org.neo4j.graphalgo.impl.shortestpath
Class Util

java.lang.Object
  extended by org.neo4j.graphalgo.impl.shortestpath.Util

public class Util
extends Object

This is a holder for some utility functions regarding paths, such as constructing them from sets of predecessors or counting them. These functions are lifted out here because they can be used by algorithms for too different problems.

Author:
Patrik Larsson

Nested Class Summary
static class Util.PathCounter
          This can be used for counting the number of paths from the start node (implicit from the predecessors) and some target nodes.
 
Constructor Summary
Util()
           
 
Method Summary
static List<List<PropertyContainer>> constructAllPathsToNode(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Constructs all paths to a given node, for a given set of predecessors
protected static List<LinkedList<PropertyContainer>> constructAllPathsToNodeAsLinkedLists(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Same as constructAllPathsToNode, but different return type
protected static List<LinkedList<Node>> constructAllPathsToNodeAsNodeLinkedLists(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Same as constructAllPathsToNodeAsNodes, but different return type
static List<List<Node>> constructAllPathsToNodeAsNodes(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Constructs all paths to a given node, for a given set of predecessors
protected static List<LinkedList<Relationship>> constructAllPathsToNodeAsRelationshipLinkedLists(Node node, Map<Node,List<Relationship>> predecessors, boolean backwards)
          Same as constructAllPathsToNodeAsRelationships, but different return type
static List<List<Relationship>> constructAllPathsToNodeAsRelationships(Node node, Map<Node,List<Relationship>> predecessors, boolean backwards)
          Constructs all paths to a given node, for a given set of predecessors.
static List<PropertyContainer> constructSinglePathToNode(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Constructs a path to a given node, for a given set of predecessors.
static List<Node> constructSinglePathToNodeAsNodes(Node node, Map<Node,List<Relationship>> predecessors, boolean includeNode, boolean backwards)
          Constructs a path to a given node, for a given set of predecessors
static List<Relationship> constructSinglePathToNodeAsRelationships(Node node, Map<Node,List<Relationship>> predecessors, boolean backwards)
          Constructs a path to a given node, for a given set of predecessors
static Map<Node,List<Relationship>> reversedPredecessors(Map<Node,List<Relationship>> predecessors)
          This can be used to generate the inverse of a structure with predecessors, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

constructSinglePathToNodeAsNodes

public static List<Node> constructSinglePathToNodeAsNodes(Node node,
                                                          Map<Node,List<Relationship>> predecessors,
                                                          boolean includeNode,
                                                          boolean backwards)
Constructs a path to a given node, for a given set of predecessors

Parameters:
node - The start node
predecessors - The predecessors set
includeNode - Boolean which determines if the start node should be included in the paths
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:
A path as a list of nodes.

constructSinglePathToNodeAsRelationships

public static List<Relationship> constructSinglePathToNodeAsRelationships(Node node,
                                                                          Map<Node,List<Relationship>> predecessors,
                                                                          boolean backwards)
Constructs a path to a given node, for a given set of predecessors

Parameters:
node - The start node
predecessors - The predecessors set
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:
A path as a list of relationships.

constructSinglePathToNode

public static List<PropertyContainer> constructSinglePathToNode(Node node,
                                                                Map<Node,List<Relationship>> predecessors,
                                                                boolean includeNode,
                                                                boolean backwards)
Constructs a path to a given node, for a given set of predecessors. The result is a list of alternating Node/Relationship.

Parameters:
node - The start node
predecessors - The predecessors set
includeNode - Boolean which determines if the start node should be included in the paths
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:
A path as a list of alternating Node/Relationship.

constructAllPathsToNodeAsNodes

public static List<List<Node>> constructAllPathsToNodeAsNodes(Node node,
                                                              Map<Node,List<Relationship>> predecessors,
                                                              boolean includeNode,
                                                              boolean backwards)
Constructs all paths to a given node, for a given set of predecessors

Parameters:
node - The start node
predecessors - The predecessors set
includeNode - Boolean which determines if the start node should be included in the paths
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:

constructAllPathsToNodeAsNodeLinkedLists

protected static List<LinkedList<Node>> constructAllPathsToNodeAsNodeLinkedLists(Node node,
                                                                                 Map<Node,List<Relationship>> predecessors,
                                                                                 boolean includeNode,
                                                                                 boolean backwards)
Same as constructAllPathsToNodeAsNodes, but different return type


constructAllPathsToNode

public static List<List<PropertyContainer>> constructAllPathsToNode(Node node,
                                                                    Map<Node,List<Relationship>> predecessors,
                                                                    boolean includeNode,
                                                                    boolean backwards)
Constructs all paths to a given node, for a given set of predecessors

Parameters:
node - The start node
predecessors - The predecessors set
includeNode - Boolean which determines if the start node should be included in the paths
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:
List of lists of alternating Node/Relationship.

constructAllPathsToNodeAsLinkedLists

protected static List<LinkedList<PropertyContainer>> constructAllPathsToNodeAsLinkedLists(Node node,
                                                                                          Map<Node,List<Relationship>> predecessors,
                                                                                          boolean includeNode,
                                                                                          boolean backwards)
Same as constructAllPathsToNode, but different return type


constructAllPathsToNodeAsRelationships

public static List<List<Relationship>> constructAllPathsToNodeAsRelationships(Node node,
                                                                              Map<Node,List<Relationship>> predecessors,
                                                                              boolean backwards)
Constructs all paths to a given node, for a given set of predecessors.

Parameters:
node - The start node
predecessors - The predecessors set
backwards - Boolean, if true the order of the nodes in the paths will be reversed
Returns:
List of lists of relationships.

constructAllPathsToNodeAsRelationshipLinkedLists

protected static List<LinkedList<Relationship>> constructAllPathsToNodeAsRelationshipLinkedLists(Node node,
                                                                                                 Map<Node,List<Relationship>> predecessors,
                                                                                                 boolean backwards)
Same as constructAllPathsToNodeAsRelationships, but different return type


reversedPredecessors

public static Map<Node,List<Relationship>> reversedPredecessors(Map<Node,List<Relationship>> predecessors)
This can be used to generate the inverse of a structure with predecessors, i.e. the successors.

Parameters:
predecessors -
Returns:


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.