MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / show_distances

Method show_distances

graphs/dijkstra_algorithm.py:380–392  ·  view source on GitHub ↗

Show the distances from src to all other nodes in a graph Examples: >>> graph_test = Graph(1) >>> graph_test.show_distances(0) Distance from node: 0 Node 0 has distance: 0

(self, src)

Source from the content-addressed store, hash-verified

378 self.show_distances(src)
379
380 def show_distances(self, src):
381 """
382 Show the distances from src to all other nodes in a graph
383
384 Examples:
385 >>> graph_test = Graph(1)
386 >>> graph_test.show_distances(0)
387 Distance from node: 0
388 Node 0 has distance: 0
389 """
390 print(f"Distance from node: {src}")
391 for u in range(self.num_nodes):
392 print(f"Node {u} has distance: {self.dist[u]}")
393
394 def show_path(self, src, dest):
395 """

Callers 1

dijkstraMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected