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

Method show_graph

graphs/dijkstra_algorithm.py:258–275  ·  view source on GitHub ↗

Show the graph: u -> v(w) Examples: >>> graph_test = Graph(1) >>> graph_test.add_edge(1, 2, 1) >>> graph_test.show_graph() 1 -> 2(1) 2 -> 1(1) >>> graph_test.add_edge(2, 3, 2) >>> graph_test.show_graph() 1 -> 2(1)

(self)

Source from the content-addressed store, hash-verified

256 self.adjList[v] = [(u, w)]
257
258 def show_graph(self):
259 """
260 Show the graph: u -> v(w)
261
262 Examples:
263 >>> graph_test = Graph(1)
264 >>> graph_test.add_edge(1, 2, 1)
265 >>> graph_test.show_graph()
266 1 -> 2(1)
267 2 -> 1(1)
268 >>> graph_test.add_edge(2, 3, 2)
269 >>> graph_test.show_graph()
270 1 -> 2(1)
271 2 -> 1(1) -> 3(2)
272 3 -> 2(2)
273 """
274 for u in self.adjList:
275 print(u, "->", " -> ".join(str(f"{v}({w})") for v, w in self.adjList[u]))
276
277 def dijkstra(self, src):
278 """

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected