1

I found that although Cytoscape (version 3.5) can import network files in graphml format, it can't read the node and edge attributes in graphml-format network file. For example, the following graphml-format network should be display with nodes colorful. However, when importing the graphml-format network file into Cytoscape, the node attribute (color) is lost. I don't know what's happening for Cytoscape. Anyone knows how to solve this problem?

The following shows the network in graphml format

<?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 id="d0" for="node" attr.name="color" attr.type="string">
    <default>yellow</default>
  </key>
  <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
  <graph id="G" edgedefault="undirected">
    <node id="n0">
      <data key="d0">green</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">blue</data>
    </node>
    <node id="n3">
      <data key="d0">red</data>
    </node>
    <node id="n4"/>
    <node id="n5">
      <data key="d0">turquoise</data>
    </node>
    <edge id="e0" source="n0" target="n2">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e1" source="n0" target="n1">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e2" source="n1" target="n3">
      <data key="d1">2.0</data>
    </edge>
    <edge id="e3" source="n3" target="n2"/>
    <edge id="e4" source="n2" target="n4"/>
    <edge id="e5" source="n3" target="n5"/>
    <edge id="e6" source="n5" target="n4">
      <data key="d1">1.1</data>
    </edge>
  </graph>
</graphml>
Community
  • 1
  • 1
friendpine
  • 11
  • 1

1 Answers1

1

In response to the graphml key, Cytoscape creates a column for "color", which you can map to the actual node color using a passthrough mapping Style. The problem is that there are many possible columns that could be imported and Cytoscape certainly allows one to import a "color" column without implying that should be the node color.

-- scooter

Scooter Morris
  • 1,269
  • 1
  • 7
  • 4
  • Actually, the color for the nodes and edges are specified in the graphml format – friendpine Nov 03 '17 at 13:12
  • For one project I was reading GraphMl file in cytoscape js and it was not reading key id correctly. So I replaced key id in graphml with attr.name, Then It worked. Just sharing my experience with cyto. `` [Project link](http://graphml.abhishekbhardwaj.xyz/) – Abhi May 05 '21 at 11:25