Memory allocation binary vs. weighted graphs

I am using python-igraph and I need to know the memory footprint of a graph depending on whether it is weighted or not, any tip?
thanks!

“Weights” are just another edge attribute. Adding any numerical edge attribute consumes memory that takes linear space in the number of edges.

The memory used by the C representation of a graph takes (4m+2n)s bytes where m is the vertex count, n is the edge count, and s is the size of an integer on your platform. Usually s=8 on 64-bit platforms and s=4 on 32-bit ones. There is some additional fixed-space bookkeeping data, plus the attribute storage.

Thanks! Does it mean that for a weighted graph (4m+2n)s + nt, where t is the size of an attribute? How can we know this size? in my case, weights are positive floating numbers loaded from a ncol file.

In C, t would be 8. Note that’s 8 times the edge count, not vertex count, assuming you are talking about edge weights.

In Python, I’m not sure. The person who could answer this definitively is away for a while. I believe in Python the attributes are stored as a plain Python list. So, the answer would be however much the list of weights takes up in Python.