Networkx parse gml writes unusable gml files

I am trying to parse some additional attributes in the networkx gml file for use later and I am having a problem.

When a gml file is specified from Cytoscape, networkx displays a gml file that it cannot read.

those. Cytoscape -> Into networkx -> Output -> Into networkx -> Error:

pyparsing.ParseException: Expected "]" (at char 1116756), (line:71732, col:3) 

Now this error requests an additional] after the nodes (AKA makes the graph ignore the edges), if you do, the graph works. However, he no longer has ribs.

To fully test this, I did "Cytoscape -> Into networkx -> Output" without changing the code, simply:

 DG = nx.read_gml("KeggComplete.gml", relabel = True) nx.write_gml(DG, "KeggCompleteEng.gml") exit() 

and then type:

 BasicGraph = nx.read_gml("KeggCompleteEng.gml", relabel = True) 

And the error is still reproducible. Therefore, I assume that this is due to the way networkx writes gml files.

Two files that I use:

If someone can give some idea of ​​why this might happen, it will be very helpful!

+1
source share
2 answers

This is a mistake in NetworkX when generating nested attributes (in this case, boundary graphic data is used). An extra set of quotes was incorrectly added to the Line attribute.

The fix was merged as part of this pull request: https://github.com/networkx/networkx/pull/981

+1
source

Pyparsing is not the smartest library when it comes to identification when parsing errors occur. Later versions of the library support some better error identification, but some updates for parsers are required to get this information.

Without viewing the parser, from your description, it looks like the parser expects to see something like:

 [ [ bunch of nodes... ] [ optional bunch of edges... ] ] 

What happens is that it successfully passes through the "bundle of nodes ..." and then detects some syntax problem in one of the edges in the "additional bundle of edges ..." section. Since this is optional, everything will only work if the ']' has been closed after the nodes. This is why you get a pyparsing exception message. But the real problem is that there is a typo on one of the ribs.

To diagnose this, try giving the parser only the first few edges. Then continue to add more and more edges until you get a pyparsing error - the last added edges contain a critical syntax error.

+1
source

All Articles