复杂的图形可能包括嵌套,超边或注册点,这些GraphML也提供了内建的支持。
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="StarSuite 8 (Linux)">
<meta name="AUTHOR" content="*">
<meta name="CREATED" content="20071029;11490000">
<meta name="CHANGEDBY" content="Seaman Wang">
<meta name="CHANGED" content="20080123;14404900">
嵌套图( Nested Graph )
嵌套图表现为图形的子元素本身也可能为图。比如:

用GraphML表示如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<graphmlxmlns="http://graphml.graphdrawing.org/xmlns"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlnshttp://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graphid="G"edgedefault="undirected">
<nodeid="n0"/>
<nodeid="n1"/>
<nodeid="n2"/>
<nodeid="n3"/>
<nodeid="n4"/>
<nodeid="n5">
<graphid="n5:"edgedefault="undirected">
<nodeid="n5::n0"/>
<nodeid="n5::n1"/>
<nodeid="n5::n2"/>
<edgeid="e0"source="n5::n0"target="n5::n2"/>
<edgeid="e1"source="n5::n1"target="n5::n2"/>
</graph>
</node>
<nodeid="n6">
<graphid="n6:"edgedefault="undirected">
<nodeid="n6::n0">
<graphid="n6::n0:"edgedefault="undirected">
<nodeid="n6::n0::n0"/>
</graph>
</node>
<nodeid="n6::n1"/>
<nodeid="n6::n2"/>
<edgeid="e10"source="n6::n1"target="n6::n0::n0"/>
<edgeid="e11"source="n6::n1"target="n6::n2"/>
</graph>
</node>
<edgeid="e2"source="n5::n2"target="n0"/>
<edgeid="e3"source="n0"target="n2"/>
<edgeid="e4"source="n0"target="n1"/>
<edgeid="e5"source="n1"target="n3"/>
<edgeid="e6"source="n3"target="n2"/>
<edgeid="e7"source="n2"target="n4"/>
<edgeid="e8"source="n3"target="n6::n1"/>
<edgeid="e9"source="n6::n1"target="n4"/>
</graph>
</graphml>
其中,如果边连接的是node中子图内的node,则适用::表示node的层级。如source="n6::n1"
<style type="text/css">
<!--
@page { size: 21cm 29.7cm; margin: 2cm }
P { margin-bottom: 0.21cm }
H3 { margin-bottom: 0.21cm }
H3.western { font-family: "Albany", "Arial", sans-serif }
H3.cjk { font-family: "方正黑体"; font-style: normal }
H3.ctl { font-family: "Lucidasans" }
--></style>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="StarSuite 8 (Linux)">
<meta name="AUTHOR" content="*">
<meta name="CREATED" content="20071029;11490000">
<meta name="CHANGEDBY" content="Seaman Wang">
<meta name="CHANGED" content="20080123;14404900">
超边( Hyperedges )
超边是指连接到多个node的边,如图:

在GraphML中用元素
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="StarSuite 8 (Linux)">
<meta name="AUTHOR" content="*">
<meta name="CREATED" content="20071029;11490000">
<meta name="CHANGEDBY" content="Seaman Wang">
<meta name="CHANGED" content="20080123;16154100">
<style type="text/css">
<!--
@page { size: 21cm 29.7cm; margin: 2cm }
PRE.western { font-family: "Cumberland", "Courier New", monospace }
PRE.cjk { font-family: "方正宋体", monospace }
PRE.ctl { font-family: "方正宋体", monospace }
P { margin-bottom: 0.21cm }
--></style>
hyperedge表示超边,其子元素为多个endpoint,每个endpoint指向一个node:
<?xmlversion="1.0"encoding="UTF-8"?>
<graphmlxmlns="http://graphml.graphdrawing.org/xmlns"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlnshttp://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graphid="G"edgedefault="undirected">
<nodeid="n0"/>
<nodeid="n1"/>
<nodeid="n2"/>
<nodeid="n3"/>
<nodeid="n4"/>
<nodeid="n5"/>
<nodeid="n6"/>
<hyperedge>
<endpointnode="n0"/>
<endpointnode="n1"/>
<endpointnode="n2"/>
</hyperedge>
<hyperedge>
<endpointnode="n3"/>
<endpointnode="n4"/>
<endpointnode="n5"/>
<endpointnode="n6"/>
</hyperedge>
<hyperedge>
<endpointnode="n1"/>
<endpointnode="n3"/>
</hyperedge>
<edgesource="n0"target="n4"/>
</graph>
</graphml>
注册点(port)
注册点指边或超边连接到node上的逻辑位置。一个node可以有多个注册点,用port子元素定义:
<?xmlversion="1.0"encoding="UTF-8"?>
<graphmlxmlns="http://graphml.graphdrawing.org/xmlns"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlnshttp://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graphid="G"edgedefault="directed">
<nodeid="n0">
<portname="North"/>
<portname="South"/>
<portname="East"/>
<portname="West"/>
</node>
<nodeid="n1">
<portname="North"/>
<portname="South"/>
<portname="East"/>
<portname="West"/>
</node>
<nodeid="n2">
<portname="NorthWest"/>
<portname="SouthEast"/>
</node>
<nodeid="n3">
<portname="NorthEast"/>
<portname="SouthWest"/>
</node>
<edgesource="n0"target="n3"sourceport="North"targetport="NorthEast"/>
<hyperedge>
<endpointnode="n0"port="North"/>
<endpointnode="n1"port="East"/>
<endpointnode="n2"port="SouthEast"/>
</hyperedge>
</graph>
</graphml>
至此,GraphML的定义如下图:
<style type="text/css"><!--
@page { size: 21cm 29.7cm; margin: 2cm }
P { margin-bottom: 0.21cm }
H3 { margin-bottom: 0.21cm }
H3.western { font-family: "Albany", "Arial", sans-serif }
H3.cjk { font-family: "方正黑体"; font-style: normal }
H3.ctl { font-family: "Lucidasans" }
--></style>
相关文章:
-
2021-10-10
-
2021-05-18
-
2022-12-23
-
2021-07-11
-
2022-02-22
-
2021-12-26
-
2021-10-16