Giraffe.Algorithms.BellmanFord (giraffe v0.1.4)
Implementation of the Bellman-Ford algorithm for finding shortest paths in graphs.
Summary
Functions
Finds the shortest paths from a source vertex to all other vertices in the graph.
Types
Functions
@spec shortest_paths(graph(), vertex()) :: {:ok, %{required(vertex()) => number()}} | {:error, :negative_cycle}
Finds the shortest paths from a source vertex to all other vertices in the graph.
Returns a map of vertices to their shortest distance from the source.
If a negative cycle is detected, returns {:error, :negative_cycle}
.