Can the Jung2 graph library traverse a digraph
Does anyone know if the Java Jung2 graph library provides the in-built capability to traverse a Digraph (directed graph) given a start Vector? I did see that there's a BFSDistanceLabeler
class that returns a map of di开发者_运维技巧stances, which could do, but I then need to sort the values (highest distance first) and iterate through the sorted set.
I'm creating a dependency management facility for Javascript using Maven and so I was thinking about using Jung2 to maintain my dependency graph.
I'm not sure what you mean by "traverse a digraph given a start vector". If you want to do a topological sort of a graph and then iterate through the vertices in that order, that's pretty easy:
(1) Calculate the breadth-first distances using BFSDistanceLabeler.
(2) Create a Comparator
for vertices that is aware of those distances (it will need to look up the distance for a vertex in the BFSDL data).
(3) Get the collection of vertices from the graph and sort it using that Comparator
.
精彩评论