Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e9903bf

Browse files
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

Lines changed: 9 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /