ValueError on networkxp.write_gexf function

Question:

I have been working on networkx. My graph was too big for networkx so I wanted to open it with gephi. I tried to convert it with nx.write_gexf function but I’m taking this error.

 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call last)
 <ipython-input-17-3e10a08e188f> in <module>
 ----> 1 nx.write_gexf(G, "test.gexf")

 C:ProgramDataAnaconda3libsite-packagesnetworkxutilsdecorators.py in > func(_argmap__wrapper, *args, **kwargs)
    843 
    844         def func(*args, __wrapper=None, **kwargs):
--> 845             return argmap._lazy_compile(__wrapper)(*args, **kwargs)
    846 
    847         # standard function-wrapping stuff

C:ProgramDataAnaconda3libsite-packagesnetworkxutilsdecorators.py in     argmap_write_gexf_1(G, path, encoding, prettyprint, version)
      3 import gzip
      4 import inspect
----> 5 import itertools
      6 import re
      7 from collections import defaultdict

C:ProgramDataAnaconda3libsite-packagesnetworkxreadwritegexf.py in write_gexf(G, path, encoding, prettyprint, version)
     84     
     85     writer = GEXFWriter(encoding=encoding, prettyprint=prettyprint, version=version)
---> 86     writer.add_graph(G)
     87     writer.write(path)
     88 

C:ProgramDataAnaconda3libsite-packagesnetworkxreadwritegexf.py in add_graph(self, G)
    338         graph_element = Element("graph", defaultedgetype=default, mode=mode,     name=name)
    339         self.graph_element = graph_element
--> 340         self.add_nodes(G, graph_element)
    341         self.add_edges(G, graph_element)
    342         self.xml.append(graph_element)

C:ProgramDataAnaconda3libsite-packagesnetworkxreadwritegexf.py in add_nodes(self,     G, graph_element)
    377                 node_data = self.add_spells(node_element, node_data)
    378             node_data = self.add_viz(node_element, node_data)
--> 379             node_data = self.add_attributes("node", node_element, node_data, default)
    380             nodes_element.append(node_element)
    381         graph_element.append(nodes_element)

C:ProgramDataAnaconda3libsite-packagesnetworkxreadwritegexf.py in add_attributes(self, node_or_edge, xml_obj, data, default)
    464             if isinstance(v, list):
    465                 # dynamic data
--> 466                 for val, start, end in v:
    467                     val_type = type(val)
    468                     if start is not None or end is not None:

ValueError: too many values to unpack (expected 3)

My graph is working well, I can see nodes, edges, weights etc. Couldn’t figure why is that happening. Thank you for your time.

Edit: If you want I can share you the graph features

Asked By: Berchister

||

Answers:

I guess your nodes have list as an attribute. set_node_attributes function allows this, but it can cause problems when transferring to Gephi.

Answered By: Berk Ak
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.