On Thu, Nov 5, 2009 at 11:59 AM, Tiago de Paula Peixoto <tiago@forked.de> wrote:
Hello Claudio,
Claudio Martella wrote:
Hello list,
I'm going on with my algorithms and i'm stuck on a thing: I cannot find the interface on graph_tool to access the adjacency matrix of the graph.
The rationale behind my request is that i have a graph and i have a matrix based algorithm to calculate new edges and new weights. So I'd like to:
(1) create a graph through the usual API (2) get its adjacency matrix (3) modify it with my matrix operations based algorithm (4) feed it back to the graph / create a new graph from the matrix
What is your suggestion to do this in graph_tool?
Step 2 can be done with the adjacency() function of the spectral module:
http://projects.forked.de/graph-tool/doc/spectral.html#graph_tool.spectral.a...
Step 4 needs to be done by hand, but it should be something as simple as:
for i in xrange(N): for j in xrange(N): if a[i,j] != 0: g.add_edge(g.vertex(i), g.vertex(j))
Thanks, that is a solution i considered but it feels very expensive. This means a continuous switch from python to C++, doesn't it? Wouldn't it be way faster if i created such a function somewhere in C++, passing the matrix?
Cheers, Tiago
_______________________________________________ graph-tool mailing list graph-tool@forked.de http://lists.forked.de/mailman/listinfo/graph-tool
-- Claudio Martella claudio.martella@gmail.com