public final class BellmanFord extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BellmanFord.Mode
For setting whether the Bellman-Ford algorithm should look for the
shortest paths from a source or to a destination.
|
| Modifier and Type | Method and Description |
|---|---|
static Map<?,Weight> |
calcShortestDistances(Object sourceOrDest,
DirectedGraph g,
BellmanFord.Mode mode)
Calculates the distance of every object in a graph from a source object.
|
static boolean |
hasNegativeCycle(Object sourceOrDest,
DirectedGraph g,
BellmanFord.Mode mode)
Determines if there are any negative cycles found.
|
public static Map<?,Weight> calcShortestDistances(Object sourceOrDest, DirectedGraph g, BellmanFord.Mode mode)
hasNegativeCycles(), and if no negative cycles
are found, returns the shortest distances.sourceOrDest - a vertex.Map of objects and their distances
from the source object, or null if a negative
cycle was encountered.public static boolean hasNegativeCycle(Object sourceOrDest, DirectedGraph g, BellmanFord.Mode mode)
sourceOrDest - a vertex.true if a negative cycle was found,
false otherwise.Copyright © 2012–2018 Emory University. All rights reserved.