Search code examples
pythonmemorynetworkx

How to estimate NetworkX graph memory usage?


How to check the amount of memory used by a NetworkX graph?

There is a method for checking the number of nodes and edges, but I could not find one for memory usage?


Solution

  • You can get an estimate by adding up the size of the edge list and the size of the node list:

     sys.getsizeof(G.edge) + sys.getsizeof(G.node)