MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / show_min

Method show_min

dynamic_programming/floyd_warshall.py:45–58  ·  view source on GitHub ↗

Returns the minimum distance from node u to node v. >>> g = Graph(3) >>> g.add_edge(0, 1, 3) >>> g.add_edge(1, 2, 4) >>> g.floyd_warshall() >>> g.show_min(0, 2) 7 >>> g.show_min(1, 0) inf

(self, u, v)

Source from the content-addressed store, hash-verified

43 self.dp[i][j] = min(self.dp[i][j], self.dp[i][k] + self.dp[k][j])
44
45 def show_min(self, u, v):
46 """
47 Returns the minimum distance from node u to node v.
48
49 >>> g = Graph(3)
50 >>> g.add_edge(0, 1, 3)
51 >>> g.add_edge(1, 2, 4)
52 >>> g.floyd_warshall()
53 >>> g.show_min(0, 2)
54 7
55 >>> g.show_min(1, 0)
56 inf
57 """
58 return self.dp[u][v]
59
60
61if __name__ == "__main__":

Callers 1

floyd_warshall.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected