I have a weighted networkx graph. I've computed the eigenvector centrality values on the graph; however, I wanted to also add circles ontop of each node that visually represent the eigenvector value of the particular node. The circles would differ in size depending on the eigenvector value of the respective node. (the greater the value, the bigger the circle ontop of the node).
I'm using the following code:
import networkx as nx
# Create a random graph
G = nx.gnp_random_graph(20, 0.2)
# Calculate centrality
centrality = nx.eigenvector_centrality_numpy(G)
# Create labels dict with fixed digit format
labels = {
node: '{:.3f}'.format(centrality[node])
for node in centrality
}
# Draw the graph with labels
nx.draw(
G,
with_labels=True,
labels=labels,
node_color='#FF0000'
)
