Print the graph vertices. Example: >>> g = Graph() >>> g.add_edge(0, 1) >>> g.add_edge(0, 2) >>> g.add_edge(1, 2) >>> g.add_edge(2, 0) >>> g.add_edge(2, 3) >>> g.add_edge(3, 3) >>> g.print_graph() {0: [1, 2], 1
(self)
| 9 | |
| 10 | # for printing the Graph vertices |
| 11 | def print_graph(self) -> None: |
| 12 | """ |
| 13 | Print the graph vertices. |
| 14 | |
| 15 | Example: |
| 16 | >>> g = Graph() |
| 17 | >>> g.add_edge(0, 1) |
| 18 | >>> g.add_edge(0, 2) |
| 19 | >>> g.add_edge(1, 2) |
| 20 | >>> g.add_edge(2, 0) |
| 21 | >>> g.add_edge(2, 3) |
| 22 | >>> g.add_edge(3, 3) |
| 23 | >>> g.print_graph() |
| 24 | {0: [1, 2], 1: [2], 2: [0, 3], 3: [3]} |
| 25 | 0 -> 1 -> 2 |
| 26 | 1 -> 2 |
| 27 | 2 -> 0 -> 3 |
| 28 | 3 -> 3 |
| 29 | """ |
| 30 | print(self.vertex) |
| 31 | for i in self.vertex: |
| 32 | print(i, " -> ", " -> ".join([str(j) for j in self.vertex[i]])) |
| 33 | |
| 34 | # for adding the edge between two vertices |
| 35 | def add_edge(self, from_vertex: int, to_vertex: int) -> None: |
no outgoing calls
no test coverage detected