X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FHierarchyGraph.java;h=5b0b85f257493d8b68355c418ab72dce7b39c678;hb=75ee5e21119b65f10cf603d29ee261674cd05a9a;hp=852206af43b0a4377b7f3a40e10666dd82b6c05a;hpb=da0fa968b5637a83e1e8878fc1ab3df8e413344a;p=IRC.git diff --git a/Robust/src/Analysis/SSJava/HierarchyGraph.java b/Robust/src/Analysis/SSJava/HierarchyGraph.java index 852206af..5b0b85f2 100644 --- a/Robust/src/Analysis/SSJava/HierarchyGraph.java +++ b/Robust/src/Analysis/SSJava/HierarchyGraph.java @@ -1098,4 +1098,32 @@ public class HierarchyGraph { } bw.write(node.getName() + " [label=\"" + nodeName + "\"]" + ";\n"); } + + public int countHopFromTopLocation(HNode node) { + + Set inNodeSet = getIncomingNodeSet(node); + int count = 0; + if (inNodeSet.size() > 0) { + count = recurCountHopFromTopLocation(inNodeSet, 1); + } + + return count; + } + + private int recurCountHopFromTopLocation(Set nodeSet, int curCount) { + + int max = curCount; + for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { + HNode node = (HNode) iterator.next(); + Set inNodeSet = getIncomingNodeSet(node); + if (inNodeSet.size() > 0) { + int recurCount = recurCountHopFromTopLocation(inNodeSet, curCount + 1); + if (max < recurCount) { + max = recurCount; + } + } + } + return max; + } + }