title: python igraph: nodes and edges color according to a number associated to the node
body: <p>I'm really new to python and igraph, so the question may be really easy.</p>
  
  <p>I have a network with 128 nodes and an array of 128 numbers, each between 0 and 1. Numbers represent a feature of nodes.</p>
  
  <p>I want two things:</p>
  
  <ul>
  <li>the color of nodes <code>i</code> and <code>j</code> has to be the same if <code>array[i] == array[j]</code></li>
  <li>the color of the edge between <code>i</code> and <code>j</code> has to be given according to this criterion: <code>
  if array[i]&lt;=array[j] -&gt; color_edge[ij] = color_node[i]
  else color_edge[ij] = color_node[j]</code></li>
  </ul>
  
  <p>I tried many thing, and I think the major problems are:</p>
  
  <ul>
  <li><code>g.vs[i]["color"] = number</code> doesn'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?</li>
  <li><code>g.es["color"]</code> gives a color to all links. However <code>g.es[i]["color"]</code> doesn't work (here <code>g</code> is my graph and in <code>g.es[i][".."]</code>, <code>i</code> is the ID of the edge).</li>
  </ul>
  
  <p>About the first question, the only solution I can propose is to assign MANUALLY  a color to each node like </p>
  
  <p><code>g.vs[0]["color"] = "red"
  .
  .
  .
  g.vs[127]["color"] = "blue"</code></p>
  
  <p>then check the condition on <code>array</code> and eventually change the color of one of the two nodes (<code>g.vs[i]["color"] = g.vs[j]["color"]</code>). 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 <a href="https://lists.nongnu.org/archive/html/igraph-help/2011-04/msg00043.html" rel="nofollow noreferrer">here</a></p>
  
  <p>About the second question, I tried to adapt the code in <a href="https://stackoverflow.com/questions/10067721/can-i-change-the-colour-of-edges-containing-specific-vertices-in-igraph-python">here</a> to my case but the best I obtained was two different colors (and morover I don't understand how they are "the choosen two")</p>
  
  <p>How can I solve this?</p>
  
  <p>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.</p>
  
  <p>Thanks in advance.</p>