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

Class Graph

Graphs/graph_matrix.py:4–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

graph_matrix.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected