Interface Node
- All Known Implementing Classes:
AbstractNode,AdjacencyListNode,GraphicNode,MultiNode,SingleNode
public interface Node extends Element, Iterable<Edge>
Important
Implementing classes should indicate the complexity of their implementation for each method.
- Since:
- July 12 2007
-
Method Summary
Modifier and Type Method Description Stream<Edge>edges()Stream over all entering and leaving edges.default Stream<Edge>enteringEdges()Stream over all entering edges.Iterator<Node>getBreadthFirstIterator()Iterator for breadth first exploration of the graph, starting at this node.Iterator<Node>getBreadthFirstIterator(boolean directed)Iterator for breadth first exploration of the graph, starting at this node.intgetDegree()Total number of relations with other nodes or this node.Iterator<Node>getDepthFirstIterator()Iterator for depth first exploration of the graph, starting at this node.Iterator<Node>getDepthFirstIterator(boolean directed)Iterator for depth first exploration of the graph, starting at this node.EdgegetEdge(int i)I-th edge.EdgegetEdgeBetween(int index)Retrieves an edge between this node and the node with index i if one exists.EdgegetEdgeBetween(String id)Retrieve an edge between this node and the node 'id', if it exits.EdgegetEdgeBetween(Node node)Retrieves an edge between this node and and another node if one exists.EdgegetEdgeFrom(int index)Retrieves an edge that leaves node with given index toward this node.EdgegetEdgeFrom(String id)Retrieve an edge that leaves node 'id' toward this node.EdgegetEdgeFrom(Node node)Retrieves an edge that leaves given node toward this node.EdgegetEdgeToward(int index)Retrieves an edge that leaves this node toward the node with given index.EdgegetEdgeToward(String id)Retrieve an edge that leaves this node toward 'id'.EdgegetEdgeToward(Node node)Retrieves an edge that leaves this node toward another node.EdgegetEnteringEdge(int i)I-th entering edge.GraphgetGraph()Parent graph.intgetInDegree()Number of entering edges.EdgegetLeavingEdge(int i)I-th leaving edge.intgetOutDegree()Number of leaving edges.default booleanhasEdgeBetween(int index)True if an edge exists between this node and a node with given index.default booleanhasEdgeBetween(String id)True if an edge exists between this node and node 'id'.default booleanhasEdgeBetween(Node node)True if an edge exists between this node and another node.default booleanhasEdgeFrom(int index)True if an edge enters this node from a node with given index.default booleanhasEdgeFrom(String id)True if an edge enters this node from node 'id'.default booleanhasEdgeFrom(Node node)True if an edge enters this node from a given node.default booleanhasEdgeToward(int index)True if an edge leaves this node toward a node with given index.default booleanhasEdgeToward(String id)True if an edge leaves this node toward node 'id'.default booleanhasEdgeToward(Node node)True if an edge leaves this node toward a given node.default Iterator<Edge>iterator()default Stream<Edge>leavingEdges()Stream over all leaving edges.default Stream<Node>neighborNodes()Stream over neighbor nodes connected to this node via one or more edges.StringtoString()Override the Object.toString() method.Methods inherited from interface org.graphstream.graph.Element
attributeKeys, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, getLabel, getMap, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasLabel, hasMap, hasNumber, hasVector, removeAttribute, setAttribute, setAttributes
-
Method Details
-
getGraph
Graph getGraph()Parent graph. Some elements are not able to give their parent graph.- Returns:
- The graph containing this node or null if unknown.
-
getDegree
int getDegree()Total number of relations with other nodes or this node.- Returns:
- The number of edges/relations/links.
-
getOutDegree
int getOutDegree()Number of leaving edges.- Returns:
- the count of edges that only leave this node plus all undirected edges.
-
getInDegree
int getInDegree()Number of entering edges.- Returns:
- the count of edges that only enter this node plus all undirected edges.
-
getEdgeToward
Retrieve an edge that leaves this node toward 'id'.This method selects only edges leaving this node an pointing at node 'id' (this also selects undirected edges).
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeToward("...");the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
id- Identifier of the target node.- Returns:
- Directed edge going from this node to 'id', or undirected edge if it exists, else null.
-
getEdgeFrom
Retrieve an edge that leaves node 'id' toward this node.This method selects only edges leaving node 'id' an pointing at this node (this also selects undirected edges).
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeFrom("...");the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
id- Identifier of the source node.- Returns:
- Directed edge going from node 'id' to this node, or undirected edge if it exists, else null.
-
getEdgeBetween
Retrieve an edge between this node and the node 'id', if it exits.This method selects directed or undirected edges. If the edge is directed, its direction is not important and leaving or entering edges will be selected.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeBetween("...");the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
id- Identifier of the opposite node.- Returns:
- Edge between node 'id' and this node if it exists, else null.
-
neighborNodes
Stream over neighbor nodes connected to this node via one or more edges. This iterator iterates across any leaving, entering and non directed edges (nodes are neighbors even if they only have a directed edge from them toward this node). If there are multiple edges connecting the same node, it might be iterated several times.- Returns:
- The stream, neighbors are streamed in arbitrary order.
-
getEdge
I-th edge. Edges are stored in no given order.However this method allows to iterate very quickly on all edges, or to choose a given edge with direct access.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdge(i);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
i- Index of the edge.- Returns:
- The i-th edge.
- Throws:
IndexOutOfBoundsException- ifiis negative or greater than or equal to the degree
-
getEnteringEdge
I-th entering edge. Edges are stored in no given order.However this method allows to iterate very quickly on all entering edges, or to choose a given entering edge with direct access.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEnteringEdge(i);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
i- Index of the edge.- Returns:
- The i-th entering edge.
- Throws:
IndexOutOfBoundsException- ifiis negative or greater than or equal to the in-degree
-
getLeavingEdge
I-th leaving edge. Edges are stored in no given order.However this method allows to iterate very quickly on all leaving edges, or to choose a given leaving edge with direct access.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getLeavingEdge(i);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
i- Index of the edge.- Returns:
- The i-th leaving edge.
- Throws:
IndexOutOfBoundException- ifiis negative or greater than or equal to the out-degree
-
getBreadthFirstIterator
Iterator for breadth first exploration of the graph, starting at this node.If the graph is not connected, only a part of it will be explored. By default, this iterator will respect edge orientation.
This method is implicitly generic and return an Iterator over something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
Iterator<ExtendedNode> ite = node.getBreadthFirstIterator();
the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.- Returns:
- An iterator able to explore the graph in a breadth first way starting at this node.
-
getBreadthFirstIterator
Iterator for breadth first exploration of the graph, starting at this node.If the graph is not connected, only a part of it will be explored.
This method is implicitly generic and return an Iterator over something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
Iterator<ExtendedNode> ite = node.getBreadthFirstIterator(true);
the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.- Parameters:
directed- If false, the iterator will ignore edge orientation (the default is "True").- Returns:
- An iterator able to explore the graph in a breadth first way starting at this node.
-
getDepthFirstIterator
Iterator for depth first exploration of the graph, starting at this node.If the graph is not connected, only a part of it will be explored. By default, this iterator will respect edge orientation.
This method is implicitly generic and return an Iterator over something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
Iterator<ExtendedNode> ite = node.getDepthFirstIterator();
the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.- Returns:
- An iterator able to explore the graph in a depth first way starting at this node.
- Computational Complexity :
- of the depth first iterator O(n+m) with n the number of nodes and m the number of edges.
-
getDepthFirstIterator
Iterator for depth first exploration of the graph, starting at this node.If the graph is not connected, only a part of it will be explored.
This method is implicitly generic and return an Iterator over something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
Iterator<ExtendedNode> ite = node.getDepthFirstIterator(true);
the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.- Parameters:
directed- If false, the iterator will ignore edge orientation (the default is "True").- Returns:
- An iterator able to explore the graph in a depth first way starting at this node.
-
edges
Stream over all entering and leaving edges.- Returns:
- A stream over all directed and undirected edges, leaving or entering.
-
leavingEdges
Stream over all leaving edges.- Returns:
- A stream over only edges that leave this node plus all undirected edges.
-
enteringEdges
Stream over all entering edges.- Returns:
- A stream over only edges that enter this node plus all undirected edges.
-
iterator
-
toString
String toString()Override the Object.toString() method. -
hasEdgeToward
True if an edge leaves this node toward node 'id'.- Parameters:
id- Identifier of the target node.- Returns:
- True if a directed edge goes from this node to 'id' or if an undirected edge exists.
-
hasEdgeToward
True if an edge leaves this node toward a given node.- Parameters:
node- The target node.- Returns:
- True if a directed edge goes from this node to the other node or if an undirected edge exists.
-
hasEdgeToward
True if an edge leaves this node toward a node with given index.- Parameters:
index- Index of the target node.- Returns:
- True if a directed edge goes from this node to the other node or if an undirected edge exists.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-
hasEdgeFrom
True if an edge enters this node from node 'id'.- Parameters:
id- Identifier of the source node.- Returns:
- True if a directed edge goes from this node to 'id' or if an undirected edge exists.
-
hasEdgeFrom
True if an edge enters this node from a given node.- Parameters:
node- The source node.- Returns:
- True if a directed edge goes from the other node to this node or if an undirected edge exists.
-
hasEdgeFrom
True if an edge enters this node from a node with given index.- Parameters:
index- Index of the source node.- Returns:
- True if a directed edge goes from the other node to this node or if an undirected edge exists.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-
hasEdgeBetween
True if an edge exists between this node and node 'id'.- Parameters:
id- Identifier of another node.- Returns:
- True if a edge exists between this node and node 'id'.
-
hasEdgeBetween
True if an edge exists between this node and another node.- Parameters:
node- Another node.- Returns:
- True if an edge exists between this node and the other node.
-
hasEdgeBetween
True if an edge exists between this node and a node with given index.- Parameters:
index- Index of another node.- Returns:
- True if an edge exists between this node and the other node.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-
getEdgeToward
Retrieves an edge that leaves this node toward another node.This method selects only edges leaving this node an pointing at the parameter node (this also selects undirected edges).
This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeToward(...);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
node- The target node.- Returns:
- Directed edge going from this node to the parameter node, or undirected edge if it exists, else null.
-
getEdgeToward
Retrieves an edge that leaves this node toward the node with given index.This method selects only edges leaving this node an pointing at the parameter node (this also selects undirected edges).
This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeToward(...);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
index- Index of the target node.- Returns:
- Directed edge going from this node to the parameter node, or undirected edge if it exists, else null.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-
getEdgeFrom
Retrieves an edge that leaves given node toward this node.This method selects only edges leaving the other node an pointing at this node (this also selects undirected edges).
This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeFrom(...);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
node- The source node.- Returns:
- Directed edge going from the parameter node to this node, or undirected edge if it exists, else null.
-
getEdgeFrom
Retrieves an edge that leaves node with given index toward this node.This method selects only edges leaving the other node an pointing at this node (this also selects undirected edges).
This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeFrom("...");the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
index- Index of the source node.- Returns:
- Directed edge going from the parameter node to this node, or undirected edge if it exists, else null.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-
getEdgeBetween
Retrieves an edge between this node and and another node if one exists.This method selects directed or undirected edges. If the edge is directed, its direction is not important and leaving or entering edges will be selected.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeBetween(...);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
node- The opposite node.- Returns:
- Edge between this node and the parameter node if it exists, else null.
-
getEdgeBetween
Retrieves an edge between this node and the node with index i if one exists.This method selects directed or undirected edges. If the edge is directed, its direction is not important and leaving or entering edges will be selected.
This method is implicitly generic and return something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedEdge e = node.getEdgeBetween(...);
the method will return an ExtendedEdge. If no left part exists, method will just return an Edge.- Parameters:
index- The index of the opposite node.- Returns:
- Edge between node with index i and this node if it exists, else null.
- Throws:
IndexOutOfBoundsException- if the index is negative or greater thangetNodeCount() - 1.
-