Provides access to the hierarchical structure of a LayoutGraph in the form of a grouping tree.
Remarks
The hierarchy is represented as a tree where group nodes are the parents of the nodes they contain. Group nodes can contain both normal nodes and other group nodes, and all top-level nodes are children of a virtual root node.
This class caches the hierarchical structure of the graph when instantiated. Therefore, subsequent modifications to the graph may not be reflected in the current instance.
When group nodes are copied or replaced, the original hierarchy should be restored by calling the restore method to avoid inconsistencies.
The following example shows a hierarchical graph containing group nodes, illustrating how nodes are nested inside group nodes:
The figure below shows the tree representing the hierarchical structure of the grouped graph. The labels in the hierarchy tree correspond to nodes from the grouped graph, and group nodes are treated as the parents of their contents.
This class cannot be instantiated
Type Details
- yFiles module
- algorithms
Properties
Gets the virtual root of the hierarchy tree, which is null
.
Remarks
Property Value
null
.See Also
Methods
Clears all grouping information from the current LayoutGraphGrouping.
Remarks
Returns
- ↪boolean
true
if clearing was successful, otherwisefalse
.
Throws
- Exception({ name: 'InvalidOperationError' })
- Thrown if the current grouping hierarchy is a read-only view.
Returns the direct children of the specified group node.
Remarks
Parameters
A map of options to pass to the method.
- parent - LayoutNode
- The group node whose children are to be retrieved.
Returns
- ↪ILinkedItemEnumerable<LayoutNode>
- The child nodes of the specified parent.
See Also
Sample Graphs
Returns all descendants of the given group node.
Remarks
Parameters
A map of options to pass to the method.
- parent - LayoutNode
- The group node for which to retrieve descendants. Passing the virtual root node will return all nodes in the graph.
Returns
- ↪ILinkedItemEnumerable<LayoutNode>
- A collection of nodes that belong to the subtree of the hierarchy tree rooted at the given parent.
See Also
Sample Graphs
Returns the nearest common ancestor of the given nodes in the hierarchy.
Remarks
node1 == node2
: Returns the parent ofnode1
/node2
.node1 is an ancestor of node2
: Returns the parent ofnode1
.node2 is an ancestor of node1
: Returns the parent ofnode2
.
Parameters
A map of options to pass to the method.
- node1 - LayoutNode
- One of the nodes to find the common ancestor for.
- node2 - LayoutNode
- The other node to find the common ancestor for.
Returns
- ↪LayoutNode?
- The nearest common ancestor node, or the virtual root if no common ancestor exists.
Sample Graphs
Returns the parent of the specified node.
Remarks
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node for which the parent is determined.
Returns
- ↪LayoutNode?
- The parent of the given node, or
null
if the node is top-level.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if the given node is
null
.
See Also
Returns the immediate child of a group node that represents the given node.
Remarks
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node for which to search for a representative.
- group - LayoutNode
- The group node to which the representative should belong.
Returns
- ↪LayoutNode?
- The representative node or
null
if no representative exists.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if the provided
node
isnull
.
Sample Graphs
Determines whether the specified group node has children as per the initial layout grouping.
Remarks
While normal nodes never have children, group nodes may contain one or more child nodes.
This method checks for children that were part of the group node when the LayoutGraphGrouping was initially created. Note that the current structure of the graph may have changed, so this method reflects only the original layout grouping and not any modifications made afterward.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to check if it has children.
Returns
- ↪boolean
true
if the node has children; otherwise,false
.
See Also
Determines whether the specified node has a parent.
Remarks
true
if the node is contained within a group node, otherwise false
.Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to check.
Returns
- ↪boolean
true
if the node has a parent; otherwise,false
.
Determines whether the specified node is a group node.
Remarks
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to check if it is a group node.
Returns
- ↪boolean
true
if the node is a group node ornull
; otherwise,false
.
See Also
Determines whether the given edge is a normal edge, as opposed to an edge that crosses any group node boundaries.
Remarks
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to check.
Returns
- ↪boolean
true
if the given edge is normal; otherwise,false
.
Disposes of all internal data structures held by this LayoutGraphGrouping instance and restores the original grouping structure.
Remarks
Sets the group node state of the specified node.
Remarks
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node whose group node state will be set.
- isGroup - boolean
- A boolean indicating whether the node should be a group node (
true
) or a normal node (false
).
Throws
Sets the parent for the specified node.
Remarks
parent
is null
, the node becomes a top-level node.Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node for which the parent will be set.
- parent - LayoutNode
- The group node to set as the parent of the node, or
null
to make the node a top-level node.
Throws
Static Methods
Replaces the current grouping hierarchy of the specified graph
with a new one, based on the current isGrouped and getParent relationships.
Remarks
The old grouping hierarchy should be restored by calling the restore method on the returned LayoutGraphGrouping instance when the copy is no longer needed.
This method can be useful for ensuring that grouping information can be modified or reset to its original state, allowing for easy disposal of intermediate changes to the hierarchy.
The original (replaced) grouping hierarchy does not recognize changes made by the newly created instance, whereas the created instance is aware of changes made directly to the original grouping.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph for which the hierarchy is copied.
Returns
- ↪LayoutGraphGrouping
- A new instance of LayoutGraphGrouping that represents the copied grouping hierarchy, and allows the restoration of the previous hierarchy.
Creates a read-only view of the current grouping hierarchy of the graph
.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The LayoutGraph to create a read-only view for.
Returns
- ↪LayoutGraphGrouping
- A new read-only LayoutGraphGrouping instance.
Temporarily hides the current grouping hierarchy of the graph
.
Remarks
After calling this method, isGrouped will return false
.
The hidden hierarchy can be restored by using the returned RestoreToken.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The LayoutGraph whose grouping hierarchy will be hidden.
Returns
- ↪RestoreToken
- A RestoreToken that can be used to restore the original hierarchy.
Determines whether the given graph is flat.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to check.
Returns
- ↪boolean
true
if the graph is flat; otherwise,false
.
See Also
Determines whether the given graph is grouped.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to check.
Returns
- ↪boolean
true
if the graph contains hierarchical information, otherwisefalse
.
See Also
replaceGrouping
(graph: LayoutGraph, isGroupNode?: function(LayoutNode):boolean, getParent?: function(LayoutNode):LayoutNode) : LayoutGraphGroupingReplaces the existing grouping hierarchy of the graph
with a new hierarchy, optionally using the provided isGroupNode
and getParent
callbacks to define the new hierarchy.
Remarks
The old grouping hierarchy can be restored by calling the restore method on the returned LayoutGraphGrouping instance.
If both isGroupNode
and getParent
are null
, the new grouping hierarchy will be empty and all nodes are top-level.
The original (replaced) grouping hierarchy does not recognize changes made by the newly created instance, whereas the created instance is aware of changes made directly to the original grouping.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The LayoutGraph whose grouping hierarchy will be replaced.
- isGroupNode - function(LayoutNode):boolean
- An optional callback to determine if a node should be treated as a group node.
Signature Details
function(arg: LayoutNode) : boolean
Encapsulates a method that has one parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg - LayoutNode
- The parameter of the method that this delegate encapsulates.
Returns
- boolean
- The return value of the method that this delegate encapsulates.
- getParent - function(LayoutNode):LayoutNode
- An optional callback that returns the parent node for a given node or
null
if the node is top-level.Signature Details
function(arg: LayoutNode) : LayoutNode
Encapsulates a method that has one parameters and returns a value of the type specified by theTResult
parameter.Parameters
- arg - LayoutNode
- The parameter of the method that this delegate encapsulates.
Returns
- LayoutNode
- The return value of the method that this delegate encapsulates.
Returns
- ↪LayoutGraphGrouping
- A new LayoutGraphGrouping instance that can restore the original hierarchy.