public class DepthFirstSearch
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private GraphAnalysis |
graphAnalysis
Properties of graph.
|
Constructor and Description |
---|
DepthFirstSearch()
Initialize depth first search object.
|
Modifier and Type | Method and Description |
---|---|
private java.util.List<Actor> |
clonePath(java.util.List<Actor> path)
Clone a path
|
void |
dfsVisit(Actor actr,
Actor dstActor,
java.util.List<Actor> currentPath,
java.util.List<java.util.List<Actor>> paths)
DFS visit a node.
|
java.util.Stack<Actor> |
dfsVisitOrder(Graph g,
boolean transpose)
Given a graph, returns a queue containing the nodes of that graph in
the order in which a DFS of that graph finishes expanding the nodes.
|
private java.util.HashSet<Actor> |
getAdjacentActors(Actor actr,
boolean transpose)
The function returns a list with actors directly reachable from
actor a (in case transpose if false).
|
java.util.List<java.util.List<Actor>> |
getDfsPaths(Actor srcActr,
Actor dstActr)
Get depth first search path.
|
private void |
recExplore(Actor node,
Graph g,
java.util.Stack<Actor> result,
java.util.Set<Actor> visited,
boolean transpose)
Recursively explores the given node with a DFS, adding it to the output
list once the exploration is complete.
|
private GraphAnalysis graphAnalysis
private java.util.List<Actor> clonePath(java.util.List<Actor> path)
path
- input pathpublic void dfsVisit(Actor actr, Actor dstActor, java.util.List<Actor> currentPath, java.util.List<java.util.List<Actor>> paths)
actr
- current actordstActor
- last actor to be visitedcurrentPath
- current path which is being traversedpaths
- list of pathspublic java.util.List<java.util.List<Actor>> getDfsPaths(Actor srcActr, Actor dstActr)
srcActr
- starting actor of the pathdstActr
- ending actor of the pathprivate java.util.HashSet<Actor> getAdjacentActors(Actor actr, boolean transpose)
actr
- actor of which adjacent actors are to be calculatedtranspose
- direction to searchpublic java.util.Stack<Actor> dfsVisitOrder(Graph g, boolean transpose)
g
- The graph to explore.transpose
- direction to searchprivate void recExplore(Actor node, Graph g, java.util.Stack<Actor> result, java.util.Set<Actor> visited, boolean transpose)
node
- The node to start from.g
- The graph to explore.result
- The final listing of the node ordering.visited
- The set of nodes that have been visited so far.transpose
- direction is reversed if transpose is set