igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] How to read in a large graph (and output a sparse matrix)


From: Tamas Nepusz
Subject: Re: [igraph] How to read in a large graph (and output a sparse matrix)
Date: Fri, 5 Aug 2016 15:20:35 +0200

> Unfortunately coo_matrix appears to be a very space inefficient
> format.  It seems to take about three times the RAM of the original
> graph.
coo_matrix() stores the matrix in three arrays: data, row_ind and
col_ind. The number of elements in each array is the number of nonzero
elements in the matrix such that data[i] is placed in the matrix at
(row[i], col[i]). So, in theory, the memory required should be
proportional to the number of nonzero elements.

You could try csc_matrix() or csr_matrix() instead; these use
alternative representations that should take up less space. However,
the key problem here is that there is a point in time when your graph
is effectively stored three times in memory:

- first you load it with igraph into a Graph object
- next, the graph object is converted into the data, rows and cols
arrays. (At this point, you could probably delete the igraph graph
from memory).
- finally, the arrays are turned into a SciPy matrix.

In theory, setting "graph" to None after the data, cols and rows
arrays were constructed and calling Python's garbage collector should
release the memory occupied by the graph, although it is probably
never returned to the OS -- Python will keep it to itself in case it
is neeed later for something else.

T.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]