#To Determine whether the given the given graph is a tree or not
#Which means are the rows of incidence matrix independent
A = matrix([[-1,1,0,0],[-1,0,1,0],[0,1,0,-1],[0,0,-1,1]])
print 'The incidence matrix is '
print A
print 'The determinant of the matrix is'
print det(A)
if det(A)==0:
    print 'Since incidence matrix is singular, it is not a tree'
else:
    print 'Since incidence matrix is non-singular, it is a tree'

Strang-2.5-5-U (last edited 2010-12-18 11:16:18 by ArnabBasu)