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

Add attributes to "data" by name not by id #21

Open Lazloo opened 4 years ago

Lazloo commented 4 years ago

Hello everyone,

I have an autogenerate graphml file like:

<?xml versi

    on='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="relationship" attr.type="string" for="edge" id="d8"/>

    <key attr.name="node_name" attr.type="string" for="node" id="d0"/>
    <key attr.name="parent" attr.type="long" for="node" id="d1"/>
    <graph edgedefault="directed">
    <node id="123">
      <data key="d0">First</data>
    </node>
    <node id="124">
      <data key="d0">Second</data>
      <data key="d1">First</data>
    </node>
    ...

Currenty the node attributes in the final data are represented by the keys (d0 and d1). However, when I add a new attribute, the order changes and therefore the attribute name vs. id association. Is it possible to add the attributes by name (node_name and parent)?

THX Lazloo

hasanbalci commented 4 years ago

Currently, extension doesn't support reading data by name. It just evaluates key and value to construct the node data.