Date: Fri, 29 Mar 2024 06:59:28 +0000 (UTC) Message-ID: <1016100306.6485.1711695568957@2f9704fbf185> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_6484_367272950.1711695568957" ------=_Part_6484_367272950.1711695568957 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
KGraph is the central data structure in KIELER for representation of gra= phs. It was generated using EMF and therefore inherits all capabilities of EMF models su= ch as storage in XML format, transformation, and validation. The KGraph is = used for several purposes:
The meta model and generated data structure is contained in the plugin <=
a href=3D"http://rtsys.informatik.uni-kiel.de/fisheye/browse/%7Ebr=3Dmaster=
/kieler/plugins/de.cau.cs.kieler.core.kgraph" class=3D"external-link" rel=
=3D"nofollow">de.cau.cs.kieler.core.kgraph
.
See also KLayoutData and KRendering.
Each node in a KGraph = may contain other nodes, thus representing a nested sub-graph. The graph it= self is represented by a top-level node that has no parent node. Nodes may = have incoming and outgoing edges, and each edge has references to its sourc= e node and its target node. Usage of ports is optional and can be applied t= o special cases such as data flow diagrams. If ports are used, they each co= ntain a list of connected edges, and the edges have references to their cor= responding source port and target port. Nodes, edges, and ports may have ar= bitrarily many labels, which are usually (but not necessarily) represented = by text.
Each element of the graph may contain arbitrary additional data, which m= ust implement the interface KGraphData. There are two important extend= ing models that use this interface: KLayoutData, which is used to store layout = data for the graph, and KRendering, which adds graphical information. Gr= aph data inherits from the plain Java IPropertyHolder interface, = which enables it to provide a key-value mapping. Keys are IProperty&nb= sp;instances, which have an identifier string and a type, and values are ar= bitrary objects of the corresponding type. This mapping is transient and is= thus not stored in the XML format. The makePersistent() operatio= n can be used to translate the mapping into a serializable list of string p= airs.
KGraphs can be easily created and edited using our Textual KGraph (KGT) format.<= /p>
KGraphFactory factory =3D KGraphFactory.eINSTANCE; KNode myGraph =3D factory.createKNode(); // Setting the parent reference automatically adds a node to // the parent's list of children. KNode node1 =3D factory.createKNode(); node1.setParent(myGraph); KNode node2 =3D factory.createKNode();=20 node2.setParent(myGraph); // Setting the source and target references automatically adds // an edge to the corresponding incoming and outgoing edges lists. // In the XML structure edges are contained by their source node. KEdge edge =3D factory.createKEdge(); edge.setSource(node1); edge.setTarget(node2); // Setting the parent reference automatically adds a label to // the parent's list of labels. KLabel label =3D factory.createKLabel(); label.setText("Hello, World!"); label.setParent(edge); // Setting the node reference automatically adds a port to the // node's list of ports. KPort port1 =3D factory.createKPort(); port1.setNode(node1); KPort port2 =3D factory.createKPort(); port2.setNode(node2); // Setting the source port / target port reference automatically // adds an edge to the port's list of edges. edge.setSourcePort(port1); edge.setTargetPort(port2);=20
A larger example that uses the KGraph for automatic layout is found in&n= bsp;standalone/LayoutTest/src/test/layout/Test.java.