AdjacencyGraphBuilder
The AdjacencyGraphBuilder creates general graphs from a data model that already has a graph structure or where the connections between nodes are given by adjacency relations. The data model consists of one or more node data collections with adjacency information. Edges are created implicitly, so there is no separate edge data collection.
A node data item may either specify its adjacent nodes directly or indirectly via an intermediate edge data item. The following two sections describe both scenarios in detail. In both cases, adjacent nodes may also be referenced via a unique node id.
The data model is allowed to have a recursive nature. The AdjacencyGraphBuilder makes sure no nodes or edges with the same id are created twice.
Specifying Adjacent Nodes directly
For this scenario the example graph shall consist of red and blue nodes with edges only between nodes of different color. Node data items for this scenario may look like this:
The RedNode
type specifies its predecessor and successor nodes directly while the BlueNode
type uses ids to
identify red nodes instead.
To bind the data model to the AdjacencyGraphBuilder, start by creating an AdjacencyNodesSource<TDataItem> for the red nodes:
This nodes source is responsible for creating all red nodes but is bound to the entire data model.
To specify that edges shall be created to predecessor and successor nodes, first create a nodes source for blue nodes as successors and then also register the same nodes source for predecessor edges:
To specify the edges between the blue nodes and the red nodes, create another EdgeCreator and register it at blueNodesSource. This time use ids to identify the nodes.
Specifying Adjacent Nodes Via Edge Data Items
For this scenario the example graph shall consist of nodes that are connected by two types of edges: red and blue ones. Data items for this scenario may look like this:
The RedEdge
type specifies its target node directly while the BlueEdge
type uses ids to identify nodes instead.
To bind the data model to the AdjacencyGraphBuilder, start by creating an AdjacencyNodesSource<TDataItem> for the nodes:
To specify the red edges, create an EdgeCreator<TDataItem> and register it at the nodes source:
To specify the blue edges, create another EdgeCreator<TDataItem> and register it. This time use ids to identify the nodes.
Building and Updating the Graph
The visual appearance, locations and labels of the nodes and edges can be customized via the NodeCreator<TDataItem>s and EdgeCreator<TDataItem>s as explained in the Configuring the Visual Appearance of Graph Items section.
It is also possible to add group nodes from group data. See the Grouping section for details.
After the sources and creators have been configured, a graph can be created and later updated if the business data has changed.
Tutorial Demo Code
The demos Simple Graph Builder and Adjacency Graph Builder show how to use an AdjacencyGraphBuilder to build a graph from user data. See the multistep GraphBuilder Tutorial for in-depth explanations of the various concepts.