iVis-at-Bilkent / cytoscape.js-graphml

A Cytoscape.js extension to import from and export to GraphML format
MIT License
31 stars 8 forks source link

Unable to Import networkx exported graphml #10

Closed talhajunaidd closed 5 years ago

talhajunaidd commented 6 years ago

Hi there I'm using networkx on backend to do heavy lifting and cytoscape.js on frontend to display graph. I've tried to import graphml file generated from networkx but got the following error. ERROR TypeError: Cannot set property 'd0' of undefined

image

Here are contents of graphml file.

<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key attr.name="weight" attr.type="long" for="edge" id="d2" />
  <key attr.name="max" attr.type="long" for="node" id="d1" />
  <key attr.name="min" attr.type="long" for="node" id="d0" />
  <graph edgedefault="directed">
    <node id="a">
      <data key="d0">0</data>
      <data key="d1">2</data>
    </node>
    <node id="b">
      <data key="d0">0</data>
      <data key="d1">3</data>
    </node>
    <edge source="a" target="b">
      <data key="d2">-4</data>
    </edge>
  </graph>
</graphml>

Any help will be appreciated.

rg2609 commented 6 years ago

I am also facing the same problem, and I think this is because of the settings[$data.attr("type")][$data.attr("key")] = $data.text(); if this change to settings["data"][$data.attr("key")] = $data.text(); then issue resoled.

ugurdogrusoz commented 6 years ago

We don't have anybody to work on this currently but feel free to do a PR to fix the problem and we'd be happy to review and merge it.

andfaulkner commented 5 years ago

I made a PR for it. Thanks @rg2609!