How to represent an iterable attribute using graphml format

♀尐吖头ヾ 提交于 2020-02-02 12:08:26

问题


I have an example of a graph with a graph property named random that has a value of 23. Is there a way to represent say a list of values as a graph attribute in this format without violating the core 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="g_random" for="graph" attr.name="random" attr.type="double"/>
  <graph id="G" edgedefault="undirected">
    <data key="g_random">23</data> 
    <node id="n0">
    </node>
    <node id="n1">
    </node>
    <edge source="n0" target="n1">
    </edge>
 </graph>

Thanks


回答1:


I ended up using a string data type to encode the data within the array. There is no native way to represent iterable data types with this format at the time of this posting. Here is an example of a node attribute with an array of values associated with it, in graphml format:

<graphml 
<!-- Boilerplate graphml -->

<key id="v_arr" for="node" attr.name="arr" attr.type="string"/>
<graph id="G" edgedefault="undirected">
:
:

<node id="n0">
  <data key="v_arr">23 4 5</data>
</node>
<node id="n1">
  <data key="v_arr">34.3 53.34</data>
</node>
<node id="n2">
  <data key="v_arr">45.4 23E-23</data>
</node>
<edge source="n0" target="n2">
</edge>



来源:https://stackoverflow.com/questions/21079708/how-to-represent-an-iterable-attribute-using-graphml-format

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