Question: #Creating Incidence matrix mat = [ ] r 1 = [ 1 , 1 , 1 , 0 , 0 ] r 2 = [

#Creating Incidence matrix mat=[]r1=[1,1,1,0,0]r2=[0,0,1,1,0]r3=[0,0,0,1,1]r4=[1,1,0,0,1]mat.append(r1)mat.append(r2)mat.append(r3)mat.append(r4)print("Incidence Matrix")for i in mat: print(i)#Functiondef fun(m): #list to hold current edge temp =[] #list to hold all edges edges =[] #looping through the matrix column for i in range(len(m[0])): #current edge is empty now temp =[] #looping through the matrix row for j in range(len(m)): #In each column we have 21s and initial 1 is #starting node and last node is ending node if m[j][i]==1: #incrementing by 1 because index start from 0 temp.append(j+1) #adding current edge to edges edges.append(temp) #returning list of edges return edgese = fun(mat)print("
Edge Node listing representation")for i in e: print(i)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!