We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e97565d commit 889f8fbCopy full SHA for 889f8fb
graphs/Directed (Weighted) Graph renamed to graphs/Directed and Undirected (Weighted) Graph
@@ -95,6 +95,16 @@ class DirectedGraph:
95
d.append(__[1])
96
visited.append(__[1])
97
return visited
98
+ def in_degree(self, u):
99
+ count = 0
100
+ for _ in self.graph:
101
+ for __ in self.graph[_]:
102
+ if __[1] == u:
103
+ count += 1
104
+ return count
105
+
106
+ def out_degree(self, u):
107
+ return len(self.graph[u])
108
109
110
class Graph:
@@ -202,3 +212,5 @@ class Graph:
202
212
203
213
204
214
215
+ def degree(self, u):
216
0 commit comments