Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

color in graph

The following code works even if the thickness is not taken in account

cand=['A','B','C','D']
M=zero_matrix(4,4)
M[1,0]=12;M[0,1]=18;M[2,0]=10;M[0,2]=20;M[3,0]=5;M[0,3]=25;M[1,2]=16;M[2,1]=14;M[3,1]=10;M[1,3]=20;M[3,2]=19;M[2,3]=11;
show(M)
N=[[-1 if M[i,j]< M[j,i] else 1 for i in range(M.nrows())]for j in range(M.nrows())] 
#show(N)
NN=[[N[i][j] if i!=j else 0 for i in range(M.nrows())]for j in range(M.nrows())]
#show(NN)
NN=[[N[i][j] if i!=j else 0 for i in range(M.nrows())]for j in range(M.nrows())]
#show(ZZ)
ZZZ={i:ZZ[i] for i in range(len(cand)) if len(ZZ[i])!=0}
#show(ZZZ)
D = DiGraph(ZZZ)
candg={i:cand[i] for i in range(len(cand))}
#show(candg)
D.relabel(candg)
cvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])==len(cand)-1]
ccvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])!=len(cand)-1]
#show(ccvc)
dd={'#0000FF':d,'#FF9900':ccvc}
show(dd)
D.graphplot(layout='circular',edge_thickness=20)

but if I want to change the vertice colors it fails

D.graphplot(layout='circular',edge_thickness=20,vertex_colors=dd).show()

Is it the definition of dd which seems to my view correct? And I have the same problem in coloring the edges. Also, I have seen two way to plot .show() and .plot(). What is the difference ?

color in graph

The following code works even if the thickness is not taken in account

 cand=['A','B','C','D']
M=zero_matrix(4,4)
M[1,0]=12;M[0,1]=18;M[2,0]=10;M[0,2]=20;M[3,0]=5;M[0,3]=25;M[1,2]=16;M[2,1]=14;M[3,1]=10;M[1,3]=20;M[3,2]=19;M[2,3]=11;
show(M)
N=[[-1 if M[i,j]< M[j,i] else 1 for i in range(M.nrows())]for j in range(M.nrows())] 
#show(N)
show(N)
NN=[[N[i][j] if i!=j else 0 for i in range(M.nrows())]for j in range(M.nrows())]
#show(NN)
NN=[[N[i][j] if i!=j else 0 show(NN)
ZZ=[[i for i in range(M.nrows())]for range(M.nrows()) if NN[j][i]==1] for j in range(M.nrows())]
#show(ZZ)
range(M.nrows()) ]
show(ZZ)
ZZZ={i:ZZ[i] for i in range(len(cand)) if len(ZZ[i])!=0}
#show(ZZZ)
show(ZZZ)
D = DiGraph(ZZZ)
candg={i:cand[i] for i in range(len(cand))}
#show(candg)
show(candg)
D.relabel(candg)
cvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])==len(cand)-1]
show(cvc)
ccvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])!=len(cand)-1]
#show(ccvc)
dd={'#0000FF':d,'#FF9900':ccvc}
dd={'#0000FF':cvc,'#FF9900':ccvc}
show(dd)
D.graphplot(layout='circular',edge_thickness=20)
D.graphplot(layout='circular',edge_thickness=20).plot()

but if I want to change the vertice colors it fails

D.graphplot(layout='circular',edge_thickness=20,vertex_colors=dd).show()

Is it the definition of dd which seems to my view correct? And I have the same problem in coloring the edges. Also, I have seen two way to plot .show() and .plot(). What is the difference ?

color in graph

The following code works even if the thickness is not taken in account

    cand=['A','B','C','D']
M=zero_matrix(4,4)
M[1,0]=12;M[0,1]=18;M[2,0]=10;M[0,2]=20;M[3,0]=5;M[0,3]=25;M[1,2]=16;M[2,1]=14;M[3,1]=10;M[1,3]=20;M[3,2]=19;M[2,3]=11;
show(M)
N=[[-1 if M[i,j]< M[j,i] else 1 for i in range(M.nrows())]for j in range(M.nrows())] 
show(N)
NN=[[N[i][j] if i!=j else 0 for i in range(M.nrows())]for j in range(M.nrows())]
show(NN)
ZZ=[[i for i in range(M.nrows()) if NN[j][i]==1] for j in range(M.nrows()) ]
show(ZZ)
ZZZ={i:ZZ[i] for i in range(len(cand)) if len(ZZ[i])!=0}
show(ZZZ)
D = DiGraph(ZZZ)
candg={i:cand[i] for i in range(len(cand))}
show(candg)
D.relabel(candg)
cvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])==len(cand)-1]
show(cvc)
ccvc = [ZZ.index(ZZ[i]) for i in range(len(cand))if len(ZZ[i])!=len(cand)-1]
#show(ccvc)
dd={'#0000FF':cvc,'#FF9900':ccvc}
show(dd)
D.graphplot(layout='circular',edge_thickness=20).plot()

but if I want to change the vertice colors it fails

D.graphplot(layout='circular',edge_thickness=20,vertex_colors=dd).show()

Is it the definition of dd which seems to my view correct? And I have the same problem in coloring the edges. Also, I have seen two way to plot .show() and .plot(). What is the difference ?

NB : I think that in the option vertex_colors=dd is not expanded to it's value since the error is

---> 24 D.graphplot(layout='circular',edge_thickness=Integer(20),vertex_colors=dd).show()