computeDepths method
Compute depths for all dirEdges via breadth-first traversal of nodes in graph @param startEdge edge to start processing with
Implementation
// <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
void computeDepths(DirectedEdge startEdge) {
Set nodesVisited = new HashSet();
Queue nodeQueue = new Queue();
Node startNode = startEdge.getNode()!;
nodeQueue.addLast(startNode);
nodesVisited.add(startNode);
startEdge.setVisited(true);
while (!nodeQueue.isEmpty) {
// print("count = ${tmp++}");
//System.out.println(nodes.size() + " queue: " + nodeQueue.size());
Node n = nodeQueue.removeFirst();
nodesVisited.add(n);
// compute depths around node, starting at this edge since it has depths assigned
computeNodeDepth(n);
// add all adjacent nodes to process queue,
// unless the node has been visited already
for (Iterator i = (n.getEdges() as DirectedEdgeStar).iterator();
i.moveNext();) {
DirectedEdge de = i.current;
DirectedEdge sym = de.getSym();
if (sym.isVisited()) continue;
Node adjNode = sym.getNode()!;
if (!(nodesVisited.contains(adjNode))) {
nodeQueue.addLast(adjNode);
nodesVisited.add(adjNode);
}
}
}
}