Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions