In all of these methods the graph is the delegate and 'it' in each closure is the vertex. This allows other methods in the graph to be used during traversal. For instance a user can get the inEdges or outEdges for the vertex in a DirecedGraph. This can be useful for finding vertices with certain input or output while traversing the graph.
Unlike breadth first search, depth first search has different orders: pre-order, in-order, post-order, and reverse post-order. This means there are 4 versions of each higher-order method (each, find, findAll, inject, collect).
The default methods for graph will use dfs preorder methods. This means each higher-order methd (find, findAll, inject, and collect) in graph will be aliases to the dfs preorder methods.
For every higher order method there will be the default which aliases to PreOrder and there will be methods for each ordering. For example each will have each, eachPreOrder, eachInOrder, eachPostOrder, and eachReversePostOrder. The pattern is each${order}(...).
each methods
Will include: each${order}(Closure) and each${order}(String,Closure)
starts at first vertex or vertex where name matches given string
in keeping with groovy's each there is no way of returning early. For that behavior use find methods instead.
find methods
Will include: find${order}(Closure) and find${order}(String,Closure)
Starts at first vertex or vertex where name matches given string
Should work like groovy's find and return the vertex if closure returns true otherwise returns null
findAll methods
Will include: findAll${order}(Closure) and findAll${order}(String,Closure)
starts at first vertex or vertex where name matches given string
returns list of all matching vertices
inject methods
Will include: inject${order}(Object,Closure) and inject${order}(String,Object,Closure)
starts at first vertex or vertex where name matches given string
Object is the first value passed into the first call to closure. The result of each call to closure are passed to the next call to closure.
the result of the final call to closure is returned from the method
collect methods
Will include: collect${order}(Closure) and collect${order}(String,Closure)
starts at first vertex or vertex where name matches given string
calls inject with a list and a closure that calls the given closure adding the result to the list
traverseEdges
The above methods need a method that tells them which edges to follow during a traversal. In the past this was called adjacentEdges but that name doesn't fit well. This method needs to be modified when DirectedGraphPlugin is applied to only return outEdges. This method will be used in breadth first search methods as well.
In all of these methods the graph is the delegate and 'it' in each closure is the vertex. This allows other methods in the graph to be used during traversal. For instance a user can get the inEdges or outEdges for the vertex in a DirecedGraph. This can be useful for finding vertices with certain input or output while traversing the graph.
Unlike breadth first search, depth first search has different orders: pre-order, in-order, post-order, and reverse post-order. This means there are 4 versions of each higher-order method (each, find, findAll, inject, collect).
The default methods for graph will use dfs preorder methods. This means each higher-order methd (find, findAll, inject, and collect) in graph will be aliases to the dfs preorder methods.
For every higher order method there will be the default which aliases to PreOrder and there will be methods for each ordering. For example each will have each, eachPreOrder, eachInOrder, eachPostOrder, and eachReversePostOrder. The pattern is each${order}(...).
each methods
find methods
findAll methods
inject methods
collect methods
traverseEdges
The above methods need a method that tells them which edges to follow during a traversal. In the past this was called adjacentEdges but that name doesn't fit well. This method needs to be modified when DirectedGraphPlugin is applied to only return outEdges. This method will be used in breadth first search methods as well.