Hi, is there a way to get the key 'id' of edges in the spirit of the vertices one like the following? _vertexIds works but not _edgeIds. g=load_graph(dataFolder+'networkFullyConnected.xml') _vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"] The result is Traceback (most recent call last): File "edgesProperties.py", line 18, in <module> _edgeIds = g.edge_properties["_graphml_edge_id"] File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 995, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1469, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id') And the network in graphml framework reads as <edge id="1" source="65091" target="65221"> <data key="w">192.49624317</data> </edge> <node id="16071"> <data key="o">5.41539461304e-05</data> <data key="d">2.03027821579e-05</data> </node> Thanks, F.
On 05/29/2014 03:43 PM, Flavien Lambert wrote:
Hi, is there a way to get the key 'id' of edges in the spirit of the vertices one like the following? _vertexIds works but not _edgeIds.
g=load_graph(dataFolder+'networkFullyConnected.xml') _vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"]
The edge property will be there if the edge labeling in the file is not canonical. I.e., if in the beginning of the file you have something like <graph id="G" edgedefault="undirected" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst"> that means that both the edge and node ids are canonical, and in that case the properties will not be available. I've tested with non-canonical labellings and I see both properties. If you see otherwise, please provide a short example. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
*Here is a minimal example :* from graph_tool.all import * g=load_graph('test.xml') _vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"] *test.xml:* <?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <key id="o" for="node" attr.name="origin" attr.type="double"/> <key id="d" for="node" attr.name="destination" attr.type="double"/> <key id="w" for="edge" attr.name="weight" attr.type="double"/> <key id="n" for="edge" attr.name="name" attr.type="int"/> <graph id="G" edgedefault="directed"> <node id="65091"> <data key="o">0.0</data> <data key="d">6.76759405264e-06</data> </node> <edge id="1" source="65091" target="65221"> <data key="w">192.49624317</data> <data key="n">1</data> </edge> <node id="16071"> <data key="o">5.41539461304e-05</data> <data key="d">2.03027821579e-05</data> </node> <edge id="2" source="16071" target="16081"> <data key="w">269.676249521</data> <data key="n">2</data> </edge> <edge id="3" source="16071" target="16061"> <data key="w">299.894548773</data> <data key="n">3</data> </edge> </graph> </graphml> *The error message:* Traceback (most recent call last): File "test.py", line 4, in <module> _edgeIds = g.edge_properties["_graphml_edge_id"] File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 995, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1469, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id') On 29 May 2014 11:32, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 05/29/2014 03:43 PM, Flavien Lambert wrote:
Hi, is there a way to get the key 'id' of edges in the spirit of the vertices one like the following? _vertexIds works but not _edgeIds.
g=load_graph(dataFolder+'networkFullyConnected.xml') _vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"]
The edge property will be there if the edge labeling in the file is not canonical. I.e., if in the beginning of the file you have something like
<graph id="G" edgedefault="undirected" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
that means that both the edge and node ids are canonical, and in that case the properties will not be available.
I've tested with non-canonical labellings and I see both properties. If you see otherwise, please provide a short example.
Best, 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 05/29/2014 08:10 PM, Flavien Lambert wrote:
*The error message:* Traceback (most recent call last): File "test.py", line 4, in <module> _edgeIds = g.edge_properties["_graphml_edge_id"] File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 995, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1469, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id')
I can't reproduce this. For me, the "_graphml_edge_id" property is present with the example you provided. What graph-tool version are you using? Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Damned! 2.2.31 On 29 May 2014 14:43, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 05/29/2014 08:10 PM, Flavien Lambert wrote:
*The error message:* Traceback (most recent call last): File "test.py", line 4, in <module> _edgeIds = g.edge_properties["_graphml_edge_id"] File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 995, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1469, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id')
I can't reproduce this. For me, the "_graphml_edge_id" property is present with the example you provided.
What graph-tool version are you using?
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
I am running it on Fedora 20 and compiled the version on my machine. For the git version, do I have to download it and recompile the whole stuff? On 29 May 2014 15:06, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 05/29/2014 08:50 PM, Flavien Lambert wrote:
Damned!
2.2.31
This is very strange... What OS are you using? Do you see the same problem with the git version?
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
Hi, digging to this old question, I eventualy installed the git version and, unfortunately, I still have the problem of edge id...
from graph_tool.all import * g=load_graph('test.xml')
_vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1049, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1542, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id') g.list_properties() destination (vertex) (type: long double) origin (vertex) (type: long double) _graphml_vertex_id (vertex) (type: string) name (edge) (type: int32_t) weight (edge) (type: long double)
*test.xml:* <?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <key id="o" for="node" attr.name="origin" attr.type="double"/> <key id="d" for="node" attr.name="destination" attr.type="double"/> <key id="w" for="edge" attr.name="weight" attr.type="double"/> <key id="n" for="edge" attr.name="name" attr.type="int"/> <graph id="G" edgedefault="directed"> <node id="65091"> <data key="o">0.0</data> <data key="d">6.76759405264e-06</ data> </node> <edge id="1" source="65091" target="65221"> <data key="w">192.49624317</data> <data key="n">1</data> </edge> <node id="16071"> <data key="o">5.41539461304e-05</data> <data key="d">2.03027821579e-05</data> </node> <edge id="2" source="16071" target="16081"> <data key="w">269.676249521</data> <data key="n">2</data> </edge> <edge id="3" source="16071" target="16061"> <data key="w">299.894548773</data> <data key="n">3</data> </edge> </graph> </graphml> On 30 May 2014 04:43, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 05/29/2014 09:34 PM, Flavien Lambert wrote:
I am running it on Fedora 20 and compiled the version on my machine. For the git version, do I have to download it and recompile the whole stuff?
Yes.
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
I found a funny fact. If I load twice the network, then I can see the edge ids! [Flavien@localhost tmp]$ ipython Python 2.7.5 (default, Jun 25 2014, 10:19:55) Type "copyright", "credits" or "license" for more information. IPython 2.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import graph_tool as gt In [2]: g = gt.load_graph('test.xml') In [3]: g.list_properties() _graphml_vertex_id (vertex) (type: string) In [4]: g = gt.load_graph('test.xml') In [5]: g.list_properties() _graphml_vertex_id (vertex) (type: string) _graphml_edge_id (edge) (type: string) with test.xml <?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <graph id="G" edgedefault="undirected"> <edge id="1" source="65091" target="65221"> </edge> </graph> </graphml> On 15 July 2014 13:58, Flavien Lambert <petit.lepton@gmail.com> wrote:
Hi, digging to this old question, I eventualy installed the git version and, unfortunately, I still have the problem of edge id...
from graph_tool.all import * g=load_graph('test.xml')
_vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1049, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1542, in <lambda>
lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id')
g.list_properties() destination (vertex) (type: long double) origin (vertex) (type: long double) _graphml_vertex_id (vertex) (type: string) name (edge) (type: int32_t) weight (edge) (type: long double)
*test.xml:* <?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <key id="o" for="node" attr.name="origin" attr.type="double"/> <key id="d" for="node" attr.name="destination" attr.type="double"/> <key id="w" for="edge" attr.name="weight" attr.type="double"/> <key id="n" for="edge" attr.name="name" attr.type="int"/> <graph id="G" edgedefault="directed"> <node id="65091"> <data key="o">0.0</data> <data key="d">6.76759405264e-06</ data> </node>
<edge id="1" source="65091" target="65221"> <data key="w">192.49624317</data> <data key="n">1</data>
</edge> <node id="16071"> <data key="o">5.41539461304e-05</data> <data key="d">2.03027821579e-05</data> </node> <edge id="2" source="16071" target="16081"> <data key="w">269.676249521</data> <data key="n">2</data> </edge> <edge id="3" source="16071" target="16061"> <data key="w">299.894548773</data> <data key="n">3</data> </edge> </graph> </graphml>
On 30 May 2014 04:43, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 05/29/2014 09:34 PM, Flavien Lambert wrote:
I am running it on Fedora 20 and compiled the version on my machine. For the git version, do I have to download it and recompile the whole stuff?
Yes.
Best, 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 07/15/2014 07:58 AM, Flavien Lambert wrote:
Hi, digging to this old question, I eventualy installed the git version and, unfortunately, I still have the problem of edge id...
from graph_tool.all import * g=load_graph('test.xml')
_vertexIds = g.vertex_properties["_graphml_vertex_id"] _edgeIds = g.edge_properties["_graphml_edge_id"] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1049, in __getitem__ val = self.get_func(self.g, key) File "/usr/lib/python2.7/site-packages/graph_tool/__init__.py", line 1542, in <lambda> lambda g, k: g.__properties[("e", k)], KeyError: ('e', '_graphml_edge_id') g.list_properties() destination (vertex) (type: long double) origin (vertex) (type: long double) _graphml_vertex_id (vertex) (type: string) name (edge) (type: int32_t) weight (edge) (type: long double)
This has been fixed now in git. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Flavien Lambert -
Tiago de Paula Peixoto