title: NetworkX graph: creating nodes with ordered list
body: <p>I am completely new to graphs. I have a 213 X 213 distance matrix. I have been trying to visualize the distance matrix using network and my idea is that far apart nodes will appear as separate clusters when the graph will be plotted. So I am creating a graph with nodes representing column index. I need to keep track of nodes in order to label it afterwards. I need to add edges in certain order so I need to keep track of nodes and their labels.</p>
  <p>Here is the code:</p>
  <pre><code>import networkx as nx
  G = nx.Graph()
  G.add_nodes_from(time_pres) ##time_pres is the list of labels that I want specific node to have
  
   for i in range(212):
      for j in range(i+1, 212):
          color = ['green' if j == i+1 else 'red'][0]
          edges.append((i,j, dist[i,j], 'green')) ##This thing requires allocation of distance as per the order in dist matrirx
          G.add_edge(i,j, dist = dist[i,j], color = 'green')
  </code></pre>
  <p>The way I am doing right now, it is allocating nodes with id as a number which is not as per the index of labels in time_pres.</p>