Represents a directed graph structure that contains layout information for its elements and to which layout algorithms (ILayoutAlgorithm) can be applied.
Remarks
A directed graph consists of a collection of "nodes" (represented by instances of LayoutNode) and "edges" (represented by instances of LayoutEdge) that connect pairs of nodes.
By default, the LayoutGraph contains layout information, such as the position and size of nodes (layout), and edge paths (pathPoints). Therefore, a LayoutGraph instance typically represents a visual drawing of a graph. If layout information is unnecessary, a more lightweight graph instance can be created using createStructureGraph, which only maintains the graph's structure without layout or labels. This is useful for performance-critical scenarios where only structural algorithms like shortestPath or pageRank are applied.
The class supports operations such as node and edge creation, deletion, access, and iteration through properties like nodes and edges. Additionally, nodes and edges can have associated labels, accessible via nodeLabels and edgeLabels.
Structural changes to the graph (such as adding or removing nodes/edges) must be made through the LayoutGraph instance, ensuring consistent graph manipulation.
In addition to basic node and edge management, the LayoutGraph supports the hierarchical grouping of nodes. Nodes can be designated as group nodes, which can contain other nodes, including other group nodes, forming a hierarchical structure. Methods such as createGroupNode, setParent, and setIsGroupNode allow the creation and manipulation of such groups.
Group nodes are useful for organizing complex graph structures, where nodes can be logically grouped together. The grouping hierarchy can be queried using methods like getChildren and getParent, enabling navigation and management of the nested structure. This functionality is particularly helpful in scenarios where visual grouping or compartmentalization of nodes is required.
Data access and manipulation are also supported via IMapper<K,V>, allowing custom data to be associated with nodes and edges.
Type Details
- yFiles module
- algorithms
See Also
Constructors
Instantiates an empty LayoutGraph object.
Properties
Provides an IEnumerable<T> of LayoutBends, allowing iteration over all bends of the edges of the graph.
Remarks
Gets the context associated with this graph.
Remarks
See Also
Gets a live view of all LayoutEdgeLabel instances contained in this graph.
Remarks
Property Value
Provides a dynamic IEnumerable<T> for LayoutEdges, allowing iteration over the edges contained in this instance.
Remarks
See Also
Gets a live view of all LayoutNodeLabel instances contained in this graph.
Property Value
Provides a dynamic IEnumerable<T> for LayoutNodes, allowing iteration over the nodes contained in this instance.
Remarks
See Also
Methods
addBend
(edge: LayoutEdge, x: number, y: number, reference?: LayoutBend, insertion?: RelativePosition) : LayoutBendCreates a new bend point for the given edge
with the specified coordinates.
Remarks
edge
already contains bend points and no reference
is specified, the new bend will be appended closest to the edge's target node, after all existing bends. If a reference
is provided, the new bend will be inserted relative to that reference bend, based on the insertion
.Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to which the bend will be added.
- x - number
- The x-coordinate of the new bend.
- y - number
- The y-coordinate of the new bend.
- reference - LayoutBend
- An optional existing bend adjacent to which the new bend will be created. If omitted, the bend is appended near the edge's target port.
- insertion - RelativePosition
Returns
- ↪LayoutBend
- The newly created LayoutBend instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
edge
does not belong to this graph, or ifx
ory
contain a Number.NaN value.
Creates a new label for the specified node
with the given dimensions.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to which the label will be added.
- width - number
- The width of the label's boundary.
- height - number
- The height of the label's boundary.
Returns
- ↪LayoutNodeLabel
- The newly created LayoutNodeLabel instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
does not belong to this graph, or ifwidth
orheight
contain a Number.NaN value.
Creates a new label for the specified node
with the given layout.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to which the label will be added.
- layout - IOrientedRectangle
- An IOrientedRectangle that defines the label's boundary and orientation.
Returns
- ↪LayoutNodeLabel
- The newly created LayoutNodeLabel instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
does not belong to this graph, or if thelayout
contains a Number.NaN value.
See Also
Creates a new label for the specified edge
with the given dimensions.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to which the label will be added.
- width - number
- The width of the label's boundary.
- height - number
- The height of the label's boundary.
Returns
- ↪LayoutEdgeLabel
- The newly created LayoutEdgeLabel instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
edge
does not belong to this graph, or ifwidth
orheight
contain a Number.NaN value.
Creates a new label for the specified edge
with the given layout.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to which the label will be added.
- layout - IOrientedRectangle
- An IOrientedRectangle that defines the label's boundary and orientation.
Returns
- ↪LayoutEdgeLabel
- The newly created LayoutEdgeLabel instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
edge
does not belong to this graph, or if thelayout
contains a Number.NaN value.
See Also
applyLayout
(layout: ILayoutAlgorithm, layoutData?: LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>)Runs an ILayoutAlgorithm synchronously on the given LayoutGraph, applying the given layoutData
.
Parameters
A map of options to pass to the method.
- layout - ILayoutAlgorithm
- The layout.
- layoutData - LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- The layout data.
See Also
changeEdge
(edge: LayoutEdge, newSource: LayoutNode, newTarget: LayoutNode, sourceReference?: LayoutEdge, sourceInsertion?: RelativePosition, targetReference?: LayoutEdge, targetInsertion?: RelativePosition)Redefines the endpoints of the specified edge, changing its source and target nodes.
Remarks
You can specify the order in which the edge should be inserted into the incoming/outgoing edges of the source/target nodes using the reference edge parameters.
The actual new source/target node will be determined based on the reference edges provided. If the reference edges are omitted, the edge will be appended to the lists of incoming and outgoing edges at the new source and target nodes, respectively.
For example, providing AFTER as sourceInsertion
will insert the edge after the sourceReference
edge when iterating through the outgoing edges at the source node.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to be modified.
- newSource - LayoutNode
- The new source node for the specified edge.
- newTarget - LayoutNode
- The new target node for the specified edge.
- sourceReference - LayoutEdge
- Optional. A reference edge for insertion at the new source node. If provided, its target must be the given node
newSource
. - sourceInsertion - RelativePosition
- targetReference - LayoutEdge
- Optional. A reference edge for insertion at the new target node. If provided, its target must be the given node
newTarget
. - targetInsertion - RelativePosition
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if the new source or target node is
null
. - Exception({ name: 'ArgumentError' })
- If the new source is not the source of the given
sourceReference
edge or the target node is not the target of the giventargetReference
edge.
See Also
Removes all nodes and edges from this graph.
Determines whether this graph contains the specified node.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to check for existence in the graph.
Returns
- ↪boolean
true
if this graph contains the specified node; otherwise,false
.
Determines whether this graph contains the specified edge.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to check for existence in the graph.
Returns
- ↪boolean
true
if this graph contains the specified edge; otherwise,false
.
Determines whether this graph contains the specified node label.
Parameters
A map of options to pass to the method.
- label - LayoutNodeLabel
- The node label to check for existence in the graph.
Returns
- ↪boolean
true
if this graph contains the specified node label; otherwise,false
.
Determines whether this graph contains the specified edge label.
Parameters
A map of options to pass to the method.
- label - LayoutEdgeLabel
- The edge label to check for existence in the graph.
Returns
- ↪boolean
true
if this graph contains the specified edge label; otherwise,false
.
Determines whether this graph contains the specified bend.
Parameters
A map of options to pass to the method.
- bend - LayoutBend
- The bend to check for existence in the graph.
Returns
- ↪boolean
true
if this graph contains the specified bend; otherwise,false
.
createCompositeLayoutData
(items: LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>…) : CompositeLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that combines the given instances of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.
Remarks
Parameters
A map of options to pass to the method.
- items - LayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- the layout data instances that should be combined into the created CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
Returns
- ↪CompositeLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that combines the given instances of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.
createEdge
(source: LayoutNode, target: LayoutNode, sourceReference?: LayoutEdge, sourceInsertion?: RelativePosition, targetReference?: LayoutEdge, targetInsertion?: RelativePosition) : LayoutEdgeCreates a new edge between the specified source
and target
nodes.
Remarks
sourceReference
and targetReference
parameters. If no reference edges are provided, the edge is added at the end of the lists of incoming/outgoing edges.Parameters
A map of options to pass to the method.
- source - LayoutNode
- The source node of the edge.
- target - LayoutNode
- The target node of the edge.
- sourceReference - LayoutEdge
- The reference edge for positioning at the source node.
- sourceInsertion - RelativePosition
- Defines whether the edge is inserted before or after
sourceReference
. - targetReference - LayoutEdge
- The reference edge for positioning at the target node.
- targetInsertion - RelativePosition
- Defines whether the edge is inserted before or after
targetReference
.
Returns
- ↪LayoutEdge
- The newly created edge.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
source
,target
, the source ofsourceReference
or the target oftargetReference
are not part of this graph.
Creates a new IMapper<K,V> that is valid for the edges in this graph.
Remarks
The implementation returned by this method can be used for any edge that is part of this LayoutGraph instance at any point in time, allowing safe modifications to the graph structure.
The returned implementation uses O(m)
memory at all times and provides true O(1)
read and write access for each edge.
To release the resources held by this map, disposeEdgeDataMap must be called.
Type Parameters
- TValue
- The type of the values to be associated with each edge.
Parameters
A map of options to pass to the method.
- fallbackValue - TValue
- A value of type
TValue
used as fallback if the registered IMapper<K,V> is indexed with a key which is not present.
Returns
- ↪IMapper<LayoutEdge,TValue>
- A newly created IMapper<Edge,TValue> instance that is valid for the edges in the graph.
See Also
createGenericLayoutData
() : GenericLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to easily associate custom item-specific data with a LayoutGraph.
Remarks
Returns
- ↪GenericLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of GenericLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to easily associate custom item-specific data with a
graph
.
Creates a new group node as a direct descendant of parent
using the optional specified layout.
Parameters
A map of options to pass to the method.
- parent - LayoutNode
- The parent node in the grouping hierarchy. If
null
, the new group node becomes a top-level group node. Use setParent to change the parent after creation. - layout - Rect
- The initial layout for the group node. If not specified, the node is positioned at (0, 0) with a size of 30x30.
Returns
- ↪LayoutNode
- The newly created group node.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
parent
is not contained in this graph.
See Also
Creates a new node as a direct descendant of parent
using the optional specified layout.
Parameters
A map of options to pass to the method.
- parent - LayoutNode
- The parent node in the grouping hierarchy. If
null
, the new node becomes a top-level node. To change the parent after creation, use setParent. - layout - Rect
- The initial layout for the node, including position and size. The layout is copied to the node's layout property. If not specified, the node's position is set to (0, 0), and its size is set to 30x30.
Returns
- ↪LayoutNode
- The newly created node.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
parent
is not a valid node in this graph or iflayout
contains invalid values (e.g., Number.NaN).
See Also
Creates a new node using the specified layout.
Parameters
A map of options to pass to the method.
- layout - Rect
- The layout to use for the node's initial position and size.
Returns
- ↪LayoutNode
- The newly created node.
See Also
Creates a new IMapper<K,V> that is valid for the nodes in this graph.
Remarks
The implementation returned by this method can be used for any node that is part of this LayoutGraph instance at any point in time, which means it is safe to modify the graph structure (add and remove nodes and edges) freely.
The returned implementation uses O(n)
memory at all times and provides true O(1)
read and write access for each node.
To release the resources held by this map, disposeNodeDataMap must be called.
Type Parameters
- TValue
- The type of the values to be associated with each node.
Parameters
A map of options to pass to the method.
- fallbackValue - TValue
- A value of type
TValue
used as fallback if the registered IMapper<K,V> is indexed with a key which is not present.
Returns
- ↪IMapper<LayoutNode,TValue>
- A newly created IMapper<Node,TValue> instance that is valid for the nodes in this graph.
See Also
Informs the graph that the specified IMapper<K,V> is no longer needed.
Remarks
This method should be used for IMapper<K,V> implementations obtained using createEdgeDataMap.
Calling this method will destroy the IMapper<K,V>, allowing associated resources to be freed. It is strongly recommended to dispose of all IMapper<K,V>s that are no longer needed using this method.
Type Parameters
- TValue
- The type of the values associated with the edges.
Parameters
A map of options to pass to the method.
- map - IMapper<LayoutEdge,TValue>
- The IMapper<K,V> to be disposed of.
Informs the graph that the specified IMapper<K,V> is no longer needed.
Remarks
This method should be used for IMapper<K,V> implementations obtained using createNodeDataMap.
Calling this method will destroy the IMapper<K,V>, allowing associated resources to be freed. It is strongly recommended to dispose of all IMapper<K,V>s that are no longer needed using this method.
Type Parameters
- TValue
- The type of the values associated with the nodes.
Parameters
A map of options to pass to the method.
- map - IMapper<LayoutNode,TValue>
- The IMapper<K,V> to be disposed of.
See Also
getBounds
(nodes?: IEnumerable<LayoutNode>, edges?: IEnumerable<LayoutEdge>, includeNodeLabels?: boolean, includeEdgeLabels?: boolean, includeMargins?: boolean) : RectReturns the bounds of the graph, optionally considering the specified nodes and edges, including node labels, edge labels, or node margins.
Parameters
A map of options to pass to the method.
- nodes - IEnumerable<LayoutNode>
- The nodes whose geometry contributes to the bounds. If
null
or omitted, all nodes of the graph will be considered. - edges - IEnumerable<LayoutEdge>
- The edges whose geometry contributes to the bounds. If
null
or omitted, all edges of the graph will be considered. - includeNodeLabels - boolean
- A flag indicating whether to include node labels in the bounds calculation.
- includeEdgeLabels - boolean
- A flag indicating whether to include edge labels in the bounds calculation.
- includeMargins - boolean
- A flag indicating whether to include node margins in the bounds calculation.
Returns
- ↪Rect
- The calculated bounds of the specified nodes and edges.
Returns the children of the specified group node.
Remarks
This method returns only the direct children, meaning all nodes that have node
as their parent, as determined by the getParent method.
To obtain all descendants of the node, consider using the getDescendants method.
To make a node a child of node
, utilize the setParent method.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The group node for which to return the children, or
null
if top-level nodes should be returned.
Returns
- ↪ILinkedItemEnumerable<LayoutNode>
- An enumerable collection of nodes that have
node
as their parent.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is not part of this graph.
See Also
getEdgesBetween
(source: LayoutNode, target: LayoutNode, directed?: boolean) : IEnumerable<LayoutEdge>Returns the edges between the specified source and target nodes.
Remarks
false
.Parameters
A map of options to pass to the method.
- source - LayoutNode
- The node from which the edges start.
- target - LayoutNode
- The node at which the edges end.
- directed - boolean
- Specifies whether to return only directed edges (default) or all edges regardless of direction.
Returns
- ↪IEnumerable<LayoutEdge>
- An enumerable collection of edges connecting the
source
to thetarget
.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if either
source
ortarget
is not contained in this graph.
See Also
Returns the parent node of a specified node, or null
if the node is a top-level node.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node for which to obtain the parent node.
Returns
- ↪LayoutNode?
- The parent node in this hierarchy, or
null
ifnode
is a top-level node.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is not part of this graph.
See Also
Determines whether the specified node is a group node.
Remarks
Group nodes are nodes that can have children, as identified by the getChildren method. While they may have children, this is not a requirement.
The virtual root of the grouping hierarchy is represented by null
, and top-level nodes are considered its 'children', thus making null
also a group node in this context.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to check for group status.
Returns
- ↪boolean
true
if the node is considered a group node; otherwise,false
.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is not part of this graph.
See Also
Reinserts a previously removed node back into this graph.
Remarks
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to be reinserted.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is already present in the graph.
See Also
Reinserts a previously removed edge back into this graph.
Remarks
The reinserted edge is appended to the sequence of edges in this graph. Its new position will likely differ from its position prior to removal, including the edge's positions in the incoming and outgoing edges of its source and target nodes.
Attempting to reinsert an edge whose source or target node is not present in the graph will result in an exception. Therefore, the corresponding endpoints must be reinserted first.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to be reinserted.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
edge
is already present in a graph, or if either the source or target ofedge
is not present in this graph.
See Also
Removes the specified edge from this graph.
Remarks
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to be removed.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
edge
is not present in this graph.
See Also
Removes the specified node from this graph.
Remarks
All edges connecting to the specified node will also be removed prior to the actual node removal.
If the node is intended to be temporarily hidden, it can be reinserted using the reinsert method.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to be removed.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is not present in this graph.
See Also
Removes the given bend
from the edge it belongs to and thus from this graph.
Parameters
A map of options to pass to the method.
- bend - LayoutBend
- The bend to remove.
Throws
- Exception({ name: 'ArgumentError' })
bend
is not in this graph.
Removes the given label
from its node.
Parameters
A map of options to pass to the method.
- label - LayoutNodeLabel
- The label to remove.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
label
is not present in this graph.
See Also
Removes the given label
from its edge.
Parameters
A map of options to pass to the method.
- label - LayoutEdgeLabel
- The label to remove.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
label
is not present in this graph.
See Also
Reverses the specified edge.
Remarks
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- The edge to be reversed.
See Also
Updates the group node status of a specified node.
Remarks
This method allows the modification of a node's status to indicate whether it is a group node, which can have children as indicated by getChildren.
When this method is used to turn a group node into a normal node, it must first be assured that the node
does not have any child nodes.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node for which to set the group node status.
- isGroup - boolean
- A boolean indicating whether to make the node a group node (
true
) or not (false
).
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
is not part of this graph or ifnode
still has child nodes
See Also
Sets the parent node for a specified node.
Remarks
Use null
as parent
to designate node
as a top-level node in the graph.
If parent
is not already a group node prior to this call, it will be automatically converted into a group node.
To retrieve the parent of a node, utilize the getParent method.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node to which a new parent will be assigned.
- parent - LayoutNode
- The parent group node to be assigned to
node
, ornull
to makenode
a top-level node.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if
node
orparent
are not part of this graph. - Exception({ name: 'InvalidOperationError' })
- Thrown if the
parent
is a descendant ofnode
or thenode
itself.
See Also
Sorts the list of LayoutEdge objects in this graph.
Parameters
A map of options to pass to the method.
- comparator - function(LayoutEdge, LayoutEdge):number
- A comparison delegate that defines the criteria for sorting the edges.
Signature Details
function(x: LayoutEdge, y: LayoutEdge) : number
Encapsulates a method that compares two objects.Parameters
- x - LayoutEdge
- The first object to compare.
- y - LayoutEdge
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
sortEdges
(inEdgeComparator: function(LayoutEdge, LayoutEdge):number, outEdgeComparator: function(LayoutEdge, LayoutEdge):number)Sorts incoming and outgoing edges at each node of the graph.
Remarks
null
, then the corresponding edges (i.e., incoming/outgoing) will not be sorted. This method sorts the order of edges as returned by inEdges and outEdges respectively.Parameters
A map of options to pass to the method.
- inEdgeComparator - function(LayoutEdge, LayoutEdge):number
- The comparison function used for sorting the incoming edges at each node. Set to
null
to skip sorting incoming edges.Signature Details
function(x: LayoutEdge, y: LayoutEdge) : number
Encapsulates a method that compares two objects.Parameters
- x - LayoutEdge
- The first object to compare.
- y - LayoutEdge
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
- outEdgeComparator - function(LayoutEdge, LayoutEdge):number
- The comparison function used for sorting the outgoing edges at each node. Set to
null
to skip sorting outgoing edges.Signature Details
function(x: LayoutEdge, y: LayoutEdge) : number
Encapsulates a method that compares two objects.Parameters
- x - LayoutEdge
- The first object to compare.
- y - LayoutEdge
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Sorts the list of LayoutNode objects in this graph.
Parameters
A map of options to pass to the method.
- comparator - function(LayoutNode, LayoutNode):number
- A comparison delegate that defines the criteria for sorting the nodes.
Signature Details
function(x: LayoutNode, y: LayoutNode) : number
Encapsulates a method that compares two objects.Parameters
- x - LayoutNode
- The first object to compare.
- y - LayoutNode
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Static Methods
createCopy
(graph: LayoutGraph, subNodes?: IEnumerable<LayoutNode>, subEdges?: IEnumerable<LayoutEdge>, structureGraph?: boolean) : LayoutGraphCreates a new LayoutGraph as a (partial) copy of the specified graph.
Remarks
Only the subgraph induced by the specified graph items will be copied to the new graph instance. If none are specified, the complete graph will be copied.
IMapper<K,V>s bound to the original graph context via NodeDataKey<TValue> and EdgeDataKey<TValue> will also be available in the copied graph context with the same keys. The original and copied IMapper<K,V>s share the same value references; values are not cloned.
LayoutGraphCopyData provides mappings between the copied and original graph items and can be retrieved from the context of the copied graph via graphCopyData.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to be (partially) copied.
- subNodes - IEnumerable<LayoutNode>
- Optional subset of the nodes in the
graph
to be copied. If omitted, all nodes will be copied. - subEdges - IEnumerable<LayoutEdge>
- Optional subset of the edges in the
graph
to be copied. If omitted, all edges for which the adjacent nodes have been copied will be included. - structureGraph - boolean
- Specifies whether the created graph should only represent a plain graph structure without layout information for its nodes and edges, similar to graphs created with createStructureGraph.
Returns
- ↪LayoutGraph
- A new LayoutGraph instance that is a (partial) copy of the specified graph.
See Also
Creates a graph that represents a plain graph structure without layout information for its nodes and edges.
Remarks
Creating an optimized graph is recommended for performance-critical applications where only the graph structure is relevant, and no ILayoutAlgorithm will be applied.
A graph created using this method cannot be processed by ILayoutAlgorithms. To create a LayoutGraph with layout capabilities, use the standard constructor.
Returns
- ↪LayoutGraph
- A new LayoutGraph instance representing a plain graph structure without layout information.