[graph-tool] Building graph from adjacency matrix

Guillaume Gay guillaume at mitotic-machine.org
Thu Mar 20 18:29:28 CET 2014


That's all ready simpler than that, as you can assign values of the 
propertymap like that:

pm.a = a


Le 20/03/2014 18:25, Pietro Battiston a écrit :
> 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.
>>
> Do you think it would make sense then to have something analogous for
> PropertyMaps?
>
> Like:
>
> pm.set_from_list(a)
>
> in place of:
>
> for v in g.vertices():
>      pm[v] = a[i]
>
> if pm is a property for vertices, and
>
> for e in g.edges():
>      pm[e] = a[i]
>
> if it is for edges?
>
> Pietro
>
>
>
> _______________________________________________
> graph-tool mailing list
> graph-tool at skewed.de
> http://lists.skewed.de/mailman/listinfo/graph-tool




More information about the graph-tool mailing list