Thursday, April 1, 2021

The Joy of Computing using Python Week 10 Programming Assignment 3 Solution

 

Week 10 Programming Assignment 3

Due on 2021-04-01, 23:59 IST
Consider a directed graph. It can be represented by an adjacency matrix. The nodes are numbered 1 to n. If there is an edge from node i to node j, there will be a 1 in the (i-1,j-1) position in the adjacency matrix. There are no self loops in the graph. print yes if the given graph is a complete graph (connection from one node to all other node) else print no
Your last recorded submission was on 2021-04-01, 08:14 IST
Select the Language for this assignment. 
1
N,n,f=int(input()),input().split(),0
2
ans=[n[i-N:i]for i in range(1,len(n)+1)if i%N==0 and n.count('0')!=N*N]
3
for a in range(N):
4
  for b in range(N):
5
    if len(ans)>1 and ans[a][b]==ans[b][a] :
6
      f=f+1
7
if f==N*N:
8
  print("yes",end="")
9
else:
10
  print("no",end="")

No comments:

Post a Comment