Skip to content

Commit e9903bf

Browse files
committed
Three Hundred - Thirty-One Commit: Implement edge_count() function
1 parent 674119b commit e9903bf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Section_12(Graphs)/(1)_graph.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ def exist_edge(self, u, v):
6161
return self._adjacent_matrix[u][v] != 0
6262

6363
def vertex_count(self):
64-
return self._vertices
64+
return self._vertices
65+
66+
def edge_count(self):
67+
count = 0
68+
for i in range(self._vertices):
69+
for j in range(self._vertices):
70+
if self._adjacent_matrix[i][j] != 0:
71+
count = count + 1
72+
return count

0 commit comments

Comments
 (0)