xml - 用 XML 表示图形

标签 xml graph

您好,用 XML 表示图形的最佳方式是什么,其中节点可以是父节点的子节点,也可以是另一个子节点的父节点。它可以引用自己,多个节点可以有相同的父节点。一个节点可以有多个父节点。 所有节点都来自同一类。我想高效地构建它,这样如果我可以从父节点了解子节点,我就可以转到特定的子标记,而不必遍历所有节点。是否可以? 例如这里是一个概述,

A->B,C,D

B->C,D

看起来像

<Node name=A>
 <childNode name=B>
 <childNode name=C>
 <childNode name=D>
</Node>

<Node name=B>
 <childNode name=C>
 <childNode name=D>
</Node>

那么还有比这更好的方法吗?每当我从 A 即 B 得到一个 child 时,我将不得不基本上遍历所有节点并将那里的名称属性与 B 匹配以找到代表 B 的节点。我能以某种方式更快地完成吗?

最佳答案

既然你有一个图,而不是你最初想的一棵树,为什么不使用 GraphML

GraphML is a comprehensive and easy-to-use file format for graphs. It consists of a language core to describe the structural properties of a graph and a flexible extension mechanism to add application-specific data.

Unlike many other file formats for graphs, GraphML does not use a custom syntax. Instead, it is based on XML and hence ideally suited as a common denominator for all kinds of services generating, archiving, or processing graphs.

关于xml - 用 XML 表示图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12905230/

相关文章:

c++ - 来自 Internet 和 Qt 的 XML 文件

java - Android 上的 NOAA Weather API

c# - 在 XML 日期时间上正确设置日期时间格式

在 ggplot2 0.9.0 中使用 axis.line 仅删除 y 轴

haskell - 如何确保图中的边正确

javascript - 使用 XML 类时出现 Flowtype 错误

algorithm - 位于半圆内的点的 MST 上界

algorithm - 路径重构——伪乘法(矩阵乘法)算法

algorithm - 数据结构List和Graph有什么区别?

python - 使用 ElementTree 和 BeautifulSoup 解析文件 : is there a way to parse the file by number of tag levels?