I have M is numpy matrix with 0's& 1's. I want to color the nodes with
different colors.
can anyone give me a hint on the following code?
import network as nx
import pylab as plt
G=nx.Graph(M) # M is numpy matrix ,i.e:type(M)=numpy.ndarray
for i in xrange(len(M)):
tt=P[i,:].sum()
if tt==1:
G.add_node(i,color='blue')
elif tt==2:
G.add_node(i,color='red')
elif tt==3:
G.add_node(i,color='white')
else:
tt==4
G.add_node(i,color='green')
G.nodes(data=True)
T=nx.draw(G)
plt.axis('off')
plt.savefig("test.png")
I didn't get color change, still the defualt color is used.Did I miss
something?
my aim is to obtain:
something like:
find total number of w-red-red-z path
number of w-red-red-red-z path
number of w-red-red-red-red-z path
where w (left side of some cyclic polygon(can also be conjugated ring))
and z(right-side of it)are any of the colors except red.
any comment is appreciated?
Thanks
Bob
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion