Package: python-networkx
Version: 1.7~rc1-3
Severity: normal
Dear Maintainer,
networkx raises TypeError when reading input from .gml file:
$ python cart_product.py c3.gml c3.gml
graph [
node [
id 0
Traceback (most recent call last):
File "cart_product.py", line 22, in <module>
for line in nx.generate_gml(X):
File "/usr/lib/pymodules/python2.7/networkx/readwrite/gml.py", line 328, in
generate_gml
yield 2*indent+'label %s'%label
TypeError: not all arguments converted during string formatting
Bug is affecting Debian stable and sid. It seems that version 1.7-2 in
Debian experimental contains the same bug, since it contains the same
line in file gml.py.
It seems that bug is fixed by applying the following patch (tested for
debian stable and sid):
--- a/networkx/readwrite/gml.py
+++ b/networkx/readwrite/gml.py
@@ -325,7 +325,7 @@
label=G.node[n].get('label',n)
if is_string_like(label):
label='"%s"'%label
- yield 2*indent+'label %s'%label
+ yield 2*indent+'label {0}'.format(label)
if n in G:
for k,v in G.node[n].items():
if k=='id' or k == 'label': continue
-- System Information:
Debian Release: 7.3
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-networkx depends on:
ii python 2.7.3-4+deb7u1
ii python-support 1.0.15
Versions of packages python-networkx recommends:
ii python-matplotlib 1.1.1~rc2-1
ii python-numpy 1:1.6.2-1.2
ii python-pkg-resources 0.6.24-1
ii python-pygraphviz 1.1-2
ii python-scipy 0.10.1+dfsg2-1
ii python-yaml 3.10-4
python-networkx suggests no packages.
-- no debconf information
graph [
comment "C_3"
node [ id 1 ]
node [ id 2 ]
node [ id 3 ]
edge[ source 1 target 2 ]
edge[ source 2 target 3 ]
edge[ source 3 target 1 ]
]
#!/usr/bin/env python
import networkx as nx
import sys
def cart_product(G, H):
X = nx.Graph()
for u in G.nodes():
for v in H.nodes():
X.add_node((u,v))
for u in X.nodes():
for v in X.nodes():
if (G.has_edge(u[0], v[0]) and u[1] == v[1]) or \
(H.has_edge(u[1], v[1]) and u[0] == v[0]):
X.add_edge(u, v)
return X
if __name__ == '__main__':
G = nx.read_gml(sys.argv[1])
H = nx.read_gml(sys.argv[2])
X = cart_product(G, H)
for line in nx.generate_gml(X):
print line
_______________________________________________
Python-modules-team mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team