复杂的图形可能包括嵌套,超边或注册点,这些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">
其中,如果边连接的是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">
至此,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>
<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"
?>
< graphml xmlns ="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" >
< graph id ="G" edgedefault ="undirected" >
< node id ="n0" />
< node id ="n1" />
< node id ="n2" />
< node id ="n3" />
< node id ="n4" />
< node id ="n5" >
< graph id ="n5:" edgedefault ="undirected" >
< node id ="n5::n0" />
< node id ="n5::n1" />
< node id ="n5::n2" />
< edge id ="e0" source ="n5::n0" target ="n5::n2" />
< edge id ="e1" source ="n5::n1" target ="n5::n2" />
</ graph >
</ node >
< node id ="n6" >
< graph id ="n6:" edgedefault ="undirected" >
< node id ="n6::n0" >
< graph id ="n6::n0:" edgedefault ="undirected" >
< node id ="n6::n0::n0" />
</ graph >
</ node >
< node id ="n6::n1" />
< node id ="n6::n2" />
< edge id ="e10" source ="n6::n1" target ="n6::n0::n0" />
< edge id ="e11" source ="n6::n1" target ="n6::n2" />
</ graph >
</ node >
< edge id ="e2" source ="n5::n2" target ="n0" />
< edge id ="e3" source ="n0" target ="n2" />
< edge id ="e4" source ="n0" target ="n1" />
< edge id ="e5" source ="n1" target ="n3" />
< edge id ="e6" source ="n3" target ="n2" />
< edge id ="e7" source ="n2" target ="n4" />
< edge id ="e8" source ="n3" target ="n6::n1" />
< edge id ="e9" source ="n6::n1" target ="n4" />
</ graph >
</ graphml >
< graphml xmlns ="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" >
< graph id ="G" edgedefault ="undirected" >
< node id ="n0" />
< node id ="n1" />
< node id ="n2" />
< node id ="n3" />
< node id ="n4" />
< node id ="n5" >
< graph id ="n5:" edgedefault ="undirected" >
< node id ="n5::n0" />
< node id ="n5::n1" />
< node id ="n5::n2" />
< edge id ="e0" source ="n5::n0" target ="n5::n2" />
< edge id ="e1" source ="n5::n1" target ="n5::n2" />
</ graph >
</ node >
< node id ="n6" >
< graph id ="n6:" edgedefault ="undirected" >
< node id ="n6::n0" >
< graph id ="n6::n0:" edgedefault ="undirected" >
< node id ="n6::n0::n0" />
</ graph >
</ node >
< node id ="n6::n1" />
< node id ="n6::n2" />
< edge id ="e10" source ="n6::n1" target ="n6::n0::n0" />
< edge id ="e11" source ="n6::n1" target ="n6::n2" />
</ graph >
</ node >
< edge id ="e2" source ="n5::n2" target ="n0" />
< edge id ="e3" source ="n0" target ="n2" />
< edge id ="e4" source ="n0" target ="n1" />
< edge id ="e5" source ="n1" target ="n3" />
< edge id ="e6" source ="n3" target ="n2" />
< edge id ="e7" source ="n2" target ="n4" />
< edge id ="e8" source ="n3" target ="n6::n1" />
< edge id ="e9" source ="n6::n1" target ="n4" />
</ graph >
</ 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">
超边( 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"
?>
< graphml xmlns ="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" >
< graph id ="G" edgedefault ="undirected" >
< node id ="n0" />
< node id ="n1" />
< node id ="n2" />
< node id ="n3" />
< node id ="n4" />
< node id ="n5" />
< node id ="n6" />
< hyperedge >
< endpoint node ="n0" />
< endpoint node ="n1" />
< endpoint node ="n2" />
</ hyperedge >
< hyperedge >
< endpoint node ="n3" />
< endpoint node ="n4" />
< endpoint node ="n5" />
< endpoint node ="n6" />
</ hyperedge >
< hyperedge >
< endpoint node ="n1" />
< endpoint node ="n3" />
</ hyperedge >
< edge source ="n0" target ="n4" />
</ graph >
</ graphml >
< graphml xmlns ="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" >
< graph id ="G" edgedefault ="undirected" >
< node id ="n0" />
< node id ="n1" />
< node id ="n2" />
< node id ="n3" />
< node id ="n4" />
< node id ="n5" />
< node id ="n6" />
< hyperedge >
< endpoint node ="n0" />
< endpoint node ="n1" />
< endpoint node ="n2" />
</ hyperedge >
< hyperedge >
< endpoint node ="n3" />
< endpoint node ="n4" />
< endpoint node ="n5" />
< endpoint node ="n6" />
</ hyperedge >
< hyperedge >
< endpoint node ="n1" />
< endpoint node ="n3" />
</ hyperedge >
< edge source ="n0" target ="n4" />
</ graph >
</ graphml >
注册点(port)
注册点指边或超边连接到node上的逻辑位置。一个node可以有多个注册点,用port子元素定义:
<?
xmlversion="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/xmlnshttp://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd" >
< graph id ="G" edgedefault ="directed" >
< node id ="n0" >
< port name ="North" />
< port name ="South" />
< port name ="East" />
< port name ="West" />
</ node >
< node id ="n1" >
< port name ="North" />
< port name ="South" />
< port name ="East" />
< port name ="West" />
</ node >
< node id ="n2" >
< port name ="NorthWest" />
< port name ="SouthEast" />
</ node >
< node id ="n3" >
< port name ="NorthEast" />
< port name ="SouthWest" />
</ node >
< edge source ="n0" target ="n3" sourceport ="North" targetport ="NorthEast" />
< hyperedge >
< endpoint node ="n0" port ="North" />
< endpoint node ="n1" port ="East" />
< endpoint node ="n2" port ="SouthEast" />
</ hyperedge >
</ graph >
</ graphml >
< graphml xmlns ="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" >
< graph id ="G" edgedefault ="directed" >
< node id ="n0" >
< port name ="North" />
< port name ="South" />
< port name ="East" />
< port name ="West" />
</ node >
< node id ="n1" >
< port name ="North" />
< port name ="South" />
< port name ="East" />
< port name ="West" />
</ node >
< node id ="n2" >
< port name ="NorthWest" />
< port name ="SouthEast" />
</ node >
< node id ="n3" >
< port name ="NorthEast" />
< port name ="SouthWest" />
</ node >
< edge source ="n0" target ="n3" sourceport ="North" targetport ="NorthEast" />
< hyperedge >
< endpoint node ="n0" port ="North" />
< endpoint node ="n1" port ="East" />
< endpoint node ="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>