The graph looks messy and barely recognize anything. I only want it to show the name of nodes with high centrality, but I don't know how. I can only show all the names now.
Graph:the result of the following codes
G_D=nx.Graph() G_D.add_edges_from(G5.edges(data=True))
nx.draw(G_D,nx.spring_layout(G_D),node_size=[v * 10 for v in df.iloc[:,0]],with_labels= True)
nx.draw
has an argument labels, which in combination withwith_labels=True
can draw only labels you want, only how you want.For example, you can pick nodes
'label'
parameter and draw labels for nodes that have 3 or more neighbours:P.S. I don't recommend to use basic networkx drawing functional. There are many powerful visualization libraries better than networkx. Even in networkx docs you can find the same opinion. One can use Gephi, Graphviz (with various libraries) or Cytoscape for really HUGE graphs.