Weak Vertices
This commit is contained in:
31
weakvertices.py
Normal file
31
weakvertices.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
graph_size = int(input())
|
||||||
|
|
||||||
|
while graph_size > 0:
|
||||||
|
adjecencies = []
|
||||||
|
|
||||||
|
for i in range(graph_size):
|
||||||
|
adjecencies.append(
|
||||||
|
[i for i, v in enumerate(list(map(int, input().split()))) if v == 1]
|
||||||
|
)
|
||||||
|
|
||||||
|
weak_nodes = []
|
||||||
|
|
||||||
|
for i, nodes in enumerate(adjecencies):
|
||||||
|
weak = True
|
||||||
|
|
||||||
|
for node in nodes:
|
||||||
|
|
||||||
|
for next_node in adjecencies[node]:
|
||||||
|
if i in adjecencies[next_node]:
|
||||||
|
weak = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if not weak:
|
||||||
|
break
|
||||||
|
|
||||||
|
if weak:
|
||||||
|
weak_nodes.append(i)
|
||||||
|
|
||||||
|
print(" ".join(map(str, weak_nodes)))
|
||||||
|
|
||||||
|
graph_size = int(input())
|
||||||
Reference in New Issue
Block a user