Package org.apache.openjpa.lib.graph
Class DepthFirstAnalysis
- java.lang.Object
- 
- org.apache.openjpa.lib.graph.DepthFirstAnalysis
 
- 
 public class DepthFirstAnalysis extends java.lang.ObjectPerforms a depth-first analysis of a given Graph, caching information about the graph's nodes and edges. See the DFS algorithm in the book 'Introduction to Algorithms' by Cormen, Leiserson, and Rivest. The algorithm has been modified to group sibling nodes without connections together during the topological sort.- Since:
- 1.0.0
- Author:
- Abe White
 
- 
- 
Constructor SummaryConstructors Constructor Description DepthFirstAnalysis(Graph graph)Constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<Edge>getEdges(int type)Return all edges of the given type.intgetFinishedTime(java.lang.Object node)Return the logical time that the given node was finished in the graph walk, or -1 if the node is not part of the graph.java.util.List<java.lang.Object>getSortedNodes()Return the nodes in topologically-sorted order.booleanhasNoCycles()Test, if the analysis didn't find cycles.voidsetNodeComparator(java.util.Comparator<java.lang.Object> comp)Set the comparator that should be used for ordering groups of nodes with the same dependencies.
 
- 
- 
- 
Constructor Detail- 
DepthFirstAnalysispublic DepthFirstAnalysis(Graph graph) Constructor. Performs the analysis on the given graph and caches the resulting information.
 
- 
 - 
Method Detail- 
setNodeComparatorpublic void setNodeComparator(java.util.Comparator<java.lang.Object> comp) Set the comparator that should be used for ordering groups of nodes with the same dependencies.
 - 
getSortedNodespublic java.util.List<java.lang.Object> getSortedNodes() Return the nodes in topologically-sorted order. This is often used to order dependencies. If each graph edge (u, v) represents a dependency of v on u, then this method will return the nodes in the order that they should be evaluated to satisfy all dependencies. Of course, if the graph is cyclic (has back edges), then no such ordering is possible, though this method will still return the correct order as if edges creating the cycles did not exist.
 - 
getEdgespublic java.util.Collection<Edge> getEdges(int type) Return all edges of the given type. This method can be used to discover all edges that cause cycles in the graph by passing it theEdge.TYPE_BACKorEdge.TYPE_FORWARDedge type.
 - 
getFinishedTimepublic int getFinishedTime(java.lang.Object node) Return the logical time that the given node was finished in the graph walk, or -1 if the node is not part of the graph.
 - 
hasNoCyclespublic boolean hasNoCycles() Test, if the analysis didn't find cycles.
 
- 
 
-