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
tiago
(Tiago Peixoto)
December 17, 2012, 8:48pm
3
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)
tiago
(Tiago Peixoto)
December 17, 2012, 10:43pm
6
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)
tiago
(Tiago Peixoto)
December 17, 2012, 11:02pm
8
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)
tiago
(Tiago Peixoto)
December 17, 2012, 11:06pm
10
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)
tiago
(Tiago Peixoto)
December 17, 2012, 11:27pm
12
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)