public class GraphHelper
extends java.lang.Object
Constructor and Description |
---|
GraphHelper() |
Modifier and Type | Method and Description |
---|---|
static <V> java.util.List<V> |
constructPath(V source,
V target,
java.util.Set<V> nodesInGraph,
IGraphDataSource<V> graphDataSource)
Constructs a path between source and target in the given graph.
|
static <V> int |
getEdgeCount(V node,
IGraphDataSource<V> graphDataSource)
Returns the number of self-loop edges for the given node.
|
static <V> int |
getEdgeCount(V source,
V target,
IGraphDataSource<V> graphDataSource)
Returns the number of edges between the given source and target nodes.
|
static <V> Graph<V> |
getSubGraph(java.util.Collection<V> nodesInSubGraph,
IBiDirectionalGraphDataSource<V> graphDataSource)
Returns the subgraph from the given
IBiDirectionalGraphDataSource
which contains the given set of nodes. |
public static <V> Graph<V> getSubGraph(java.util.Collection<V> nodesInSubGraph, IBiDirectionalGraphDataSource<V> graphDataSource)
IBiDirectionalGraphDataSource
which contains the given set of nodes.nodesInSubGraph
- the nodes that are present in the subgraphgraphDataSource
- the graph data source for the original graphpublic static <V> java.util.List<V> constructPath(V source, V target, java.util.Set<V> nodesInGraph, IGraphDataSource<V> graphDataSource)
IGraphDataSource
and the set of nodes are used,
this way it is possible to construct a path in a given subgraph.
The returned List
contains the nodes along the path
(this means that there is an edge in the graph between two consecutive nodes).
A self loop (one edge) is indicated with the source node being present two times in the returned List
.source
- the source nodetarget
- the target nodenodesInGraph
- the nodes that are present in the subgraphgraphDataSource
- the graph data sourcepublic static <V> int getEdgeCount(V node, IGraphDataSource<V> graphDataSource)
node
- the nodegraphDataSource
- the graph data sourcepublic static <V> int getEdgeCount(V source, V target, IGraphDataSource<V> graphDataSource)
source
- the source nodetarget
- the target nodegraphDataSource
- the graph data source