Adjacency matrix

dear all,

I noticed that the adjacency matrix is used in several centrality measures implemented in graph-tool.
Is there some way to access this adjacency matrix directly or do I have to write a loop over the edges to
fill an 0 initialized matrix with 1s?

thanks in advance

Yannis

As is stated in the documentation, the internal representation used in
graph-tool is an adjacency list, not an adjacency matrix. An adjacency
matrix would require O(N^2) space, and hence it would be very wasteful
(and slow) for large sparse graphs. The adjacency matrix is referenced
in the centrality documentation purely for convenience of notation.

You can get a copy of the graph as a sparse adjacency matrix via the
function:

    https://graph-tool.skewed.de/static/doc/spectral.html#graph_tool.spectral.adjacency

Best,
Tiago

Thanks for the answer.

I tried to include the code of the adjacency method into my program but it doens’t find libgraph_tool_spectral

I don’t understand the __future__, .., etc. imports, how can I simply add libgraph_tool_spectral to my code so that I can calculate the adjacency matrix?

Thanks in advance

I don't get what you are trying to accomplish.

If you call the function adjacency(g), it will return you the adjacency
matrix of graph g. Isn't that what you want? Why do you want to copy and
past the function's implementation?

Best,
Tiago

OK, sorry. I didn’t understood that the adjacency function was already available.
It would be nice to include it in the documentation!

???

But I just **sent you** the link to the documentation!

Sorry, it is hard to concentrate…