title: Nodes clusters on weighted graph visualization
body: <p>I am new to graph analysis and I need some hints on how to visualize my graph.</p>
  
  <p>I have a pandas Dataframe that contains my edges with a distance.</p>
  
  <p>Here is a sample of my Dataframe : </p>
  
  <pre><code>    node_1, node_2, distance
  1    nodeA,  nodeB,     12.5 
  2    nodeA,  nodeA,        1 
  3    nodeB,  nodeA,     10.6 
  4    nodeC,  nodeD,       20 
  5    nodeD,  nodeE,       25 
  ...    ...     ...       ...
  </code></pre>
  
  <p>In my real dataset, I have around 400 nodes and 1000 edges.</p>
  
  <p>Using library <code>networkx</code>, I have been able to draw my graph : </p>
  
  <pre><code>G = nx.from_pandas_edgelist(df = edges, source = 'node_1', target = 'node_2', edge_attr='distance')
  G.add_nodes_from(nodes_for_adding = edges['node_1'].tolist())
  
  edge_all = [(u,v) for (u,v,d) in G.edges(data=True)]
  
  pos=nx.spring_layout(G)
  plt.figure(figsize=(40,30))
  nx.draw_networkx_nodes(G,pos,node_size=10)                 # draw nodes
  nx.draw_networkx_edges(G,pos,edgelist=edge_all,width=0.08) # draw edges
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sZOtb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sZOtb.png" alt="enter image description here"></a></p>
  
  <p>Luckily, I know what my graph should look like. It should be a bunch of cluster of nodes linked together by some independant nodes. (A cluster being defined by lot of connection with low distance)</p>
  
  <p>What would be a the good direction to represent my graph as I want ? </p>
  
  <p>The goal of this visualization would be to then map some routes on it to see how it goes from some clusters to some other.</p>
  
  <p>-- EDIT --</p>
  
  <p>Here is the output using method proposed by Paul Brodersen : </p>
  
  <p>Partitioning was done using Spectral Clustering with 8 clusters based on distance of edges</p>
  
  <p><a href="https://i.stack.imgur.com/yUOkK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yUOkK.jpg" alt="enter image description here"></a></p>