@Override protected boolean nodeCheck(Node n, boolean throwException) { return super.nodeCheck(n, throwException); }
/** * Get the degree of a node, the number of edges for which a node * is either the source or the target. * @param n the Node instance * @return the total degree of the node */ public int getDegree(Node n) { nodeCheck(n, true); return getDegree(n.getRow()); }
/** * Remove a node from the graph, also removing all incident edges. * @param n the Node to remove from the graph * @return true if the node was successfully removed, false if the * node was not found in this graph */ public boolean removeNode(Node n) { nodeCheck(n, true); return removeNode(n.getRow()); }
/** * Get an Edge with given source and target Nodes. There may be times * where there are multiple edges between two nodes; in those cases * this method returns the first such edge found. * @param source the source Node * @param target the target Node * @return an Edge with given source and target nodes, or null if no * such edge is found. */ public Edge getEdge(Node source, Node target) { nodeCheck(source, true); nodeCheck(target, true); return getEdge(getEdge(source.getRow(), target.getRow())); }
/** * Get the in-degree of a node, the number of edges for which the node * is the target. * @param n the Node instance * @return the in-degree of the node */ public int getInDegree(Node n) { nodeCheck(n, true); return getInDegree(n.getRow()); }
/** * Get the out-degree of a node, the number of edges for which the node * is the source. * @param n the Node instance * @return the out-degree of the node */ public int getOutDegree(Node n) { nodeCheck(n, true); return getOutDegree(n.getRow()); }
/** * Get an iterator over all in-linking edges to the given Node. * @param node a Node in the graph * @return an iterator over all in-linking edges to the input target node */ public Iterator inEdges(Node node) { nodeCheck(node, true); return m_edgeTuples.iterator(inEdgeRows(node.getRow())); }
/** * Get an iterator over all out-linking edges from the given Node. * @param node a Node in the graph * @return an iterator over all out-linking edges from the input source * node */ public Iterator outEdges(Node node) { nodeCheck(node, true); return m_edgeTuples.iterator(outEdgeRows(node.getRow())); }
/** * Get an iterator over all Edges connected to the given Node in the graph. * @param node a Node in the graph * @return an iterator over all Edges connected to the input node */ public Iterator edges(Node node) { nodeCheck(node, true); return m_edgeTuples.iterator(edgeRows(node.getRow(), UNDIRECTED)); }
/** * Returns a spanning tree rooted at the specified node. If the current * spanning tree is already rooted at the given node, it is simply * returned. Otherwise, the tree is reconstructed at the new root and * made the current spanning tree for this Graph instance. * * Spanning trees are generated using an unweighted breadth first search * over the graph structure. * * @param root the node at which to root the spanning tree. * @return a spanning tree over this graph, rooted at the given root * @see #getSpanningTree() * @see #clearSpanningTree() */ public Tree getSpanningTree(Node root) { nodeCheck(root, true); if ( m_spanning == null ) { m_spanning = new SpanningTree(this, root); } else if ( m_spanning.getRoot() != root ) { m_spanning.buildSpanningTree(root); } return m_spanning; }
/** * Given an Edge and an incident Node, return the other Node * connected to the edge. * @param e an Edge instance * @param n a Node instance. This node must * be connected to the edge * @return the adjacent Node */ public Node getAdjacentNode(Edge e, Node n) { edgeCheck(e, true); nodeCheck(n, true); return getNode(getAdjacentNode(e.getRow(), n.getRow())); }