I'm really new to python and igraph, so the question may be really easy.
I have a network with 128 nodes and an array of 128 numbers, each between 0 and 1. Numbers represent a feature of nodes.
I want two things:
- the color of nodes
iandjhas to be the same ifarray[i] == array[j] - the color of the edge between
iandjhas to be given according to this criterion:if array[i]<=array[j] -> color_edge[ij] = color_node[i] else color_edge[ij] = color_node[j]
I tried many thing, and I think the major problems are:
g.vs[i]["color"] = numberdoesn't work.I have to insert a string of the type "red" or "HTML notation for color". But how can I associate each number of my array to a string?g.es["color"]gives a color to all links. Howeverg.es[i]["color"]doesn't work (heregis my graph and ing.es[i][".."],iis the ID of the edge).
About the first question, the only solution I can propose is to assign MANUALLY a color to each node like
g.vs[0]["color"] = "red"
.
.
.
g.vs[127]["color"] = "blue"
then check the condition on array and eventually change the color of one of the two nodes (g.vs[i]["color"] = g.vs[j]["color"]). But it's a huge loss of time and is not a general way to do that (what if the network has 10^6 nodes?). I was suggested in this here
About the second question, I tried to adapt the code in here to my case but the best I obtained was two different colors (and morover I don't understand how they are "the choosen two")
How can I solve this?
P.s. I know I asked two questions, but I think they're very related. However, if necessary, I can edit this post and create a new one.
Thanks in advance.