/** * If <code>node</code> is one of the two nodes associated with this Edge, * returns the other node; otherwise returns null. */ public Node getOppositeNode(Node node) { if (dirEdge[0].getFromNode() == node) return dirEdge[0].getToNode(); if (dirEdge[1].getFromNode() == node) return dirEdge[1].getToNode(); // node not found // possibly should throw an exception here? return null; }
/** * Adds the argument node and all its out edges to the subgraph. * @param node the node to add * @param nodeStack the current set of nodes being traversed */ private void addEdges(Node node, Stack nodeStack, Subgraph subgraph) { node.setVisited(true); for (Iterator i = ((DirectedEdgeStar) node.getOutEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); subgraph.add(de.getEdge()); Node toNode = de.getToNode(); if (! toNode.isVisited()) nodeStack.push(toNode); } }
private void addReverseSubpath(DirectedEdge de, ListIterator lit, boolean expectedClosed) { // trace an unvisited path *backwards* from this de Node endNode = de.getToNode(); Node fromNode = null; while (true) { lit.add(de.getSym()); de.getEdge().setVisited(true); fromNode = de.getFromNode(); DirectedEdge unvisitedOutDE = findUnvisitedBestOrientedDE(fromNode); // this must terminate, since we are continually marking edges as visited if (unvisitedOutDE == null) break; de = unvisitedOutDE.getSym(); } if (expectedClosed) { // the path should end at the toNode of this de, otherwise we have an error Assert.isTrue(fromNode == endNode, "path not contiguous"); } }
/** * If <code>node</code> is one of the two nodes associated with this Edge, * returns the other node; otherwise returns null. */ public Node getOppositeNode(Node node) { if (dirEdge[0].getFromNode() == node) return dirEdge[0].getToNode(); if (dirEdge[1].getFromNode() == node) return dirEdge[1].getToNode(); // node not found // possibly should throw an exception here? return null; }
/** * Adds the argument node and all its out edges to the subgraph. * @param node the node to add * @param nodeStack the current set of nodes being traversed */ private void addEdges(Node node, Stack nodeStack, Subgraph subgraph) { node.setVisited(true); for (Iterator i = ((DirectedEdgeStar) node.getOutEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); subgraph.add(de.getEdge()); Node toNode = de.getToNode(); if (! toNode.isVisited()) nodeStack.push(toNode); } }
private void addReverseSubpath(DirectedEdge de, ListIterator lit, boolean expectedClosed) { // trace an unvisited path *backwards* from this de Node endNode = de.getToNode(); Node fromNode = null; while (true) { lit.add(de.getSym()); de.getEdge().setVisited(true); fromNode = de.getFromNode(); DirectedEdge unvisitedOutDE = findUnvisitedBestOrientedDE(fromNode); // this must terminate, since we are continually marking edges as visited if (unvisitedOutDE == null) break; de = unvisitedOutDE.getSym(); } if (expectedClosed) { // the path should end at the toNode of this de, otherwise we have an error Assert.isTrue(fromNode == endNode, "path not contiguous"); } }