java.lang.Object
tools.refinery.interpreter.rete.itc.alg.misc.GraphHelper

public class GraphHelper extends Object
Utility class for graph related operations.
  • Method Details

    • getSubGraph

      public static <V> Graph<V> getSubGraph(Collection<V> nodesInSubGraph, IBiDirectionalGraphDataSource<V> graphDataSource)
      Returns the subgraph from the given IBiDirectionalGraphDataSource which contains the given set of nodes.
      Parameters:
      nodesInSubGraph - the nodes that are present in the subgraph
      graphDataSource - 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 the 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.
      Parameters:
      source - the source node
      target - the target node
      nodesInGraph - the nodes that are present in the subgraph
      graphDataSource - the graph data source
      Returns:
      the path between the two nodes
    • getEdgeCount

      public static <V> int getEdgeCount(V node, IGraphDataSource<V> graphDataSource)
      Returns the number of self-loop edges for the given node.
      Parameters:
      node - the node
      graphDataSource - the graph data source
      Returns:
      the number of self-loop edges
    • getEdgeCount

      public static <V> int getEdgeCount(V source, V target, IGraphDataSource<V> graphDataSource)
      Returns the number of edges between the given source and target nodes.
      Parameters:
      source - the source node
      target - the target node
      graphDataSource - the graph data source
      Returns:
      the number of parallel edges between the two nodes