Class GraphHelper
java.lang.Object
tools.refinery.interpreter.rete.itc.alg.misc.GraphHelper
Utility class for graph related operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> List<V> constructPath(V source, V target, Set<V> nodesInGraph, IGraphDataSource<V> graphDataSource) Constructs a path between source and target in the given graph.static <V> intgetEdgeCount(V node, IGraphDataSource<V> graphDataSource) Returns the number of self-loop edges for the given node.static <V> intgetEdgeCount(V source, V target, IGraphDataSource<V> graphDataSource) Returns the number of edges between the given source and target nodes.static <V> Graph<V> getSubGraph(Collection<V> nodesInSubGraph, IBiDirectionalGraphDataSource<V> graphDataSource) Returns the subgraph from the givenIBiDirectionalGraphDataSourcewhich contains the given set of nodes.
-
Method Details
-
getSubGraph
public static <V> Graph<V> getSubGraph(Collection<V> nodesInSubGraph, IBiDirectionalGraphDataSource<V> graphDataSource) Returns the subgraph from the givenIBiDirectionalGraphDataSourcewhich contains the given set of nodes.- Parameters:
nodesInSubGraph- the nodes that are present in the subgraphgraphDataSource- the graph data source for the original graph- Returns:
- the subgraph associated to the given nodes
-
constructPath
public static <V> List<V> constructPath(V source, V target, Set<V> nodesInGraph, IGraphDataSource<V> graphDataSource) Constructs a path between source and target in the given graph. Both theIGraphDataSourceand the set of nodes are used, this way it is possible to construct a path in a given subgraph. The returnedListcontains 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 returnedList.- Parameters:
source- the source nodetarget- the target nodenodesInGraph- the nodes that are present in the subgraphgraphDataSource- the graph data source- Returns:
- the path between the two nodes
-
getEdgeCount
Returns the number of self-loop edges for the given node.- Parameters:
node- the nodegraphDataSource- the graph data source- Returns:
- the number of self-loop edges
-
getEdgeCount
Returns the number of edges between the given source and target nodes.- Parameters:
source- the source nodetarget- the target nodegraphDataSource- the graph data source- Returns:
- the number of parallel edges between the two nodes
-