Remarks
Type Parameters
TNode
TEdge
TNodeLabel
TEdgeLabel
Examples
The following example shows how to create a new instance of this class and use it in conjunction with an ILayoutAlgorithm that has a SubgraphLayoutStage already in its LayoutStageStack:
const hierarchicLayout = new HierarchicalLayout()
hierarchicLayout.layoutStages.get(SubgraphLayoutStage)!.enabled = true
const subgraphLayoutData = new SubgraphLayoutStageData()
//only nodes that have at least one adjacent edge are included and visible for the hierarchic layout
subgraphLayoutData.subgraphNodes = (node) => graph.degree(node) > 0
graphComponent.graph.applyLayout(hierarchicLayout, subgraphLayoutData)The SubgraphLayoutStage and its SubgraphLayoutStageData<TNode, TEdge, TNodeLabel, TEdgeLabel> can be used as a stage with any other layout algorithm:
//create an edge routing algorithm wrapped by a subgraph layout stage
const layout = new SubgraphLayoutStage(new EdgeRouter())
const layoutData = new SubgraphLayoutStageData()
//exclude edges that are a self-loop -> will not be visible for the core layout (EdgeRouter in this example)
layoutData.subgraphEdges.excludes = (edge) => edge.isSelfLoop
graphComponent.graph.applyLayout(layout, layoutData)Members
Constructors
Properties
Gets or sets the collection of subgraph edge labels that are included in the graph, thus, are visible for the coreLayout of the SubgraphLayoutStage.
If nothing is set, all edge labels of the graph will be included in the subgraph.
If only the excludes are set, all edge labels in the graph except those provided in the excludes are part of the subgraph.
Note that edge labels are automatically excluded if the associated edge is not in the subgraphEdges.
See Also
Gets or sets the collection of subgraph edges that are included in the graph, thus, are visible for the coreLayout of the SubgraphLayoutStage.
If nothing is set, all edges of the graph will be included in the subgraph.
If only the excludes are set all edges in the graph except those provided in the excludes are part of the subgraph.
Note that edges which start or end at nodes which are not in the subgraphNodes are automatically excluded.
Examples
Defining the subgraph edges can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
layoutData.subgraphEdges = graphComponent.selection.edgesAlternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
layoutData.subgraphEdges.items.add(edge1)
layoutData.subgraphEdges.items.add(edge2)A powerful option that doesn't use a collection is to use the predicate to set a custom delegate that returns for every edge whether it is contained in the subgraph or not:
// We assume here that all edges have a data instance as their tag,
// which then has a boolean property 'includeInSubgraph'.
layoutData.subgraphEdges = (edge) => edge.tag.includeInSubgraphTo only exclude specific edges, the excludes property can be used:
// In this example two specific edges are excluded
layoutData.subgraphEdges.excludes = (edge) =>
excludedEdge1 === edge || excludedEdge2 === edgeSee Also
Gets or sets the collection of subgraph node labels that are included in the graph, thus, are visible for the coreLayout of the SubgraphLayoutStage.
If nothing is set, all node labels of the graph will be included in the subgraph.
If only the excludes are set, all node labels in the graph except those provided in the excludes are part of the subgraph.
Note that node labels are automatically excluded if the associated node is not in the subgraphNodes.
See Also
Gets or sets the collection of subgraph nodes that are included in the graph, thus, are visible for the coreLayout of the SubgraphLayoutStage.
Examples
Defining the subgraph nodes can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
layoutData.subgraphNodes = graphComponent.selection.nodesAlternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
layoutData.subgraphNodes.items.add(node1)
layoutData.subgraphNodes.items.add(node2)A powerful option that doesn't use a collection is to use the predicate to set a custom delegate that returns for every node whether it is contained in the subgraph or not:
// We assume here that all nodes have a data instance as their tag,
// which then has a boolean property 'includeInSubgraph'.
layoutData.subgraphNodes = (node) => node.tag.includeInSubgraphTo only exclude specific nodes, the excludes property can be used:
// In this example two specific nodes are excluded
layoutData.subgraphNodes.excludes = (node) =>
excludedNode1 === node || excludedNode2 === nodeSee Also
Methods
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>Combines this instance with the given layout data.
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>Parameters
- data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
- The LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> to combine this instance with.
Return Value
- LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
- The combined layout data.
See Also
Developer's Guide
API
- CompositeLayoutData, GenericLayoutData