Advice on the use of C(X)Sparse
szhorvat opened this issue · 2 comments
igraph uses CXSparse as the back-end for its sparse matrices. igraph's sparse matrix support was implemented a long time ago, and I am currently looking into cleaning it up and rationalizing its API. This brought up a question:
What purpose does the triplet format have other than making it easy to add more entries?
igraph's current interface exposes the triplet/compressed duality (i.e. each sparse matrix is either in triplet or compressed form), and tries to support as many operations as possible even on the triplet format.
This conflicts with my personal understanding. My impression was that the triplet format is really just a means of construction, but the majority of mathematically useful operations applies only to the compressed format. Thus exposing the triplet format to users doesn't make much sense. It should suffice to provide a way to create a compressed format matrix from an explicit list of index pairs and associated values.
Your advice on this topic would be appreciated. In the meantime I'm looking at the book, as well as the CXSparse's MATLAB interface.
What purpose does the triplet format have other than making it easy to add more entries?
The only purpose for the triplet format is to provide a simpler way of constructing the compress-sparse-column format. The only methods I have that can use the triplet format are cs_entry (adds one entry to a triplet form, using a dynamic table approach) and cs_compress (constructs a compressed-sparse-column matrix from the triplet form).
That's the only purpose of the triplet format.
I would say that there's no reason for igraph to try to do operations on the triplet form.
Thanks for confirming my understanding!