Question

I am trying to use JgraphT to create a network graph for a redundant topology, and I'm interested in getting the closest node to another node, but the topology doesn't allow above a certain amount of hops to avoid loops. I was wondering if there is a way to quickly get vertices similarly to the way closestFirstIterator returns them, but with a cap on the amount of hops there can be for each path. I've noticed the closestFirstIterator constructor with the radius cap (which caps the accumulated weight from each hop), but that is not what I'm looking for.

Était-ce utile?

La solution

You probably need the KShortestPaths class, which includes a nMaxHops option

EDIT: I do have to note that I noticed considerably better performance with BellmanFordShortestPath if you're interested in the best path for each vertice, but you'll have to provide the vertices yourself and use something like GraphPathImpl to convert the set of edges into a GraphPath

Autres conseils

You could use DijkstraShortestPath<V,E> and filter out the long paths you don't want, with a performance loss of course, but an alternative.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top