Missing weight when saving as GEXF with value equal to 0

5 views
Skip to first unread message

Alejandro Weinstein

unread,
May 11, 2011, 7:04:58 PM5/11/11
to networkx-discuss
Hi:

I don't know if this is an expected behavior or if it is a bug. In a
weighted digraph, if I set the weight of an edge equal to 0, and then
save the graph in GEXF format, the weight of that edge in the GEXF
file is missing. The problem is that when I open the file in Gephi,
that edge appears with a weight equal to 1.

The following code illustrate the problem:

import networkx as nx

G = nx.DiGraph()

G.add_node('A')
G.add_node('B')
G.add_node('C')

G.add_edge('A', 'B', weight=2)
G.add_edge('B', 'C', weight=1)
G.add_edge('C', 'A', weight=0)

nx.write_gexf(G, 'graph.gexf')

These are the edges that appear in graph.gexf:

<edge id="0" source="A" target="B" weight="2" />
<edge id="1" source="C" target="A" />
<edge id="2" source="B" target="C" weight="1" />

I am using Networkx version 1.4 and Python 2.6.5

Alejandro.

Aric Hagberg

unread,
May 11, 2011, 7:17:38 PM5/11/11
to networkx...@googlegroups.com

Thanks for the report. It's a bug. I opened a ticket at
https://networkx.lanl.gov/trac/ticket/550

Aric

Reply all
Reply to author
Forward
0 new messages