id2cn = new Hashtable<String, ConflictNode>();
}
- public void addPseudoEdgeBetweenReadOnlyNode() {
-
- Collection<ConflictNode> conflictNodes = id2cn.values();
- Set<String> analyzedIDSet = new HashSet<String>();
-
- for (Iterator iterator = conflictNodes.iterator(); iterator.hasNext();) {
- ConflictNode conflictNode = (ConflictNode) iterator.next();
- if (isReadOnly(conflictNode)
- && conflictNode.getEdgeSet().size() > 0) {
-
- for (Iterator<ConflictNode> iter = id2cn.values().iterator(); iter
- .hasNext();) {
- ConflictNode nextNode = iter.next();
-
- if (!conflictNode.equals(nextNode)
- && nextNode.getEdgeSet().size() > 0
- && !analyzedIDSet.contains(conflictNode.getID()
- + nextNode.getID())
- && !analyzedIDSet.contains(nextNode.getID()
- + conflictNode.getID())
- && isReadOnly(nextNode)) {
- if (hasSameReadEffects(conflictNode, nextNode)) {
- addConflictEdge(ConflictEdge.PSEUDO_EDGE,
- conflictNode, nextNode);
- }
- }
- analyzedIDSet.add(conflictNode.getID() + nextNode.getID());
- }
- }
- }
- }
-
- private boolean hasSameReadEffects(ConflictNode nodeA, ConflictNode nodeB) {
-
- StallSiteNode stallSiteNode = null;
- LiveInNode liveInNode = null;
-
- if (nodeA instanceof StallSiteNode && nodeB instanceof StallSiteNode) {
- return hasSameReadEffects((StallSiteNode) nodeA,
- (StallSiteNode) nodeB);
- }
-
- if (nodeA instanceof StallSiteNode) {
- stallSiteNode = (StallSiteNode) nodeA;
- } else {
- liveInNode = (LiveInNode) nodeA;
- }
-
- if (nodeB instanceof StallSiteNode) {
- stallSiteNode = (StallSiteNode) nodeB;
- } else {
- liveInNode = (LiveInNode) nodeB;
- }
-
- if (stallSiteNode != null) {
- return hasSameReadEffects(stallSiteNode, liveInNode);
- } else {
- return hasSameReadEffects((LiveInNode) nodeA, (LiveInNode) nodeB);
- }
-
- }
-
- private boolean hasSameReadEffects(LiveInNode linA, LiveInNode linB) {
-
- Set<SESEEffectsKey> readSetA = linA.getReadEffectsSet();
- Set<SESEEffectsKey> readSetB = linB.getReadEffectsSet();
-
- boolean returnValue = true;
- for (Iterator iterator = readSetA.iterator(); iterator.hasNext();) {
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator.next();
-
- for (Iterator iterator2 = readSetB.iterator(); iterator2.hasNext();) {
- SESEEffectsKey opr = (SESEEffectsKey) iterator2.next();
- if (!(seseEffectsKey.getHRNUniqueId().equals(
- opr.getHRNUniqueId()) && seseEffectsKey
- .getFieldDescriptor().equals(opr.getFieldDescriptor()))) {
- returnValue = false;
- }
- }
- }
- return returnValue;
- }
-
- private boolean hasSameReadEffects(StallSiteNode ssnA, StallSiteNode ssnB) {
-
- HashSet<Effect> effectSetA = ssnA.getStallSite().getEffectSet();
- HashSet<HeapRegionNode> nodeSetA = ssnA.getStallSite().getHRNSet();
- HashSet<Effect> effectSetB = ssnB.getStallSite().getEffectSet();
- HashSet<HeapRegionNode> nodeSetB = ssnA.getStallSite().getHRNSet();
- boolean returnValue = true;
-
- for (Iterator iteratorA = effectSetA.iterator(); iteratorA.hasNext();) {
- Effect effectKeyA = (Effect) iteratorA.next();
- for (Iterator iterator2A = nodeSetA.iterator(); iterator2A
- .hasNext();) {
- HeapRegionNode hrnA = (HeapRegionNode) iterator2A.next();
-
- for (Iterator iteratorB = effectSetB.iterator(); iteratorB
- .hasNext();) {
- Effect effectKeyB = (Effect) iteratorB.next();
- for (Iterator iterator2B = nodeSetB.iterator(); iterator2B
- .hasNext();) {
- HeapRegionNode hrnB = (HeapRegionNode) iterator2B
- .next();
-
- if (!(hrnA.getGloballyUniqueIdentifier().equals(
- hrnB.getGloballyUniqueIdentifier()) && effectKeyA
- .getField().equals(effectKeyB.getField()))) {
- returnValue = false;
- }
- }
- }
-
- }
-
- }
-
- return returnValue;
- }
-
- private boolean hasSameReadEffects(StallSiteNode ssnA, LiveInNode linB) {
-
- HashSet<Effect> effectSetA = ssnA.getStallSite().getEffectSet();
- HashSet<HeapRegionNode> nodeSetA = ssnA.getStallSite().getHRNSet();
-
- Set<SESEEffectsKey> readSetB = linB.getReadEffectsSet();
- if (readSetB == null) {
- return false;
- }
-
- boolean returnValue = true;
-
- for (Iterator iterator = effectSetA.iterator(); iterator.hasNext();) {
- Effect effectKey = (Effect) iterator.next();
- for (Iterator iterator2 = nodeSetA.iterator(); iterator2.hasNext();) {
- HeapRegionNode hrn = (HeapRegionNode) iterator2.next();
-
- for (Iterator iterator3 = readSetB.iterator(); iterator3
- .hasNext();) {
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator3
- .next();
-
- if (!(seseEffectsKey.getHRNUniqueId().equals(
- hrn.getGloballyUniqueIdentifier()) && seseEffectsKey
- .getFieldDescriptor().equals(effectKey.getField()))) {
- returnValue = false;
- }
-
- }
-
- }
- }
-
- return returnValue;
- }
-
private boolean isReadOnly(ConflictNode node) {
if (node instanceof StallSiteNode) {
return false;
}
+
+ private boolean isSCC(LiveInNode liveInNode){
+
+ Set<HeapRegionNode> liveInHrnSet = liveInNode.getHRNSet();
+// for (Iterator iterator = liveInHrnSet.iterator(); iterator.hasNext();) {
+// HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
+// System.out.println("hrn="+heapRegionNode.getGloballyUniqueIdentifier());
+// }
+
+ Set<Set> liveInNodeReachabilitySet = liveInNode.getReachabilitySet();
+ Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(liveInNodeReachabilitySet,liveInNodeReachabilitySet);
+
+ if(liveInHrnSet.size()>1){
+ if(overlappedReachableRegionSet.size()>0){
+ return true;
+ }
+ }
+
+ return false;
+ }
public void analyzePossibleConflicts(Set<String> analyzedIDSet,
ConflictNode currentNode) {
// addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
// currentNode);
// }
- if(isSelfConflicted(liveInNode)){
+ if(isSCC(liveInNode)){
+ addConflictEdge(ConflictEdge.COARSE_GRAIN_EDGE, currentNode,
+ currentNode);
+ }else if(isSelfConflicted(liveInNode)){
addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
currentNode);
}
public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
+ // if there are two edges between the same node pair, coarse has a priority
+ HashSet<ConflictEdge> set=nodeU.getEdgeSet();
+ ConflictEdge toBeRemoved=null;
+ for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+
+ if((conflictEdge.getVertexU().equals(nodeU) && conflictEdge.getVertexV().equals(nodeV)) ||
+ (conflictEdge.getVertexU().equals(nodeV) && conflictEdge.getVertexV().equals(nodeU))
+ ){
+ if(conflictEdge.getType()==ConflictEdge.FINE_GRAIN_EDGE && type==ConflictEdge.COARSE_GRAIN_EDGE){
+ toBeRemoved=conflictEdge;
+ break;
+ }else if(conflictEdge.getType()==ConflictEdge.COARSE_GRAIN_EDGE && type==ConflictEdge.FINE_GRAIN_EDGE){
+ //ignore
+ return;
+ }
+ }
+ }
+
+ if(toBeRemoved!=null){
+ nodeU.getEdgeSet().remove(toBeRemoved);
+ nodeV.getEdgeSet().remove(toBeRemoved);
+ }
+
+
ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type);
nodeU.addEdge(newEdge);
nodeV.addEdge(newEdge);
public static final int NON_WRITE_CONFLICT = 0;
public static final int FINE_GRAIN_EDGE = 1;
public static final int COARSE_GRAIN_EDGE = 2;
- public static final int PSEUDO_EDGE = 3;
public ConflictEdge(ConflictNode u, ConflictNode v, int type) {
this.u = u;
return "\"F_CONFLICT\"";
} else if (type == COARSE_GRAIN_EDGE) {
return "\"C_CONFLICT\"";
- } else if (type == PSEUDO_EDGE) {
- return "\"P_CONFLICT\", style=dotted";
} else {
return "CONFLICT\"";
}
public int getType() {
return type;
}
+
+ public String toString(){
+ return getVertexU()+"-"+getVertexV();
+ }
}
\ No newline at end of file
protected HashSet<ConflictEdge> edgeSet;
protected Set<Set> reachabilitySet;
protected TempDescriptor alias;
+ protected int type;
+
+ public static final int FINE_READ = 0;
+ public static final int FINE_WRITE = 1;
+ public static final int PARENT_READ = 2;
+ public static final int PARENT_WRITE = 3;
+ public static final int COARSE = 4;
+ public static final int SCC = 5;
+ public static final int PARENT_COARSE = 6;
+
public ConflictNode() {
edgeSet = new HashSet<ConflictEdge>();
}
public String getID() {
return id;
}
+
+ public int getType(){
+ return type;
+ }
+ public void setType(int type){
+ this.type=type;
+ }
public void addEdge(ConflictEdge edge) {
edgeSet.add(edge);
}
}
public String toString() {
- String str = "LiveInNode " + id;
+ String str = "LiveInNode " + id +" type="+type;
return str;
}
return sorted;
}
- private void calculateCliqueCovering(ConflictGraph conflictGraph) {
-
- HashSet<ConflictEdge> tocover = conflictGraph.getEdgeSet();
+ private void calculateCovering(ConflictGraph conflictGraph){
+
+ HashSet<ConflictEdge> fineToCover = new HashSet<ConflictEdge>();
+ HashSet<ConflictEdge> coarseToCover = new HashSet<ConflictEdge>();
HashSet<SESELock> lockSet=new HashSet<SESELock>();
-
- while (!tocover.isEmpty()) {
- ConflictEdge edge = (ConflictEdge) tocover.iterator().next();
- tocover.remove(edge);
-
+
+ HashSet<ConflictEdge> tempCover = conflictGraph.getEdgeSet();
+ for (Iterator iterator = tempCover.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+ if(conflictEdge.getType()==ConflictEdge.FINE_GRAIN_EDGE){
+ fineToCover.add(conflictEdge);
+ }else if(conflictEdge.getType()==ConflictEdge.COARSE_GRAIN_EDGE){
+ coarseToCover.add(conflictEdge);
+ }
+ }
+
+ HashSet<ConflictEdge> toCover=new HashSet<ConflictEdge>();
+ toCover.addAll(fineToCover);
+ toCover.addAll(coarseToCover);
+
+ while (!toCover.isEmpty()) {
+
SESELock seseLock = new SESELock();
- seseLock.addEdge(edge);
-
- boolean changed = false;
- do {
- changed = false;
- for (Iterator edgeit = tocover.iterator(); edgeit.hasNext();) {
- ConflictEdge newEdge = (ConflictEdge) edgeit.next();
- if (newEdge.getVertexU() == newEdge.getVertexV()
- && seseLock.containsConflictNode(newEdge
- .getVertexU())) {
- // for self-edge case
- tocover.remove(newEdge);
- changed = true;
+
+ boolean changed;
+
+ do{ // fine-grained edge
+
+ changed=false;
+
+ for (Iterator iterator = fineToCover.iterator(); iterator
+ .hasNext();) {
+
+ ConflictEdge edge = (ConflictEdge) iterator.next();
+ if(seseLock.getConflictNodeSet().size()==0){
+ //initial setup
+ if(seseLock.hasSelfEdge(edge.getVertexU())){
+ // mark as fine_write
+ if(edge.getVertexU() instanceof StallSiteNode){
+ edge.getVertexU().setType(ConflictNode.PARENT_WRITE);
+ }else{
+ edge.getVertexU().setType(ConflictNode.FINE_WRITE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexU());
+ }else{
+ // mark as fine_read
+ if(edge.getVertexU() instanceof StallSiteNode){
+ edge.getVertexU().setType(ConflictNode.PARENT_READ);
+ }else{
+ edge.getVertexU().setType(ConflictNode.FINE_READ);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexU());
+ }
+ if(edge.getVertexV()!=edge.getVertexU()){
+ if(seseLock.hasSelfEdge(edge.getVertexV())){
+ // mark as fine_write
+ if(edge.getVertexV() instanceof StallSiteNode){
+ edge.getVertexV().setType(ConflictNode.PARENT_WRITE);
+ }else{
+ edge.getVertexV().setType(ConflictNode.FINE_WRITE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexV());
+ }else{
+ // mark as fine_read
+ if(edge.getVertexV() instanceof StallSiteNode){
+ edge.getVertexV().setType(ConflictNode.PARENT_WRITE);
+ }else{
+ edge.getVertexV().setType(ConflictNode.FINE_READ);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexV());
+ }
+ }
+ changed=true;
+ fineToCover.remove(edge);
break;// exit iterator loop
- } else if (seseLock.testEdge(newEdge)) {
-
- ConflictNode nodeToAdd = seseLock
- .containsConflictNode(newEdge.getVertexU()) ? newEdge
- .getVertexV()
- : newEdge.getVertexU();
-
- for (Iterator newEdgeIter = nodeToAdd.getEdgeSet()
- .iterator(); newEdgeIter.hasNext();) {
- ConflictEdge ne = (ConflictEdge) newEdgeIter.next();
- if (seseLock.containsConflictNode(ne.getVertexU())) {
- tocover.remove(ne);
- } else if (seseLock.containsConflictNode(ne
- .getVertexV())) {
- tocover.remove(ne);
+ }// end of initial setup
+
+ ConflictNode newNode;
+ if((newNode=seseLock.getNewNodeConnectedWithGroup(edge))!=null){
+ // new node has a fine-grained edge to all current node
+ // If there is a coarse grained edge where need a fine edge, it's okay to add the node
+ // but the edge must remain uncovered.
+
+ changed=true;
+
+ if(seseLock.hasSelfEdge(newNode)){
+ if(newNode instanceof StallSiteNode){
+ newNode.setType(ConflictNode.PARENT_WRITE);
+ }else{
+ newNode.setType(ConflictNode.FINE_WRITE);
+ }
+ }else{
+ if(newNode instanceof StallSiteNode){
+ newNode.setType(ConflictNode.PARENT_READ);
+ }else{
+ newNode.setType(ConflictNode.FINE_READ);
+ }
+ }
+
+ seseLock.addEdge(edge);
+ HashSet<ConflictEdge> edgeSet=newNode.getEdgeSet();
+ for (Iterator iterator2 = edgeSet.iterator(); iterator2
+ .hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator2
+ .next();
+
+
+ // mark all fine edges between new node and nodes in the group as covered
+ if(!conflictEdge.getVertexU().equals(newNode)){
+ if(seseLock.containsConflictNode(conflictEdge.getVertexU())){
+ changed=true;
+ fineToCover.remove(conflictEdge);
+ }
+ }else if(!conflictEdge.getVertexV().equals(newNode)){
+ if(seseLock.containsConflictNode(conflictEdge.getVertexV())){
+ changed=true;
+ fineToCover.remove(conflictEdge);
+ }
}
+
}
- // Add in new node to lockset
- seseLock.addEdge(newEdge);
- changed = true;
- break; // exit iterator loop
+
+ break;// exit iterator loop
}
+ }
+
+ }while(changed);
+
+ do{ // coarse
+
+ changed=false;
+
+ for (Iterator iterator = coarseToCover.iterator(); iterator
+ .hasNext();) {
+
+ ConflictEdge edge = (ConflictEdge) iterator.next();
+
+ if(seseLock.getConflictNodeSet().size()==0){
+ //initial setup
+ if(seseLock.hasSelfEdge(edge.getVertexU())){
+ // node has a coarse-grained edge with itself
+ if(!(edge.getVertexU() instanceof StallSiteNode)){
+ // and it is not parent
+ edge.getVertexU().setType(ConflictNode.SCC);
+ }else{
+ edge.getVertexU().setType(ConflictNode.PARENT_COARSE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexU());
+ }else{
+ if(edge.getVertexU() instanceof StallSiteNode){
+ edge.getVertexU().setType(ConflictNode.PARENT_COARSE);
+ }else{
+ edge.getVertexU().setType(ConflictNode.COARSE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexU());
+ }
+ if(seseLock.hasSelfEdge(edge.getVertexV())){
+ // node has a coarse-grained edge with itself
+ if(!(edge.getVertexV() instanceof StallSiteNode)){
+ // and it is not parent
+ edge.getVertexV().setType(ConflictNode.SCC);
+ }else{
+ edge.getVertexV().setType(ConflictNode.PARENT_COARSE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexV());
+ }else{
+ if(edge.getVertexV() instanceof StallSiteNode){
+ edge.getVertexV().setType(ConflictNode.PARENT_COARSE);
+ }else{
+ edge.getVertexV().setType(ConflictNode.COARSE);
+ }
+ seseLock.getConflictNodeSet().add(edge.getVertexV());
+ }
+ changed=true;
+ break;// exit iterator loop
+ }// end of initial setup
+
+
+ ConflictNode newNode;
+ if((newNode=seseLock.getNewNodeConnectedWithGroup(edge))!=null){
+ // new node has a coarse-grained edge to all fine-read, fine-write, parent
+ changed=true;
+
+ if(seseLock.hasSelfEdge(newNode)){
+ //SCC
+ if(newNode instanceof StallSiteNode){
+ newNode.setType(ConflictNode.PARENT_COARSE);
+ }else{
+ newNode.setType(ConflictNode.SCC);
+ }
+ }else{
+ if(newNode instanceof StallSiteNode){
+ newNode.setType(ConflictNode.PARENT_COARSE);
+ }else{
+ newNode.setType(ConflictNode.COARSE);
+ }
+ }
+ seseLock.addEdge(edge);
+ HashSet<ConflictEdge> edgeSet=newNode.getEdgeSet();
+ for (Iterator iterator2 = edgeSet.iterator(); iterator2
+ .hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator2
+ .next();
+ // mark all coarse edges between new node and nodes in the group as covered
+ if(!conflictEdge.getVertexU().equals(newNode)){
+ if(seseLock.containsConflictNode(conflictEdge.getVertexU())){
+ changed=true;
+ coarseToCover.remove(conflictEdge);
+ }
+ }else if(!conflictEdge.getVertexV().equals(newNode)){
+ if(seseLock.containsConflictNode(conflictEdge.getVertexV())){
+ changed=true;
+ coarseToCover.remove(conflictEdge);
+ }
+ }
+
+ }
+ break;// exit iterator loop
+ }
+
+
}
- } while (changed);
- seseLock.setID(ConflictGraph.generateUniqueCliqueID());
+
+ }while(changed);
+
+// System.out.println("lock="+seseLock);
lockSet.add(seseLock);
-
- }// end of while
+
+ toCover.clear();
+ toCover.addAll(fineToCover);
+ toCover.addAll(coarseToCover);
+
+ }
- //build map from synthsized locks to conflict graph
conflictGraphLockMap.put(conflictGraph, lockSet);
-
}
-
private void synthesizeLocks(){
-
-// conflictGraphResults.put(seseSummary.getCurrentSESE(),
-// conflictGraph);
-
Set<Entry<FlatNode,ConflictGraph>> graphEntrySet=conflictGraphResults.entrySet();
for (Iterator iterator = graphEntrySet.iterator(); iterator.hasNext();) {
Entry<FlatNode, ConflictGraph> graphEntry = (Entry<FlatNode, ConflictGraph>) iterator
.next();
FlatNode sese=graphEntry.getKey();
ConflictGraph conflictGraph=graphEntry.getValue();
- calculateCliqueCovering(conflictGraph);
+ calculateCovering(conflictGraph);
}
-
}
-
+
private void makeConflictGraph() {
Iterator<Descriptor> methItr = ownAnalysis.descriptorsToAnalyze
.iterator();
FlatNode flatNode = (FlatNode) keyEnum1.nextElement();
ConflictGraph conflictGraph=conflictGraphResults.get(flatNode);
conflictGraph.analyzeConflicts();
- conflictGraph.addPseudoEdgeBetweenReadOnlyNode();
- conflictGraphResults.put(flatNode, conflictGraph);
- }
-
- // add pseudo-edge for a pair of read-only node
- keyEnum1=conflictGraphResults.keys();
- while (keyEnum1.hasMoreElements()) {
- FlatNode flatNode = (FlatNode) keyEnum1.nextElement();
- ConflictGraph conflictGraph=conflictGraphResults.get(flatNode);
-// conflictGraph.analyzeConflicts();
conflictGraphResults.put(flatNode, conflictGraph);
}
conflictNodeSet=new HashSet<ConflictNode>();
}
+ public HashSet<ConflictNode> getConflictNodeSet(){
+ return conflictNodeSet;
+ }
+
+ public boolean hasSelfEdge(ConflictNode node){
+
+ HashSet<ConflictEdge> set=node.getEdgeSet();
+ for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+ if(conflictEdge.getVertexU()==conflictEdge.getVertexV()){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isFineNode(ConflictNode node){
+
+ if(node.getType()<4){
+ return true;
+ }
+
+ return false;
+
+ }
+
+ public ConflictNode getNewNodeCoarseConnectedWithGroup(ConflictEdge newEdge) {
+
+ // check whether or not the new node has a fine-grained edges to all
+ // current nodes.
+
+ ConflictNode newNode;
+ if (conflictNodeSet.contains(newEdge.getVertexU())) {
+ newNode = newEdge.getVertexV();
+ } else if(conflictNodeSet.contains(newEdge.getVertexV())) {
+ newNode = newEdge.getVertexU();
+ }else{
+ return null;
+ }
+
+ int count = 0;
+ HashSet<ConflictEdge> edgeSet = newNode.getEdgeSet();
+ for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+ if (!conflictEdge.getVertexU().equals(newNode)
+ && conflictNodeSet.contains(conflictEdge.getVertexU()) && isFineNode(conflictEdge.getVertexU()) ) {
+ count++;
+ } else if (!conflictEdge.getVertexV().equals(newNode)
+ && conflictNodeSet.contains(conflictEdge.getVertexV()) && isFineNode(conflictEdge.getVertexU()) ) {
+ count++;
+ }
+ }
+
+ if (count == conflictNodeSet.size()) {
+ // connected to all current nodes in group
+ return newNode;
+ }
+
+ return null;
+
+ }
+
+
+ public ConflictNode getNewNodeConnectedWithGroup(ConflictEdge newEdge) {
+
+ // check whether or not the new node has a fine-grained edges to all
+ // current nodes.
+
+ ConflictNode newNode;
+ if (conflictNodeSet.contains(newEdge.getVertexU())) {
+ newNode = newEdge.getVertexV();
+ } else if(conflictNodeSet.contains(newEdge.getVertexV())){
+ newNode = newEdge.getVertexU();
+ }else{
+ return null;
+ }
+
+ int count = 0;
+ HashSet<ConflictEdge> edgeSet = newNode.getEdgeSet();
+ for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+ if (!conflictEdge.getVertexU().equals(newNode)
+ && conflictNodeSet.contains(conflictEdge.getVertexU())) {
+ count++;
+ } else if (!conflictEdge.getVertexV().equals(newNode)
+ && conflictNodeSet.contains(conflictEdge.getVertexV())) {
+ count++;
+ }
+ }
+
+ if (count == conflictNodeSet.size()) {
+ // connected to all current nodes in group
+ return newNode;
+ }
+
+ return null;
+
+ }
+
public void addEdge(ConflictEdge edge){
conflictNodeSet.add(edge.getVertexU());
conflictNodeSet.add(edge.getVertexV());
}
public String toString(){
- String str="StallSiteNode "+id;
+ String str="StallSiteNode "+id +" type="+type;
return str;
}