Search code examples
pythonnetworkx

Python networkx, how to change node size?


I have a simple configuration model, and I would like to change the size of nodes in the graph.

My code is:

import networkx as nx
import matplotlib.pyplot as plt
hosts = 100
H=nx.configuration_model([2]*hosts)
nx.draw_random(H)

enter image description here

I tried including node_size but this is undefined and I receive the error:

TypeError: configuration_model() got an unexpected keyword argument 'node_size'

How do I change the size of my nodes?

Many thanks.


Solution

  • Use node_size parameter in draw_random

    nx.draw_random(H, node_size=100)
    

    enter image description here