|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.algo.Paths
public class Paths
Responsible for finding paths within a graph that have certain properties.
Constructor Summary | |
---|---|
Paths()
|
Method Summary | |
---|---|
static NodeList |
constructNodePath(EdgeList path)
Constructs a node path from a given edge path. |
static EdgeList[] |
findAllChains(Graph graph,
boolean directed)
Returns all chains present in the given graph. |
static EdgeList[] |
findAllPaths(Graph graph,
Node startNode,
Node endNode,
boolean directed)
Returns all simple directed or undirected paths that connect start with end node. |
static EdgeList[] |
findAllPaths(Graph graph,
Node startNode,
Node endNode,
boolean directed,
Filter filter)
A variant of findAllPaths(Graph, Node, Node, boolean)
that additionally allows to specify a filter for the paths to be returned. |
static void |
findAllPaths(Graph g,
Node start,
Node end,
EdgeMap pathEdges)
Marks all edges that belong to a directed path from start to end node. |
static YCursor |
findAllPathsCursor(Graph graph,
Node startNode,
Node endNode,
boolean directed)
A variant of findAllPaths(Graph, Node, Node, boolean)
that returns its result not as a list but as a special cursor that calculates
the next path in the sequence only when needed. |
static EdgeList |
findLongestPath(Graph g)
Returns the longest directed path within the given acyclic graph. |
static EdgeList |
findLongestPath(Graph g,
DataProvider edgeLength)
Returns the longest directed path within a given acyclic weighted graph. |
static void |
findLongestPaths(Graph g,
Node startNode,
EdgeMap dist,
NodeMap maxDist,
EdgeMap predicate)
Calculates the longest path from one vertex to all other vertices in a given acyclic graph |
static EdgeList |
findLongPath(Graph graph)
Returns an edge list that contains the edges of a undirected simple path within the given graph. |
static boolean |
findPath(Graph g,
NodeList topSort,
Node startNode,
Node endNode,
EdgeMap predicate)
Returns whether or not there is a directed path from one node to another node in an acyclic graph |
static EdgeList |
findPath(Graph graph,
Node startNode,
Node endNode,
boolean directed)
Returns an edge list that contains the edges of a path from the given start node to the given end node, if such a path exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Paths()
Method Detail |
---|
public static EdgeList findPath(Graph graph, Node startNode, Node endNode, boolean directed)
graph
- the input graphstartNode
- the first node of the pathendNode
- the last node of the pathdirected
- whether to search for a directed or undirected pathpublic static EdgeList findLongPath(Graph graph)
public static void findLongestPaths(Graph g, Node startNode, EdgeMap dist, NodeMap maxDist, EdgeMap predicate)
g
- a directed acyclic graph.startNode
- the node, for which the distances are calculated.dist
- the distances for the edges.maxDist
- here the result will be stored.predicate
- only edges for which predicate is true are considered.public static EdgeList findLongestPath(Graph g)
g
- a directed acyclic graph
public static EdgeList findLongestPath(Graph g, DataProvider edgeLength)
g
- a directed acyclic graphedgeLength
- a data provider that must provide the length of each
edge as an int value
public static NodeList constructNodePath(EdgeList path)
path.size()+1
, if the given path is not empty.
Otherwise the returned path will be empty. The i-th node in the
returned path will be either source or target node of the i-th edge
in the given path.
public static boolean findPath(Graph g, NodeList topSort, Node startNode, Node endNode, EdgeMap predicate)
g
- the acyclic graph which contains the two nodes.topSort
- a topological sorting of the nodes of the graph.predicate
- only edges for which predicate is true are considered.public static final void findAllPaths(Graph g, Node start, Node end, EdgeMap pathEdges)
start
to end
node.
g
- the input graphstart
- the start nodeend
- the end nodepathEdges
- the result. For each edge a boolean value will indicate whether or not
it belongs to a path connecting the two nodes.public static EdgeList[] findAllChains(Graph graph, boolean directed)
graph
- the input graph
constructNodePath(EdgeList)
can be used to convert an edge path
to a node path.public static EdgeList[] findAllPaths(Graph graph, Node startNode, Node endNode, boolean directed)
start
with end
node.
One should note that the number of different paths connecting two nodes can be exponential
in number of nodes and edges of a given graph. This said, even for small graphs the runtime and memory
consumption of the algorithm can be excessive. To significantly lower memory consumption use
findAllPathsCursor(Graph, Node, Node, boolean)
instead.
graph
- the input graphstartNode
- the start nodeendNode
- the end nodedirected
- whether or not to consider the edges in the graph to be directed or not.
null
.public static YCursor findAllPathsCursor(Graph graph, Node startNode, Node endNode, boolean directed)
findAllPaths(Graph, Node, Node, boolean)
that returns its result not as a list but as a special cursor that calculates
the next path in the sequence only when needed.
The returned cursor only supports the operation YCursor.ok()
,
YCursor.current()
, YCursor.size()
and YCursor.next()
.
public static EdgeList[] findAllPaths(Graph graph, Node startNode, Node endNode, boolean directed, Filter filter)
findAllPaths(Graph, Node, Node, boolean)
that additionally allows to specify a filter for the paths to be returned.
filter
- a filter that tests for each found EdgeList if it should make it to the result list.
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |