public class PathFinder
extends java.lang.Object
Constructor and Description |
---|
PathFinder(Diagram diagram)
Initializes a new instance of the
PathFinder class. |
PathFinder(Diagram diagram,
boolean ignoreDirection)
Initializes a new instance of the PathFinder class,
optionally ignoring the link direction.
|
Modifier and Type | Method and Description |
---|---|
PathList |
findAllCycles()
Finds all cycles in the underlying diagram.
|
PathList |
findAllPaths(DiagramNode from,
DiagramNode to)
Finds and returns all paths that exist between two
DiagramNode objects. |
PathList |
findAllPaths(DiagramNode from,
DiagramNode to,
int maxPaths)
Finds and returns all paths that exist between two
DiagramNode objects. |
Path |
findCycle()
Detects whether there is a cycle in the diagram.
|
Path |
findCycle(DiagramNode participant)
Detects whether the specified
DiagramNode participates in a cycle. |
Path |
findLongestPath()
Finds the longest path in the graph.
|
Path |
findLongestPath(DiagramNode from,
DiagramNode to)
Finds the longest path between the specified
DiagramNode objects. |
Path |
findLongestPath(long timeLimit)
Finds the longest path in the diagram.
|
Path |
findShortestPath(DiagramNode from,
DiagramNode to)
Finds and returns the shortest
Path between the specified
DiagramNode objects. |
Path |
findShortestPath(DiagramNode from,
DiagramNode to,
boolean useNodeWeights,
boolean useLinkWeights)
Finds and returns the shortest path between two
DiagramNode elements,
considering the Weight of the nodes, the
Weight of the links or both. |
public PathFinder(Diagram diagram)
PathFinder
class.
Path-finding will depend on the direction of links.diagram
- An instance of the Diagram
class
in which to look for paths or cycles.public PathFinder(Diagram diagram, boolean ignoreDirection)
diagram
- A Diagram
instance in which to look
for paths or cycles.ignoreDirection
- Specifies whether the direction of links
should be considered when looking for paths or cycles.public PathList findAllPaths(DiagramNode from, DiagramNode to)
DiagramNode
objects.
The returned Path
instances include the from an to nodes.from
- The DiagramNode
where the path should start.to
- The DiagramNode
where the path should end.Path
objects; if no paths are found,
the collection is empty.public PathList findAllPaths(DiagramNode from, DiagramNode to, int maxPaths)
DiagramNode
objects.
The returned Path instances include the from an to nodes.from
- The DiagramNode
where the path should start.to
- The DiagramNode
where the path should end.maxPaths
- The maximum number of paths to find.Path
objects; if no paths are found,
the collection is empty.public Path findShortestPath(DiagramNode from, DiagramNode to)
Path
between the specified
DiagramNode
objects.from
- The DiagramNode
where the path should start.to
- The DiagramNode
where the path should end.Path
instance that represents the shortest path found;
null
, if there is no path connecting from and to.public Path findShortestPath(DiagramNode from, DiagramNode to, boolean useNodeWeights, boolean useLinkWeights)
DiagramNode
elements,
considering the Weight
of the nodes, the
Weight
of the links or both.from
- The DiagramNode
where the path should start.to
- The DiagramNode
where the path should end.useNodeWeights
- true
if the Weight
attribute of nodes should be considered, otherwise false
.useLinkWeights
- true
if the Weight
attribute of links should be considered, otherwise false
.Path
object representing the found path, or null
if there isn't any path connecting the specified nodes.public Path findLongestPath(DiagramNode from, DiagramNode to)
DiagramNode
objects.from
- The DiagramNode
where the path should start.to
- The DiagramNode
where the path should end.Path
object representing the found path, or
null
if there isn't any path connecting the specified nodes.public Path findLongestPath()
Path
object representing the found path, or
null
if there aren't any linked nodes in the graph.public Path findLongestPath(long timeLimit)
timeLimit
- Specifies the maximal amount of time
the algorithm is allowed to run.Path
object representing the found path, or
null
if there aren't any linked nodes in the graph.public Path findCycle(DiagramNode participant)
DiagramNode
participates in a cycle.participant
- A DiagramNode
that should be in the cycle.Path
object representing the cycle that contains
the specified node, or null
if the node is not in a cycle.public Path findCycle()
Path
object representing the first cycle found in
the graph, or null
if the graph does not contain any cycles.