I am new to graph analysis and I need some hints on how to visualize my graph.
I have a pandas Dataframe that contains my edges with a distance.
Here is a sample of my Dataframe :
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
... ... ... ...
In my real dataset, I have around 400 nodes and 1000 edges.
Using library networkx
, I have been able to draw my graph :
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
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)
What would be a the good direction to represent my graph as I want ?
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.
-- EDIT --
Here is the output using method proposed by Paul Brodersen :
Partitioning was done using Spectral Clustering with 8 clusters based on distance of edges