File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import print_function
2
2
3
3
try :
4
- raw_input # Python 2
4
+ raw_input # Python 2
5
5
except NameError :
6
6
raw_input = input # Python 3
7
7
8
8
try :
9
- xrange # Python 2
9
+ xrange # Python 2
10
10
except NameError :
11
- xrange = range # Python 3
11
+ xrange = range # Python 3
12
12
13
13
# Accept No. of Nodes and edges
14
14
n , m = map (int , raw_input ().split (" " ))
@@ -141,7 +141,7 @@ def dijk(G, s):
141
141
142
142
def topo (G , ind = None , Q = [1 ]):
143
143
if ind is None :
144
- ind = [0 ] * (len (G ) + 1 ) # SInce oth Index is ignored
144
+ ind = [0 ] * (len (G ) + 1 ) # SInce oth Index is ignored
145
145
for u in G :
146
146
for v in G [u ]:
147
147
ind [v ] += 1
@@ -279,3 +279,12 @@ def krusk(E_and_n):
279
279
s [j ].update (s [i ])
280
280
s .pop (i )
281
281
break
282
+
283
+
284
+ # find the isolated node in the graph
285
+ def find_isolated_nodes (graph ):
286
+ isolated = []
287
+ for node in graph :
288
+ if not graph [node ]:
289
+ isolated .append (node )
290
+ return isolated
You can’t perform that action at this time.
0 commit comments