/** * 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)); }
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; }
/** * 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(); }
/** * Returns all Nodes with the given number of Edges around it. */ public List findNodesOfDegree(int degree) { List nodesFound = new ArrayList(); for (Iterator i = nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (node.getDegree() == degree) nodesFound.add(node); } return nodesFound; }
/** * Returns all Nodes with the given number of Edges around it. */ public List findNodesOfDegree(int degree) { List nodesFound = new ArrayList(); for (Iterator i = nodeIterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (node.getDegree() == degree) nodesFound.add(node); } return nodesFound; }
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; }
/** * Removes a node from the graph, along with any associated DirectedEdges and * Edges. */ public void remove(Node node) { // unhook all directed edges List outEdges = node.getOutEdges().getEdges(); for (Iterator i = outEdges.iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); DirectedEdge sym = de.getSym(); // remove the diredge that points to this node if (sym != null) remove(sym); // remove this diredge from the graph collection dirEdges.remove(de); Edge edge = de.getEdge(); if (edge != null) { edges.remove(edge); } } // remove the node from the graph nodeMap.remove(node.getCoordinate()); node.remove(); }
/** * 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)); }
/** * 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(); }
/** * Removes a node from the graph, along with any associated DirectedEdges and * Edges. */ public void remove(Node node) { // unhook all directed edges List outEdges = node.getOutEdges().getEdges(); for (Iterator i = outEdges.iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); DirectedEdge sym = de.getSym(); // remove the diredge that points to this node if (sym != null) remove(sym); // remove this diredge from the graph collection dirEdges.remove(de); Edge edge = de.getEdge(); if (edge != null) { edges.remove(edge); } } // remove the node from the graph nodeMap.remove(node.getCoordinate()); node.remove(); }