With either vertices or edges, if you're going to call the iterator multiple times, I feel like it might be faster to use it once to build a list or array, and then work with indices to that.  With edges, I'd build one list of edge objects and another of tuples of source index, target index, index to the edge list, and whatever properties I need.  Graph tool is fast when it uses the c++ functions, but it's just python otherwise, and needs to be treated like python.

Be aware that numpy arrays can be super slow if misused. Masking is just a convenience,  not the fastest way for all situations.  Also,  arrays are immutable and "changing" them is very slow compared to lists.

I'm new to graphtool though, so I take my advice with a grain of salt.

On Aug 4, 2014 7:35 PM, "..." <offonoffoffonoff@gmail.com> wrote:

Why do you not want to use graph.vertices?

Elliot

On Aug 4, 2014 5:57 PM, "Helen Lampesis" <eukolomnimonitos@gmail.com> wrote:
Hello graphGang!

I have some relative simple (but also quiet practical) questions for you.

1. How can you access the indices of the nodes of an arbitrary graph?
        - You can not assume that they are equal to the "range(graph.num_vertices())”.  For instance, imagine that we are dealing with a filtered version of some graph.
        - Is there another way than invoking the iterator graph.vertices() ?

The application I have at hand is to sample pairs of nodes of a graph and apply a function like the shortest distance between them (and I would like to do that fast).

2. I think that when it comes to sampling/accessing of the indices of edges there is not a better way than invoking the iterator graph.edges() and work with its output. Correct?

Thanks a lot,
H.

_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool