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 -- Daniel Müllner Stanford University Department of Mathematics 450 Serra Mall, Building 380 Stanford, CA 94305 USA e-mail: muellner@math.stanford.edu http://math.stanford.edu/~muellner
do you mean this? http://pastie.org/private/ezf3dltycxmvaeiow92a On 17 December 2012 15:30, Daniel Müllner <muellner@math.stanford.edu>wrote:
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
-- Daniel Müllner Stanford University Department of Mathematics 450 Serra Mall, Building 380 Stanford, CA 94305 USA e-mail: muellner@math.stanford.edu http://math.stanford.edu/~**muellner <http://math.stanford.edu/~muellner> ______________________________**_________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/**mailman/listinfo/graph-tool<http://lists.skewed.de/mailman/listinfo/graph-tool>
On 12/17/2012 09:30 PM, Daniel Müllner wrote:
for edge in GV.edges(): source = GV.vertex_index(edge.source()) print(source)
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 -- Tiago de Paula Peixoto <tiago@skewed.de>
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
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
Tiago, What's the benefit in using a property map over just calling the attribute of the edge? Thanks, Ronnie On 17 December 2012 15:52, Daniel Müllner <muellner@math.stanford.edu>wrote:
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
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
______________________________**_________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/**mailman/listinfo/graph-tool<http://lists.skewed.de/mailman/listinfo/graph-tool>
Sorry I mean in general. ~ any performance gain? ..... as in is it not a memory redundancy otherwise? On 17 December 2012 17:43, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 12/17/2012 09:56 PM, Ronnie Ghose wrote:
What's the benefit in using a property map over just calling the attribute of the edge?
None. I did not imply there was any benefit, I just explained what his mistake was.
Cheers, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
On 12/17/2012 11:45 PM, Ronnie Ghose wrote:
Sorry I mean in general. ~ any performance gain? ..... as in is it not a memory redundancy otherwise?
I don't understand your question. What are the cases you are comparing, and what kind of performance are you talking about? -- Tiago de Paula Peixoto <tiago@skewed.de>
why can you get the same information using a property map and the edge attributes? Why is the information duplicated? On 17 December 2012 18:02, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 12/17/2012 11:45 PM, Ronnie Ghose wrote:
Sorry I mean in general. ~ any performance gain? ..... as in is it not a memory redundancy otherwise?
I don't understand your question. What are the cases you are comparing, and what kind of performance are you talking about?
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
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. On 17 December 2012 18:06, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 12/18/2012 12:04 AM, Ronnie Ghose wrote:
why can you get the same information using a property map and the edge attributes? Why is the information duplicated?
What information? What edge attribute?
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
On 12/18/2012 12:13 AM, Ronnie Ghose wrote:
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.
You're not making much effort to explain clearly what you mean. I have no idea of what property map you are talking about. -- Tiago de Paula Peixoto <tiago@skewed.de>
Ehh nevermind ~~ sorry for the vague question. On 17 December 2012 18:27, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 12/18/2012 12:13 AM, Ronnie Ghose wrote:
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.
You're not making much effort to explain clearly what you mean. I have no idea of what property map you are talking about.
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
participants (3)
-
Daniel Müllner -
Ronnie Ghose -
Tiago de Paula Peixoto