MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / Graph

Class Graph

Graphs/graph_list.py:4–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3
4class Graph:
5 def __init__(self, vertex):
6 self.vertex = vertex
7 self.graph = [[0] for i in range(vertex)]
8
9 def add_edge(self, u, v):
10 self.graph[u - 1].append(v - 1)
11
12 def show(self):
13 for i in range(self.vertex):
14 print('%d: '% (i + 1), end=' ')
15 for j in self.graph[i]:
16 print('%d-> '% (j + 1), end=' ')
17 print(' ')
18
19
20

Callers 1

graph_list.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected