Il giorno gio, 20/03/2014 alle 12.52 +0100, Tiago de Paula Peixoto ha
scritto:

> [...] I have now just added a Graph.add_edge_list() to the
> git version, which takes a list of edges to be added, which can be a
> numpy array. If you have a full adjacency matrix instead of an edge
> list, you can do simply:
> 
>     g.add_edge_list(transpose(nonzero(a)))
> 
> This should be much faster than the Python loop above.
> 


I think there is some problem with add_edge_list.

The following code:

---------------------------------------------------------

from scipy import array
from graph_tool import Graph
from graph_tool.draw import graph_draw

def blocks_star(transpose=False):
    g = Graph()
    members = array([0,1,2])
    edges_list = array([[0,1,2], [2,0,1]]).transpose()
    edges_list_2 = array([[0,2],[1,0],[2,1]])
    print edges_list
    print edges_list_2
    print all(edges_list == edges_list_2)
    if transpose:
        g.add_edge_list(edges_list)
    else:
        g.add_edge_list(edges_list_2)
    graph_draw(g)

---------------------------------------------------------

gives me a different result if called with True or False as argument
(with True, the resulting graph is disconnected), while the edges lists
are clearly identical. I guess this has to do with the fact that
transposing, for numpy, is just a change of view, not a relocation of
elements... but I see your code is based on boost, which I have no
experience with. I am using package python-graph-tool 2.2.31-1 from your
Debian sid repositories.

By the way: why "add_edge_list" rather than "add_edges_list"? True,
"add_vertex" can add multiple vertices, but then there is "clear_edges".
Not really crucial issue, but... later it would be too late to raise it!

Cheers,

Pietro

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to