Cannot access vertices of a GraphView

Dear experts,

when I build a GraphView, I cannot access the vertices of an edge. Here
is a minimal example:

import graph_tool as gt
import graph_tool.topology as gtt

G = gt.Graph(directed=False)

G.add_vertex(4)

for s,t in [(0,1), (2,3), (0,2)]:
     G.add_edge(G.vertex(s), G.vertex(t))

match, is_maximal = gtt.max_cardinality_matching(G)

GV = gt.GraphView(G, efilt=match)

for edge in GV.edges():
     source = GV.vertex_index(edge.source())
     print(source)

I get the following error message:

Traceback (most recent call last):
   File "gt_test.py", line 16, in <module>
     source = GV.vertex_index(edge.source())
...
...
   File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line
181, in _type_alias
     raise ValueError("invalid property value type: " + type_name)
ValueError: invalid property value type: unsigned long

Any idea what's wrong here, and more importantly: how to fix it?

Best regards,

Daniel

do you mean this?

http://pastie.org/private/ezf3dltycxmvaeiow92a

attachment.html (2.29 KB)

In order to access property map items, you have to use the [] operator,
not the call operator, i.e.

    for edge in GV.edges():
        source = GV.vertex_index[edge.source()]
        print(source)

(The call operator expects an array, which is copied to the property
internal values.)

Cheers,
Tiago

Silly me! I thought that I had used round brackets with ordinary Graphs
(as opposed to GraphViews before), but that was wrong. Thanks for the
swift help!

Cheers,

Daniel

Tiago,

What's the benefit in using a property map over just calling the attribute
of the edge?

Thanks,
Ronnie

attachment.html (1.55 KB)

None. I did not imply there was any benefit, I just explained what his
mistake was.

Cheers,
Tiago

Sorry I mean in general. ~ any performance gain? ..... as in is it not a
memory redundancy otherwise?

attachment.html (1.19 KB)

I don't understand your question. What are the cases you are
comparing, and what kind of performance are you talking about?

why can you get the same information using a property map and the edge
attributes? Why is the information duplicated?

attachment.html (1.24 KB)

What information? What edge attribute?

to get edge attributes. ex. which two vertices it connects, why is this
mirrored in property map *and* edge objects? as in the information is
stored twice .... its like having an array of the same information in two
different places.

attachment.html (1.28 KB)

You're not making much effort to explain clearly what you mean. I have
no idea of what property map you are talking about.

Ehh nevermind ~~ sorry for the vague question.

attachment.html (1.33 KB)