- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Known Implementing Classes:
DefaultGraphIterables
Whether the returned iterators support removal of elements is left to the graph implementation. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.
- Author:
- Dimitrios Michail
-
Method Summary
Modifier and TypeMethodDescriptionReturns an iterable view over all edges connecting source vertex to target vertex if such vertices exist in this graph.default long
Returns the degree of the specified vertex.default long
Return the number of edges in the graph.edges()
Returns an iterable over the edges of the graph.Returns an iterable view over all edges touching the specified vertex.getGraph()
Get the underlying graph.incomingEdgesOf
(V vertex) Returns an iterable view over all edges incoming into the specified vertex.default long
inDegreeOf
(V vertex) Returns the "in degree" of the specified vertex.default long
outDegreeOf
(V vertex) Returns the "out degree" of the specified vertex.outgoingEdgesOf
(V vertex) Returns an iterable view over all edges outgoing into the specified vertex.default long
Return the number of vertices in the graph.vertices()
Returns an iterable view over the vertices contained in this graph.
-
Method Details
-
getGraph
Get the underlying graph.- Returns:
- the underlying graph
-
edges
Returns an iterable over the edges of the graph.Whether the ordering is deterministic, depends on the actual graph implementation. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.
- Returns:
- an iterable over the edges of the graph.
-
edgeCount
default long edgeCount()Return the number of edges in the graph.- Returns:
- the number of edges.
-
vertices
Returns an iterable view over the vertices contained in this graph. The returned iterator is a live view of the vertices. If the graph is modified while an iteration is in progress, the results of the iteration are undefined.The graph implementation may maintain a particular ordering for deterministic iteration, but this is not required. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.
- Returns:
- an iterable view of the vertices contained in this graph
-
vertexCount
default long vertexCount()Return the number of vertices in the graph.- Returns:
- the number of vertices
-
edgesOf
Returns an iterable view over all edges touching the specified vertex. The returned iterators are live views. If the graph is modified while an iteration is in progress, the results of the iteration are undefined. If no edges are touching the specified vertex, the returned iterators are already exhausted.- Parameters:
vertex
- input vertex- Returns:
- an iterable view of the vertices contained in this graph
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
degreeOf
Returns the degree of the specified vertex.A degree of a vertex in an undirected graph is the number of edges touching that vertex. Edges with same source and target vertices (self-loops) are counted twice.
In directed graphs this method returns the sum of the "in degree" and the "out degree".
- Parameters:
vertex
- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
incomingEdgesOf
Returns an iterable view over all edges incoming into the specified vertex. The returned iterators are live views. If the graph is modified while an iteration is in progress, the results of the iteration are undefined.In the case of undirected graphs the returned iterators return all edges touching the vertex, thus, some of the returned edges may have their source and target vertices in the opposite order.
- Parameters:
vertex
- input vertex- Returns:
- an iterable view of all edges incoming into the specified vertex
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
inDegreeOf
Returns the "in degree" of the specified vertex.The "in degree" of a vertex in a directed graph is the number of inward directed edges from that vertex. See http://mathworld.wolfram.com/Indegree.html.
In the case of undirected graphs this method returns the number of edges touching the vertex. Edges with same source and target vertices (self-loops) are counted twice.
- Parameters:
vertex
- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
outgoingEdgesOf
Returns an iterable view over all edges outgoing into the specified vertex. The returned iterators are live views. If the graph is modified while an iteration is in progress, the results of the iteration are undefined.In the case of undirected graphs the returned iterators return all edges touching the vertex, thus, some of the returned edges may have their source and target vertices in the opposite order.
- Parameters:
vertex
- input vertex- Returns:
- an iterable view of all edges outgoing from the specified vertex
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
outDegreeOf
Returns the "out degree" of the specified vertex.The "out degree" of a vertex in a directed graph is the number of outward directed edges from that vertex. See http://mathworld.wolfram.com/Outdegree.html.
In the case of undirected graphs this method returns the number of edges touching the vertex. Edges with same source and target vertices (self-loops) are counted twice.
- Parameters:
vertex
- vertex whose degree is to be calculated.- Returns:
- the degree of the specified vertex.
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-
allEdges
Returns an iterable view over all edges connecting source vertex to target vertex if such vertices exist in this graph. The returned iterators are live views. If the graph is modified while an iteration is in progress, the results of the iteration are undefined. If any of the vertices does not exist or isnull
, returnsnull
. If both vertices exist but no edges found, returns an iterable which returns exhausted iterators.In undirected graphs, some of the returned edges may have their source and target vertices in the opposite order. In simple graphs the returned set is either singleton set or empty set.
- Parameters:
sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.- Returns:
- an iterable view of all edges connecting source to target vertex.
- Throws:
IllegalArgumentException
- if vertex is not found in the graph.NullPointerException
- if vertex isnull
.
-