/** * Adds the Edge and its DirectedEdges with this PlanarGraph. * Assumes that the Edge has already been created with its associated DirectEdges. * Only subclasses can add Edges, to ensure the edges added are of the right class. */ protected void add(Edge edge) { edges.add(edge); add(edge.getDirEdge(0)); add(edge.getDirEdge(1)); }
/** * Adds an {@link Edge} to the subgraph. * The associated {@link DirectedEdge}s and {@link Node}s * are also added. * * @param e the edge to add */ public void add(Edge e) { if (edges.contains(e)) return; edges.add(e); dirEdges.add(e.getDirEdge(0)); dirEdges.add(e.getDirEdge(1)); nodeMap.add(e.getDirEdge(0).getFromNode()); nodeMap.add(e.getDirEdge(1).getFromNode()); }
/** * Removes an {@link Edge} and its associated {@link DirectedEdge}s * from their from-Nodes and from the graph. * Note: This method does not remove the {@link Node}s associated * with the {@link Edge}, even if the removal of the {@link Edge} * reduces the degree of a {@link Node} to zero. */ public void remove(Edge edge) { remove(edge.getDirEdge(0)); remove(edge.getDirEdge(1)); edges.remove(edge); edge.remove(); }
public List getConnectedSubgraphs() { List subgraphs = new ArrayList(); GraphComponent.setVisited(graph.nodeIterator(), false); for (Iterator i = graph.edgeIterator(); i.hasNext(); ) { Edge e = (Edge) i.next(); Node node = e.getDirEdge(0).getFromNode(); if (! node.isVisited()) { subgraphs.add(findSubgraph(node)); } } return subgraphs; }
/** * Adds the Edge and its DirectedEdges with this PlanarGraph. * Assumes that the Edge has already been created with its associated DirectEdges. * Only subclasses can add Edges, to ensure the edges added are of the right class. */ protected void add(Edge edge) { edges.add(edge); add(edge.getDirEdge(0)); add(edge.getDirEdge(1)); }
/** * Adds an {@link Edge} to the subgraph. * The associated {@link DirectedEdge}s and {@link Node}s * are also added. * * @param e the edge to add */ public void add(Edge e) { if (edges.contains(e)) return; edges.add(e); dirEdges.add(e.getDirEdge(0)); dirEdges.add(e.getDirEdge(1)); nodeMap.add(e.getDirEdge(0).getFromNode()); nodeMap.add(e.getDirEdge(1).getFromNode()); }
/** * Removes an {@link Edge} and its associated {@link DirectedEdge}s * from their from-Nodes and from the graph. * Note: This method does not remove the {@link Node}s associated * with the {@link Edge}, even if the removal of the {@link Edge} * reduces the degree of a {@link Node} to zero. */ public void remove(Edge edge) { remove(edge.getDirEdge(0)); remove(edge.getDirEdge(1)); edges.remove(edge); edge.remove(); }
public List getConnectedSubgraphs() { List subgraphs = new ArrayList(); GraphComponent.setVisited(graph.nodeIterator(), false); for (Iterator i = graph.edgeIterator(); i.hasNext(); ) { Edge e = (Edge) i.next(); Node node = e.getDirEdge(0).getFromNode(); if (! node.isVisited()) { subgraphs.add(findSubgraph(node)); } } return subgraphs; }