From 18a9c3eabc166c3490d65fa80bc7dc0b343f313b Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 2 Jul 2020 08:58:43 +0930 Subject: [PATCH] graph/path: fix comments in BellmanFordFrom --- graph/path/bellman_ford_moore.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/graph/path/bellman_ford_moore.go b/graph/path/bellman_ford_moore.go index 7199dc90f..d7abfb534 100644 --- a/graph/path/bellman_ford_moore.go +++ b/graph/path/bellman_ford_moore.go @@ -31,11 +31,13 @@ func BellmanFordFrom(u graph.Node, g graph.Graph) (path Shortest, ok bool) { path.dist[path.indexOf[u.ID()]] = 0 // Queue to keep track which nodes need to be relaxed. - // Only nodes whose vertex distance changed in the previous iterations need to be relaxed again. + // Only nodes whose vertex distance changed in the previous iterations + // need to be relaxed again. queue := newBellmanFordQueue(path.indexOf) queue.enqueue(u) - // The maximum of edges in a graph is |V| * (|V|-1) which is also the worst case complexity. + // The maximum number of edges in a graph is |V| * (|V|-1) which is also + // the worst case complexity. // If the queue-loop has more iterations than the amount of maximum edges // it indicates that we have a negative cycle. maxEdges := len(nodes) * (len(nodes) - 1)