Answer the question
In order to leave comments, you need to log in
[[+content_image]]
In what other cases is a graph called directed?
I'm solving a problem and I can't come up with tests for the problem.
The solution is:
N = int(input())
G = [[0]*N for _ in range(N)]
p = 0
for i in range(N):
G[i] = list(map(int, input().split()))
p += sum(G[i])
#if p == 0:print("NO"); exit(); # (Ничего не меняется, будь то YES или NO)
for i in range(N):
for j in range(N):
if (i == j and G[i][j] == 1):
print("NO");exit()
elif (G[i][j] != G[j][i]):
print("YES");exit()
print("NO")
Answer the question
In order to leave comments, you need to log in
.e. if a graph has at least one edge that has a direction, then it is a digraph.
for i in range(N):
for j in range(N):
if (i == j):
if (G[i][j] == 1):
print("NO");exit()
elif (G[i][j] != G[j][i]):
print("YES");exit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question