Hello Tiago,
thank you very much for the suggestions. i'll try to find the way that best fit to my case.
Cheers,
Elia
Hello Elia,
There is no simple solution for this if you intend to modify the graph by
Elia Bruni wrote:
> Hello list,
>
> I am currently working with graph_tool to analyse text documents. let's
> say that in my graph each vertex is a word that appears in the text and
> each edge corresponds to a relationship between two words. Because of
> the fact that vertex is individuated only by its index i suppose to use
> a vertex property map (let's call it 'name', of type 'string') to put
> the word related to the vertex, assuring a bijective property of the
> "word <-> vertex index" function.
> Intuitively i'd like to do something like idx = g.vertex("example").
> I cannot see how to implement it with the PropertyMaps because i can
> only have the function "vertex index -> word".
>
> I cannot keep the "word -> vertex index" elsewhere because
> remove_vertex() is changing my indexes under my feet.
>
> Does anybody of you have a suggestion?
removing vertices... You have basically two options:
1 - Don't remove the vertex, and instead just mask it out of the graph, with
set_vertex_filter(). This way, all vertex objects remain valid, and
you can store them as values of a dictionary.
2 - Use the find_vertex() function to find vertices with a given property
map value. This is easy, but it is also slow, since every lookup
takes O(V) time.
I hope this helps.
Cheers,
Tiago
_______________________________________________
graph-tool mailing list
graph-tool@forked.de
http://lists.forked.de/mailman/listinfo/graph-tool