title: Avoid overlapping of nodes and edges in Networkx
body: <p>I have a data frame called final_net that resembles the source and the destination of tweets:</p>
  
  <pre><code>From     Destination    Count
  A        B              31
  A        C              25
  B        C              24
  ...
  </code></pre>
  
  <p>What I am trying to do is to create a network diagram using Networkx. In order to do that, I have written the following code:</p>
  
  <pre><code># libraries
  import pandas as pd
  import numpy as np
  import networkx as nx
  import matplotlib.pyplot as plt
  
  plt.figure(figsize=(20,10))
  # Build your graph
  G=nx.from_pandas_edgelist(final_net.head(25), 'from', 'to', create_using=nx.DiGraph() )
  
  # Custom the nodes:
  nx.draw(G, with_labels=True, 
          node_color='skyblue', node_size=2200, 
          edge_color=final_net.head(25)['count'], width=3, edge_cmap=plt.cm.OrRd,
          arrowstyle='-&gt;',arrowsize=20,
          font_size=10, font_weight="bold",
          pos=nx.random_layout(G, seed=13))
  </code></pre>
  
  <p>I am taking only the most frequent 25 links and creating a network diagram. But I want to tidy the diagram a little bit more in such a way that:</p>
  
  <ul>
  <li>no nodes overlap</li>
  <li>no edges overlap</li>
  <li>nodes are close to each other to avoid extra-long edges</li>
  </ul>
  
  <p>My outcome is: <a href="https://i.stack.imgur.com/3PY7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3PY7H.png" alt="enter image description here"></a></p>