Unexpected error reading GML graph

∥☆過路亽.° 提交于 2019-12-04 06:31:41

In the newer versions of networkx, the gml file should follow a more specific format. The problem with the dolphins.gml is that there should not be any carriage return before the open square brackets. For example:

Wrong format:

graph 
[
  directed 0
  node 
  [
    id 0
    label "Beak"
  ]
  .
  .
  .

Correct format:

graph [
  directed 0
  node [
    id 0
    label "Beak"
  ]
  .
  .
  .

It does not care about how many spaces there are before the square bracket as long as there is more than one and there is no carriage return.

What I ended up doing was using regular expression to get rid of the white spaces before the opening square brackets. The following regex worked for me:

\s+\[

and just replace it with " [". There has to be at least one space before the bracket.

Also keep in mind that every node has to have a unique label.

Hope it helped.

It worked by downgrading the networkx version from 1.10 to 1.9.1.

Hope this answer can help someone else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!