moaxcp / graph-dsl

A groovy dsl for creating and traversing graphs.
https://moaxcp.github.io/graph-dsl/
MIT License
27 stars 6 forks source link

Breadth First Search methods #57

Closed moaxcp closed 7 years ago

moaxcp commented 7 years ago

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.

eachBfs methods

findBfs methods

findAllBfs methods

injectBfs methods

collectBfs 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 depth first search methods as well.

moaxcp commented 7 years ago

Also add collectEntries which will use a map instead of a list