On 08/05/2014 12:55 AM, Helen Lampesis 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() ?
If you are dealing with a filtered graph, the Graph.vertices iterator is the best way. Another option is the use the Graph.vertex(i, use_index=False), to return the i-th vertex. However, if you use this with filtered graphs, it takes time O(N) per call. > 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). The simplest thing you can do is to build a list of vertices at the beginning, and use that for the rest of the algorithm. > 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? Yes. The edges are not stored in a single array, so they cannot be addressed easily. But again, you can easily store the edge descriptors in a list in the initialization of your algorithm, and address them easily. Best, Tiago -- Tiago de Paula Peixoto <[email protected]> _______________________________________________ graph-tool mailing list [email protected] http://lists.skewed.de/mailman/listinfo/graph-tool
