Central interface that models a graph which can be displayed in a canvas or GraphComponent.
ImplementsInheritance Hierarchy

Remarks

This interface can be used to query structural information, it also offers methods that change the structure of the graph and its attributes. Furthermore, a number of events will be triggered if the structure of the graph changes.

The graph is made up of collections of nodes and edges. Each node and edge can be associated with a number of labels and possibly ports to which edges connect. An edge connects to two ports and may consist of zero or more bends. The graph is treated as a directed graph, i.e. edges have a sourcePort and a targetPort. It is up to the algorithms and the visualization to possibly treat them as undirected.

This interface also provides support for hierarchically organized, i.e. grouped graphs. This means that nodes together with their connecting edges can be put into other nodes. The containing node is referred to as a "group node." To create and edit group nodes interactively use the GraphEditorInputMode as input mode and enable the grouping operations.

The edgesAt and edgesAt methods can be used to query adjacency information from the graph's structure.

Each element in the graph can be associated with a style that is used for the visualization of the element. Styles can be shared between multiple instances.

To associate data with the elements in the graph, code can make use of the tag property that all IModelItems provide. In order to associate more than one data element with the graph items, compound data objects can be used. Alternatively additional dictionaries can be used to associate arbitrary data sets with the items in this graph.

This interface provides a number of events that can be used to get notified for changes in the graph structure. These events are raised whenever the corresponding state change occurs, e.g. also when loading the graph from a file. If you are only interested in changes that are triggered interactively, you should subscribe to the corresponding events on the IInputMode implementations that implement the user interaction. Especially, you may not modify the graph structure in handlers for these event, e.g. try to prevent or undo the change that has raised the event.

Examples

New elements can be created either using defaults or with explicitly provided styles:

Creating graph elements
const graph = graphComponent.graph

// set defaults for newly created elements

// appearance of nodes
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.RECTANGLE,
  fill: Color.ORANGE,
})
// placement and appearance of node labels
graph.nodeDefaults.labels.layoutParameter = InteriorNodeLabelModel.CENTER
graph.nodeDefaults.labels.style = new LabelStyle({
  backgroundStroke: Stroke.BLACK,
  backgroundFill: Color.WHITE,
})

// create some nodes and edges
const node1 = graph.createNode()
const node2 = graph.createNode(
  new Rect(100, 0, 60, 40),
  new GroupNodeStyle(),
  'some tag',
)
const edge1 = graph.createEdge(
  node1,
  node2,
  new PolylineEdgeStyle({ targetArrow: new Arrow(ArrowType.STEALTH) }),
)

Existing elements can be changed using methods provided by IGraph:

Changing the graph
let index = 0
for (const node of graph.nodes) {
  if (node.labels.size === 0) {
    // if the node has no label, yet, add one
    graph.addLabel(node, `New label for node ${index}`)
  } else {
    // otherwise change the first label's text
    graph.setLabelText(
      node.labels.get(0),
      `Change text for node ${index}`,
    )
  }
  // set another style for the node
  graph.setStyle(
    node,
    new ShapeNodeStyle({
      shape: ShapeNodeShape.RECTANGLE,
      fill: Color.GREEN,
    }),
  )
  index++
}

The graph can be traversed along the edges with the help of a number of methods which provide adjacency information from the graph's structure.

Analyzing the graph structure
for (const node of graph.nodes) {
  const nodeName = node.labels.get(0).text
  // no predecessors: the node is a root
  if (!graph.predecessors(node).some()) {
    console.log(`Node ${nodeName} is a root.`)
  }
  // no successor: the node is a leaf
  if (!graph.successors(node).some()) {
    console.log(`Node ${nodeName} is a leaf.`)
  }
  // list all nodes which are linked to the current node
  for (const edge of graph.edgesAt(node)) {
    const otherNode = edge.opposite(node) as INode
    console.log(
      `Node ${nodeName} is linked to ${otherNode.labels.get(0).text}.`,
    )
  }
}

Finally, graph items can also be removed.

Removing graph elements and clearing the graph
// IMPORTANT: graph.nodes will throw exception if it is changed during iteration
// therefore we have to iterate over a copy of the node collection
// while we remove the nodes
const nodesToRemove = graph.nodes.toList()
for (const node of nodesToRemove) {
  graph.remove(node)
}

// clear the existing graph
graph.clear()

IGraph also provides support for hierarchically organized, i.e. grouped graphs. This means that nodes together with their connecting edges can be put into other nodes.

Grouping features overview
const graph = graphComponent.graph

// set the defaults for a newly created group node
graph.groupNodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ROUND_RECTANGLE,
  stroke: Stroke.AQUAMARINE,
  fill: null,
})
// create a group node
const groupNode = graph.createGroupNode()
// add existing nodes as children

graph.groupNodes(groupNode, [node1, node2, node3])

// whether the node is a group node
console.log(graph.isGroupNode(groupNode)) // true
console.log(graph.isGroupNode(node1)) // false

// get the parent of a node
console.log(graph.getParent(node1)) // groupNode
console.log(graph.getParent(groupNode)) // null

// get the children of a group node
const children = graph.getChildren(groupNode) // node1, node2, node3
console.log(children.size) // 3

See Also

The graph model with all relevant types and their relationships is presented in detail in the section The Graph Model.

More information on visual styles can be found in the section Visualization of Graph Elements.

Developer's Guide

API

Graph, INode, IEdge, IPort, ILabel, IBend

Members

Show:

Properties

Gets a live view of all bends contained in this IGraph.
readonly

See Also

API
bends
Gets a GraphDecorator instance for use with this graph.
Gets or sets the defaults for edges.
The settings that are obtained from the instance influence newly created elements only. Setting different defaults afterward does not influence existing elements.
abstract

Examples

Setting some defaults for newly created edges
// the defaults for edges can be set on the IEdgeDefaults instance
// which can be retrieved from the graph's EdgeDefaults property
graph.edgeDefaults.style = new PolylineEdgeStyle({
  stroke: Stroke.BLACK,
  targetArrow: new Arrow(ArrowType.STEALTH),
})

// the defaults for edge labels can be set on the ILabelDefaults instance
// found at the Labels property of the edge defaults
graph.edgeDefaults.labels.layoutParameter =
  new EdgeSegmentLabelModel().createParameterFromSource(0)
graph.edgeDefaults.labels.style = new LabelStyle()

See Also

Developer's Guide
Gets a live view of all edge labels contained in this IGraph.
Gets a view of the edges contained in this graph.

This is a live view of the edges that always represents the current state of the graph. The same reference will be returned for each invocation.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the edges via a foreach loop.

readonlyabstract

Examples

Iterating over all edges in the graph
for (const edge of graph.edges) {
  // ...
}

See Also

Developer's Guide
Gets the IFoldingView instance associated with this IGraph or null if none is associated with it.
This convenience method uses the lookup of the IGraph to obtain the IFoldingView.
readonly

See Also

Developer's Guide
API
FoldingManager, createFoldingView
Creates a GroupingSupport instance for the graph.
GroupingSupport provides less frequently used methods for grouped graphs, such as methods for analyzing and walking the grouping hierarchy.
readonly

See Also

Developer's Guide
Gets or sets the defaults for group nodes.
The settings that are obtained from the instance influence newly created elements only. Setting different defaults afterwards does not influence existing elements.
abstract

Examples

Defaults for newly created group nodes
graph.groupNodeDefaults.style = new GroupNodeStyle()
graph.groupNodeDefaults.labels.layoutParameter =
  InteriorNodeLabelModel.TOP

It is possible to set a new INodeDefaults instance here, as well. That way, it is possible to share the same defaults for group nodes and normal nodes:

Sharing node defaults
// use the same defaults for nodes and group nodes
graph.groupNodeDefaults = graph.nodeDefaults
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ELLIPSE,
  fill: Color.YELLOW,
})

or to share only the label defaults:

Sharing label defaults only
// use the different defaults for nodes and group nodes
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ELLIPSE,
  fill: Color.YELLOW,
})
graph.groupNodeDefaults.style = new GroupNodeStyle({
  tabFill: Color.LIGHT_BLUE,
})
// but use the same label defaults
graph.groupNodeDefaults.labels = graph.nodeDefaults.labels
graph.nodeDefaults.labels.style = new LabelStyle({
  backgroundFill: Color.DARK_GRAY,
})
graph.nodeDefaults.labels.layoutParameter = ExteriorNodeLabelModel.BOTTOM

See Also

Developer's Guide
Gets a view of the labels contained in this graph.

This is a live view of the labels that always represents the current state of the graph. The same reference will be returned for each invocation.

Note that even though labels can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the labels in your own list, if possible. This is not necessary for the first or last element or when iterating over the labels via a foreach loop.

readonlyabstract

Examples

labels provides a view of all labels in the graph.

for (const label of graph.labels) {
  // ...
}

To retrieve only labels at nodes on can either filter labels or use method nodeLabels. The following examples are equivalent:

const nodeLabels = graph.labels
  .filter((l) => l.owner instanceof INode)
  .toList()
const nodeLabels2 = graph.nodeLabels.toList()

The same applies for labels at edges and ports:

const edgeLabels = graph.labels
  .filter((l) => l.owner instanceof IEdge)
  .toList()
const edgeLabels2 = graph.edgeLabels.toList()
const portLabels = graph.labels
  .filter((l) => l.owner instanceof IPort)
  .toList()
const portLabels2 = graph.portLabels.toList()

The following example shows how to get a list of all nodes with labels:

const labeledNodes = graph.nodeLabels.map((l) => l.owner).toList()

See Also

API
nodeLabels, edgeLabels, portLabels
Gets or sets the defaults for normal nodes.
The settings that are obtained from the instance influence newly created elements only. Setting different defaults afterwards does not influence existing elements.
abstract

Examples

The IGraph implementations provided by yFiles for HTML always provide a pre-configured instance in this property. New defaults can be set by changing its properties.

Setting some defaults for newly created nodes
// the defaults for nodes can be set on the INodeDefaults instance
// which can be retrieved from the graph's node defaults property
graph.nodeDefaults.size = new Size(50, 30)
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ELLIPSE,
  fill: Color.YELLOW,
})

// the defaults for node labels can be set on the ILabelDefaults instance
// found at the Labels property of the node defaults
graph.nodeDefaults.labels.layoutParameter = InteriorNodeLabelModel.CENTER
graph.nodeDefaults.labels.style = new LabelStyle()

// the defaults for node ports can be set on the IPortDefaults instance
// found at the Ports property of the node defaults
graph.nodeDefaults.ports.autoCleanUp = false
graph.nodeDefaults.ports.locationParameter =
  FreeNodePortLocationModel.CENTER

It is possible to set a new INodeDefaults instance here, as well. That way, it is possible to share the same defaults for group nodes and normal nodes:

Sharing node defaults
// use the same defaults for nodes and group nodes
graph.groupNodeDefaults = graph.nodeDefaults
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ELLIPSE,
  fill: Color.YELLOW,
})

or to share only the label defaults:

Sharing label defaults only
// use the different defaults for nodes and group nodes
graph.nodeDefaults.style = new ShapeNodeStyle({
  shape: ShapeNodeShape.ELLIPSE,
  fill: Color.YELLOW,
})
graph.groupNodeDefaults.style = new GroupNodeStyle({
  tabFill: Color.LIGHT_BLUE,
})
// but use the same label defaults
graph.groupNodeDefaults.labels = graph.nodeDefaults.labels
graph.nodeDefaults.labels.style = new LabelStyle({
  backgroundFill: Color.DARK_GRAY,
})
graph.nodeDefaults.labels.layoutParameter = ExteriorNodeLabelModel.BOTTOM

or to keep pre-configured defaults:

Providing different defaults
const darkTheme = new NodeDefaults()
darkTheme.labels.style = new LabelStyle({
  backgroundFill: 'black',
  backgroundStroke: 'white',
  textFill: 'light-gray',
})
darkTheme.style = new ShapeNodeStyle({ fill: 'black', stroke: 'white' })

const classicTheme = new NodeDefaults()
classicTheme.labels.style = new LabelStyle({
  backgroundFill: 'white',
  backgroundStroke: 'black',
  textFill: 'black',
})
classicTheme.style = new ShapeNodeStyle({
  fill: 'orange',
  stroke: 'white',
})
graph.nodeDefaults = useDarkTheme ? darkTheme : classicTheme

See Also

Developer's Guide
Gets a live view of all node labels contained in this IGraph.
Gets a view of the nodes contained in this graph.

This is a live view of the nodes that always represents the current state of the graph. The same reference will be returned for each invocation.

Note that even though nodes can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the nodes in your own list, if possible. This is not necessary for the first or last element or when iterating over the nodes via a foreach loop.

readonlyabstract

Examples

Iterating over all nodes in the graph
for (const node of graph.nodes) {
  // ...
}
Note that nodes is an IListEnumerable<T> which extends IEnumerable<T>.
Iterating over the blue nodes in the graph
for (const node of graph.nodes.filter(
  (n) => n.style instanceof ShapeNodeStyle && n.style.fill === Color.BLUE,
)) {
  // ...
}

graph.nodes
  .filter(
    (n) =>
      n.style instanceof ShapeNodeStyle && n.style.fill === Color.BLUE,
  )
  .forEach((node) => {
    // ...
  })

See Also

Developer's Guide
Gets a live view of all port labels contained in this IGraph.
Gets a view of the ports contained in this graph.

This is a live view of the ports that always represents the current state of the graph. The same reference will be returned for each invocation.

Note that even though ports can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the ports in your own list, if possible. This is not necessary for the first or last element or when iterating over the ports via a foreach loop.

readonlyabstract

Examples

Iterating over all ports in the graph
for (const port of graph.ports) {
  // ...
}
Gets or sets the tag object associated with this item instance.
The tag is an optional user-defined object which can be used to store arbitrary data related to this item. The item itself just provides the storage for the object.
abstract

Property Value

The user object associated with this item instance.

Examples

Setting a model item's tag
owner.tag = newTag
Getting the tag from a model item
const tag = owner.tag

See Also

Tags are presented in detail in the section The Graph Model.
Developer's Guide

Defined in

ITagOwner.tag
Gets the UndoEngine instance associated with this IGraph or null if none is associated with it.
This convenience method uses the lookup of the IGraph to obtain the UndoEngine.
readonly

See Also

Developer's Guide
Gets or sets whether or not the UndoEngine used for this instance should be enabled.

Methods

Adds a bend at the given index to the given edge using the coordinates provided.

The added instance will be returned.

To retrieve the current bends of an edge, use bends

abstract

Parameters

edge: IEdge
The edge to which the bend will be added.
location: Point
The coordinates to use for the newly created bend. To change the location after the bend has been added, use setBendLocation.
index?: number
The index for the newly added bend; A negative value (which is the default) indicates that the bend should be appended to the end of the list of bends.

Return Value

IBend
A newly created live bend

Throws

Exception ({ name: 'ArgumentError' })
edge is not in this graph, or location contains one or more NaN values.

Examples

Bends can be added either as the last bend or at a given index

Adding a bend to an edge.
const bend = graph.addBend(edge, new Point(x, y))
Inserting a bend at position 1.
const anotherBend = graph.addBend(edge, new Point(x, y), 1)

To add multiple points as bends at once, another method, addBends, can be used instead:

Adding multiple bends at once
graph.addBends(edge, [
  new Point(10, 10),
  new Point(20, 20),
  new Point(30, 30),
])

See Also

Developer's Guide
API
remove, setBendLocation, bends
Adds bends with the given locations to the end of the bend list of the given edge.

Parameters

edge: IEdge
The edge to add the bends to.
locations: IEnumerable<Point>
The locations of the bends.

Throws

Exception ({ name: 'ArgumentError' })
edge is not in this graph.
Exception ({ name: 'ArgumentError' })
locations contains one or more NaN values.

See Also

API
addBend
Add a label to the given node or edge using the text as the initial label text and label model parameter, style, and tag.
To add labels to IStripes in ITables, you have to use the ITable's addLabel method instead. Even though stripes are ILabelOwners, they don't actually belong to the graph.
abstract

Parameters

owner: ILabelOwner
The node, edge, or port to add the label to. Note that the owner cannot be changed after the label has been added.
text: string
The initial text of the label. To change the text after the label has been added, use setLabelText.
layoutParameter?: ILabelModelParameter
The label model parameter instance to use. If omitted the default parameter will be set. To change the parameter after the label has been added, use setLabelLayoutParameter.
style?: ILabelStyle
The style to use for the label. If omitted the default style will be set. To change the style after the label has been added, use setStyle.
preferredSize?: Size
The initial values to use for the preferredSize. If omitted size will be determined automatically. To change the preferred size after the label has been added, use setLabelPreferredSize.
tag?: ILabel['tag']
The initial tag to assign.

Return Value

ILabel
The newly created label.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph or preferredSize contains one or more NaN values.

Examples

// add label with given text, default style, and default placement
// and determine the preferred size automatically

const label1 = graph.addLabel(node, 'Some Label')

// add label with given text, placement, style, size, and tag (user object)
const label2 = graph.addLabel(
  node,
  'Some Label',
  InteriorNodeLabelModel.CENTER,
  new LabelStyle(),
  new Size(10, 150),
  userObject,
)

// add label with given text and style but default placement
// and determine the preferred size automatically
const label3 = graph.addLabel({
  owner: node,
  text: 'Some Label',
  style: new LabelStyle(),
})
In most cases it is recommended to let yFiles determine the preferred size automatically:
// add label with given text, placement, style, and tag (user object)
// however, determine the size automatically (recommended in  most cases)
const label4 = graph.addLabel({
  owner: node,
  text: 'Some Label',
  layoutParameter: InteriorNodeLabelModel.CENTER,
  style: new LabelStyle(),
  tag: userObject,
})

See Also

Developer's Guide
API
label-added, setLabelText, text, setLabelLayoutParameter, layoutParameter, setStyle, style, setLabelPreferredSize, preferredSize, owner, labels, labels, labels, labels, tag
Add a port to the given port owner using the location model parameter, style, and tag.

The locationParameter determines the location of the port.

An implementation may throw a NotSupportedError if the type of the owner instance does not support adding ports.

abstract

Parameters

owner: IPortOwner
the owner to add the port instance to.
locationParameter?: IPortLocationModelParameter
the parameter to use for the port to determine its location. If omitted, the default parameter will be set. To change the parameter after the port has been added, use setPortLocationParameter.
style?: IPortStyle
the style to initially assign to the style property. If omitted, the default style will be set, e.g. VOID_PORT_STYLE. To change the style after the port has been added, use setStyle.
tag?: IPort['tag']
the initial tag to assign.

Return Value

IPort
the newly created port

Throws

Exception ({ name: 'NotSupportedError' })
If this instance cannot add a port to owner.
Exception ({ name: 'ArgumentError' })
owner is not in this graph.

Examples

Adding a port
// add a port at x,y with default style
const port1 = graph.addPortAt(node, new Point(x, y))

const portStyle = new ShapePortStyle({
  shape: ShapeNodeShape.ELLIPSE,
  renderSize: new Size(3, 3),
})

// add a port at x,y with the given style and tag (user object)
const port2 = graph.addPortAt(
  node,
  new Point(x, y),
  portStyle,
  userObject,
)

The port's position is determined by the locationParameter. Method addPortAt places the port at the given (absolute) location.

Adding a port at an (absolute) location
// add a port at x,y with default style
const port1 = graph.addPortAt(node, new Point(x, y))

const portStyle = new ShapePortStyle({
  shape: ShapeNodeShape.ELLIPSE,
  renderSize: new Size(3, 3),
})

// add a port at x,y with the given style and tag (user object)
const port2 = graph.addPortAt(
  node,
  new Point(x, y),
  portStyle,
  userObject,
)

Method addRelativePort adds the port at the given location relative to the given node's top left corner.

Adding a port at a relative location
// add a port at the center of the node with the given style and tag (user object)
const port = graph.addRelativePort(
  node,
  new Point(node.layout.width / 2, node.layout.height / 2),
)

See Also

Developer's Guide
API
port-added, setPortLocationParameter, locationParameter, setStyle, style, ports, ports, tag
Add a port to the given port owner using the absolute coordinates as the new initial position of the port anchor.

Parameters

owner: IPortOwner
The owner to add the port instance to.
location: Point
The location to use for the port to determine its location. This is passed to the createDefaultPortLocationParameter method to determine the initial IPortLocationModelParameter to use.
style?: IPortStyle
The style to initially assign to the style property, e.g. VOID_PORT_STYLE.
tag?: IPort['tag']
The initial tag to assign.

Return Value

IPort
The newly created port

Throws

Exception ({ name: 'NotSupportedError' })
If this instance cannot add a port to owner.
Exception ({ name: 'ArgumentError' })
owner is not in this graph.
Exception ({ name: 'ArgumentError' })
location contains one or more NaN values.

See Also

Developer's Guide
API
addPort, setPortLocation
Adds a new port to the graph at the node using a location that is relative to the center of the node.
The port style for the newly-created port is taken from the graph's defaults. The location parameter is determined by delegating to addPortAt.

Parameters

node: INode
The owner of the port.
relativeLocation: Point
The offset of the port relative to the center of the layout.

Return Value

IPort
The newly added port instance.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.
Exception ({ name: 'ArgumentError' })
relativeLocation contains one or more NaN values.

See Also

API
addPort, addPortAt, setRelativePortLocation
Uses the UndoEngine from the IGraph's ILookup to add a unit.

Parameters

undoName: string
The name of the undo operation.
redoName: string
The name of the redo operation.
undo: function
The undo action.
redo: function
The redo action.

See Also

Developer's Guide
Method to adjust the size of a group node.
This will resize the group node bounds such that the node requires the least amount of space. If the node does not have any children, its bounds will be left unchanged. This will also respect any INodeSizeConstraintProviders for INodes that are available in the lookup of the groupNode.

Parameters

groupNode: INode
The group node to adjust the size of.

Throws

Exception ({ name: 'ArgumentError' })
groupNode is not in this graph.

Examples

How to create create a group node with children
// create a group node
const group = graph.createGroupNode()
// add some child nodes
graph.createNode(group, new Rect(10, 10, 30, 30))
graph.createNode(group, new Rect(50, 10, 30, 30))
graph.createNode(group, new Rect(50, 50, 30, 30))
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(group)
AdjustGroupNodeLayout only affects the node it is called for. To properly adjust all of its ancestors, too, one has to adjust all of them from the given node to the root:
for (const nodeToAdjust of graph.groupingSupport.getAncestors(
  innermostGroup,
)) {
  graph.adjustGroupNodeLayout(nodeToAdjust)
}

See Also

Developer's Guide
API
IGroupBoundsCalculator, INodeSizeConstraintProvider, calculateMinimumEnclosedArea, enlargeGroupNode, enlargeAllGroupNodes
Adjusts the preferredSize property of a label to fit the suggested size of its ILabelStyleRenderer.
This implementation uses the style's renderer for the label to determine the preferred rendering size. This is useful after the label's content or style have been changed.

Parameters

label: ILabel
The label to adjust the size for.

See Also

API
autoAdjustPreferredSize, setLabelPreferredSize, preferredSize, calculateLabelPreferredSize
Runs an ILayoutAlgorithm synchronously on the given graph.
For more control over how to apply a layout use LayoutExecutor.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

layout: ILayoutAlgorithm
The layout.
layoutData?: LayoutData<INode, IEdge, ILabel, ILabel>
The layout data.
stopDuration?: TimeSpan
the maximum runtime for the layout calculation before it is automatically stopped.
cancelDuration?: TimeSpan
the maximum runtime for the layout calculation before it is automatically canceled.
portAdjustmentPolicies?: ItemMapping<IPort, PortAdjustmentPolicy>
The policy that specifies how port locations should be adjusted after a layout has been calculated.
portPlacementPolicies?: ItemMapping<IPort, PortPlacementPolicy>
The policy that specifies how ports should be placed by the layout algorithm.
portLabelPolicies?: ItemMapping<ILabel, PortLabelPolicy>
Sets how ILabels at IPorts should be treated by the layout algorithm.
anchoredItems?: ItemMapping<IModelItem, LayoutAnchoringPolicy>
Specifies which part of the items should be used to anchor the graph during layout.
labelPlacementPolicies?: ItemMapping<ILabel, LabelPlacementPolicy>
Sets how ILabels should be placed by the layout algorithm.
nodeComparator?: function(INode, INode): number
A comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations.
edgeComparator?: function(IEdge, IEdge): number
A comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations.

See Also

Developer's Guide
API
LayoutExecutor, applyLayoutAnimated
Starts an ICompoundEdit that records graph changes and custom undo units in a single compound unit.

This method can be used to bracket several undo units. All edits added to the queue after this call and before a call to cancel or commit will be placed into the queue as a single block.

Client code needs to make sure that either the cancel or commit method is called on the returned instance.

Parameters

undoName: string
The undo name for the compound edit.
redoName: string
The redo name for the compound edit.

Return Value

ICompoundEdit
The handle to stop the recording by calling cancel or commit on it.

See Also

Developer's Guide
Starts an ICompoundEdit that uses the memento design pattern to record changes to the items in the given items collection.

This method uses the IMementoSupport returned by the provider to record the state of an item at the beginning of the edit and when commit is called to create an IUndoUnit that can revert the item to the recorded state and back. If no provider is given, this method uses the IMementoSupport returned by the lookup implementation of the items to record the state of an item at the beginning of the edit and when commit is called to create an IUndoUnit that can revert the item to the recorded state and back.

Calling this method will immediately enqueue an IUndoUnit into the undo queue. Subsequent additions to the queue will be added after the created instance, even if they are added to the queue before the commit method has been called.

Parameters

undoName: string
The undoName of the IUndoUnit that will be placed into the undo queue after commit has been called.
redoName: string
The redoName of the IUndoUnit that will be placed into the undo queue after commit has been called.
items: IEnumerable<T>
The items that will be changed after this call and before the call to commit.
provider?: function(T): IMementoSupport
The provider for the IMementoSupport of the items. if the provider returns null for a given item, changes to this item are not being recorded.

Return Value

ICompoundEdit
An implementation of the ICompoundEdit interface whose commit or cancel methods need to be called after the items have been modified.

Examples

The following is an example implementation of an item that is being managed using IMementoSupport:

A sample business object that implements ILookup to return IMementoSupport
class Employee extends BaseClass<ILookup>(ILookup) implements ILookup {
  _name: string
  position: string
  age: number

  constructor(name: string, position: string, age: number) {
    super()
    this._name = name
    this.position = position
    this.age = age
  }

  get name(): string {
    return this._name
  }

  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
  lookup<T extends any>(type: Constructor<any>): T | null {
    if (type === IMementoSupport) {
      return new EmployeeMementoSupport() as T
    }
    return null
  }
}

A collection of items from this type can then be watched using the following code snippet:

Using an ICompoundEdit
const edit = graph.beginEdit(
  undoName,
  redoName,
  listWithMyEmployeesToWatch,
)

// changes to the employees are done here

if (!success) {
  // if we don't want the changes to be done after all, then we need to cancel the edit
  edit.cancel()
}

Alternatively, when using a specific provider, consider the following examples. The following is an example implementation of an item that is being managed using IMementoSupport:

A sample business object
class SimpleEmployee {
  private readonly _name: string
  position: string
  age: number

  constructor(name: string, position: string, age: number) {
    this._name = name
    this.position = position
    this.age = age
  }

  get name(): string {
    return this._name
  }
}

A collection of items from this type can then be watched using the following code snippet, using the provider to return an appropriate IMementoSupport implementation:

Using an ICompoundEdit
const edit = graph.beginEdit(
  undoName,
  redoName,
  listWithMyEmployeesToWatch,
  (item) => new EmployeeMementoSupport(),
)

// changes to the employees are done here

if (!success) {
  // if we don't want the changes to be done after all, then we need to cancel the edit
  edit.cancel()
}

Implementing the IMementoSupport interface is quite unrestrained, the type of the state returned by getState method can by anything as long as the applyState and stateEquals methods can deal with it:

Sample implementation of IMementoSupport
class EmployeeMementoSupport
  extends BaseClass<IMementoSupport>(IMementoSupport)
  implements IMementoSupport
{
  getState(subject: any): EmployeeState | null {
    if (subject instanceof Employee) {
      return new EmployeeState(subject.position, subject.age)
    }
    return null
  }

  applyState(subject: any, state: any): void {
    if (subject instanceof Employee && state instanceof EmployeeState) {
      subject.position = state.position
      subject.age = state.age
    }
  }

  stateEquals(state1: any, state2: any): boolean {
    if (
      state1 instanceof EmployeeState &&
      state2 instanceof EmployeeState
    ) {
      return (
        state1.position === state2.position && state1.age === state2.age
      )
    }
    return state1 === state2
  }
}

class EmployeeState {
  _position: string
  _age: number

  constructor(position: string, age: number) {
    this._position = position
    this._age = age
  }

  get position(): string {
    return this._position
  }

  get age(): number {
    return this._age
  }
}

In summary, use this concept when you want to track the state of items during certain operations for undo/redo. This is efficient if it's easier to handle an item's state than the changes to the item themselves. If you want to focus on the changes or on certain events, you should use custom IUndoUnit

See Also

Developer's Guide
API
IMementoSupport
Calculates the preferred size of a label with the given properties.

Parameters

owner: ILabelOwner
The item that will own the label.
text: string
The text.
layoutParameter?: ILabelModelParameter
The label model parameter.
style?: ILabelStyle
The label style.
tag?: ILabel['tag']
The tag for the label.

Return Value

Size
The size as calculated by the ILabelStyleRenderer.

See Also

API
setLabelPreferredSize, preferredSize, adjustLabelPreferredSize
Clears the graph, removing all items in proper order.

See Also

Developer's Guide
API
remove
Removes all bends from the given edge.
The edge must be part of this graph at the time of the invocation. This will trigger the corresponding events.

Parameters

owner: IEdge
the edge whose bends will be removed

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

API
remove, bend-removed, bends
Removes all labels from the given ILabelOwner, which can be an INode, IEdge, or IPort.
The owner must be part of this graph at the time of the invocation. This will trigger the corresponding events.

Parameters

labelOwner: ILabelOwner
the owner whose labels will be removed

Throws

Exception ({ name: 'ArgumentError' })
labelOwner is not in this graph.

See Also

API
remove, label-removed, labels
Removes all ports from the given IPortOwner, which can be an INode or an IEdge.
The owner must be part of this graph at the time of the invocation. This will trigger the corresponding events.

Parameters

portOwner: IPortOwner
the owner whose ports will be removed

Throws

Exception ({ name: 'ArgumentError' })
portOwner is not in this graph.

See Also

API
remove, port-removed, ports
Determines whether this graph contains the specified item.
abstract

Parameters

item: IModelItem
The item.

Return Value

boolean
true if this graph contains the specified item; otherwise, false.

Examples

const node = graph.createNode()

// an element which is created in a graph is contained in that graph
console.log(graph.contains(node)) // true

// an element which is created in a graph is not contained in another graph
console.log(anotherGraph.contains(node)) // false

graph.remove(node)
// an element which is removed is not contained in the graph anymore
console.log(graph.contains(node)) // false
Returns an instance of CompositeLayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that combines the given layout data instances.
The generic type arguments of the created layout data are compatible with instances of IGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

items: LayoutData<INode, IEdge, ILabel, ILabel>
the layout data instances that should be combined into the created CompositeLayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>

Return Value

CompositeLayoutData<INode, IEdge, ILabel, ILabel>
an instance of CompositeLayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that combines the given layout data instances.
Creates the label layout parameter for a given ILabelOwner.
This implementation uses the label defaults for the graph to obtain the parameter instance.

Parameters

owner: ILabelOwner
The item that is the owner of the label in question.

Return Value

ILabelModelParameter
The default label layout parameter to use for newly created labels at the item.

See Also

API
getLayoutParameterInstance, getLabelDefaults
Creates a location model parameter for a newly created IPort at the owner that matches the location.
If location is null, this method uses the port defaults for the owner to obtain the location parameter.

Parameters

owner: IPortOwner
The owner of the port.
location?: Point
The location in the world coordinate system where the port should be added.

Return Value

IPortLocationModelParameter
Either a location model parameter that matches the location, or the default parameter to use for the IPortOwner as returned by getLocationParameterInstance.

Throws

Exception ({ name: 'ArgumentError' })
location contains one or more NaN values.

See Also

API
createParameter, getPortDefaults
Creates and returns an edge that connects to the given port instances.
The ports must be part of this graph at the time of the invocation. The edge will be a part of this graph after the method returns. This will trigger the corresponding events.
abstract

Parameters

sourcePort: IPort
The source port the created edge will connect to. To change the source port after the edge has been created, use setEdgePorts.
targetPort: IPort
The target port the created edge will connect to. To change the target port after the edge has been created, use setEdgePorts.
style?: IEdgeStyle
The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set. To change the style after the edge has been created, use setStyle.
tag?: IEdge['tag']
The initial value of the tag that will be assigned to the new edge.

Return Value

IEdge
the newly created edge instance

Examples

Creating edges between ports
const node1 = graph.createNodeAt(new Point(0, 0))
const port1 = graph.addPort(node1)
const node2 = graph.createNodeAt(new Point(100, 0))
const port2 = graph.addPort(node2)

// Create an edge between port1 and port2 with default style
const edge1 = graph.createEdge(port1, port2)

// Create an edge between port1 and port2 with the given style and tag
const edge2 = graph.createEdge(
  port1,
  port2,
  new PolylineEdgeStyle({ targetArrow: new Arrow(ArrowType.STEALTH) }),
  tag,
)

See Also

API
edge-created, edgeDefaults, setEdgePorts, sourcePort, targetPort, setStyle, style, tag
Creates and returns an edge that connects to the given node instances using the given style instance.
The nodes must be part of this graph at the time of the invocation, and an implementation can choose the IPort instances to which the edge will be connected. The edge will be a part of this graph after the method returns. This will trigger the corresponding events.
abstract

Parameters

source: INode
The source node the created edge will connect to. It is up to the implementation to decide which port to use at the given node. An implementation may create a new port of the edge. To change the source port after the edge has been created, use setEdgePorts.
target: INode
The target node the created edge will connect to. It is up to the implementation to decide which port to use at the given node. An implementation may create a new port of the edge. To change the target port after the edge has been created, use setEdgePorts.
style?: IEdgeStyle
The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set. To change the style after the edge has been created, use setStyle.
tag?: IEdge['tag']
The initial value of the tag that will be assigned to the new edge.

Return Value

IEdge
the newly created edge instance

Examples

Creating edges between source and target node
const node1 = graph.createNodeAt(new Point(0, 0))
const node2 = graph.createNodeAt(new Point(100, 0))

// Create an edge between node1 and node2 with default style
const edge1 = graph.createEdge(node1, node2)

// Create an edge between node1 and node2 with the given style and tag
const edge2 = graph.createEdge(
  node1,
  node2,
  new PolylineEdgeStyle({ targetArrow: new Arrow(ArrowType.STEALTH) }),
  tag,
)

See Also

Developer's Guide
API
edge-created, edgeDefaults, setEdgePorts, sourcePort, targetPort, setStyle, style, tag
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to easily associate custom item-specific data with an IGraph.
The generic type arguments of the created layout data are compatible with instances of IGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Return Value

GenericLayoutData<INode, IEdge, ILabel, ILabel>
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 using the provided style and layout as a child of parent.

The group node will be a direct descendant of parent.

To create group nodes interactively use the GraphEditorInputMode as input mode and enable the grouping operations.

abstract

Parameters

parent?: INode
The node to use as the parent in the grouping hierarchy or null if the new node should become a top-level node. To change the parent after the group node has been created, use setParent.
layout?: Rect
The initial layout to use for the new node. If omitted the node will be placed with its top left corner at 0,0 and the default size. To change the layout after the group node has been created, use setNodeLayout.
style?: INodeStyle
The style to use for the new node. If omitted the default style will be set. To change the style after the group node has been created, use setStyle.
tag?: INode['tag']
The tag to assign to the INode.

Return Value

INode
The newly created group node.

Throws

Exception ({ name: 'ArgumentError' })
The layout contains one or more NaN values.

Examples

// create a group node top level (without parent) at 0,0 with default size and style
const node1 = graph.createGroupNode()

// create a group node as child of the given parent node at 0,0 with default size and style
const node2 = graph.createGroupNode(parent)

// create a group node as child of the given parent node with the given layout, style, and tag (user object)
const node3 = graph.createGroupNode(
  parent,
  new Rect(x, y, width, height),
  new ShapeNodeStyle(),
  userObject,
)

// create a group node as child of the given parent node at 0,0 with default size and style and the given tag
const node4 = graph.createGroupNode({ parent, tag: userObject })
The newly created node is a group node from the beginning. As such, it takes its defaults from groupNodeDefaults:
graph.nodeDefaults.style = new ShapeNodeStyle()
graph.groupNodeDefaults.style = new GroupNodeStyle()

const group = graph.createGroupNode()
// the newly created node is a group node from the beginning
console.log(graph.isGroupNode(group)) // true
// the newly created node is created with the GroupNodeDefaults
console.log(group.style instanceof GroupNodeStyle) // true

See Also

Developer's Guide
API
createNode, setParent, getParent, setNodeLayout, layout, setStyle, style, tag, groupNodeDefaults
Creates and returns a node using the specified values for the initial geometry, style, and tag.
The node will be a part of this graph after the method returns. This will trigger the corresponding events.
abstract

Parameters

layout: Rect
The layout to use initially. The values will be copied to the node's layout field. To change the layout after the node has been created, use setNodeLayout.
style?: INodeStyle
The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set. To change the style after the node has been added, use setStyle.
tag?: INode['tag']
The initial value of the tag that will be assigned to the new node.

Return Value

INode
A newly created node instance

Throws

Exception ({ name: 'ArgumentError' })
layout contains one or more NaN values.

Examples

Creating a node with different parameters
// Create a node with default style and size at 0,0
const node1 = graph.createNode()

// create a node with the given layout and the default style
const node2 = graph.createNode(new Rect(x, y, width, height))

// create a node with the given layout, style, and tag (user object)
const node3 = graph.createNode(
  new Rect(x, y, width, height),
  new ShapeNodeStyle(),
  userObject,
)

// Create a node with default size at 0,0 with the given style
const node4 = graph.createNode({ style: new ShapeNodeStyle() })

// create a node at the given location with default style and size
const node5 = graph.createNodeAt(new Point(x, y))

// create a node at the given location with default size and the given style and tag
const node6 = graph.createNodeAt(
  new Point(x, y),
  new ShapeNodeStyle(),
  userObject,
)

See Also

API
node-created, nodeDefaults, setNodeLayout, layout, setStyle, style, tag
Creates a new ordinary node as a direct descendant of parent using the given layout and style.
abstract

Parameters

parent?: INode
The node to use as the parent in the grouping hierarchy or null if the new node should become a top-level node. To change the parent after the group node has been created, use setParent.
layout?: Rect
The layout to use initially. The values will be copied to the node's layout field. If omitted the default size will be set and the node's top left corner will be placed at 0,0. To change the layout after the group node has been created, use setNodeLayout.
style?: INodeStyle
The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set.
tag?: INode['tag']
The tag to assign to the INode.

Return Value

INode
The newly created node.

Throws

Exception ({ name: 'ArgumentError' })
parent is not in this graph, or layout contains one or more NaN values.

Examples

Creating nodes in a grouping hierarchy
// create a node top level (without parent) at 0,0 with default size and style
const node1 = graph.createNode()

// create a node as child of the given parent node at 0,0 with default size and style
const node2 = graph.createNode(parent)

// create a node as child of the given parent node with the given layout, style, and tag (user object)
const node3 = graph.createNode(
  parent,
  new Rect(x, y, width, height),
  new ShapeNodeStyle(),
  userObject,
)

// create a node as child of the given parent node at 0,0 with default size and style and the given tag
const node4 = graph.createNode({ parent, tag: userObject })

See Also

Developer's Guide
API
setParent, getParent, setNodeLayout, layout, setStyle, style, tag, createNode, createGroupNode, nodeDefaults
Creates and returns a node using the specified initial center location and style, as well as the tag.
The node will be a part of this graph after the method returns. This will trigger the corresponding events.

Parameters

location: Point
the initial coordinates of the center of the node's layout property
style?: INodeStyle
The style instance that will be assigned to the newly created instance. This is done by reference.
tag?: INode['tag']
The initial value of the tag that will be assigned to the new node.

Return Value

INode
A newly created node instance

Throws

Exception ({ name: 'ArgumentError' })
location contains one or more NaN values.

See Also

Developer's Guide
API
node-created, createNode, setNodeCenter
Calculates the number of edges at the given IPortOwner for this graph.
Note that an edge that is both incoming and outgoing will be counted twice.

Parameters

owner: IPortOwner
The port owner to count the degree of.

Return Value

number
The number of edges that are incident to the port owner.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

Developer's Guide
API
edgesAt
Calculates the number of edges at the given IPort for this graph.
Note that an edge that is both incoming and outgoing will be counted twice.

Parameters

port: IPort
The port owner to count the degree of.

Return Value

number
The number of edges that are incident to the port.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

See Also

Developer's Guide
API
edgesAt
Returns an IListEnumerable<T> for the incoming, the outgoing, or all edges adjacent to the given port, depending on type.

If the given type is ALL, adjacent self-loops will appear twice in the returned enumerable. For INCOMING or OUTGOING, self-loops will only appear once.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases, it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the adjacent edges via a foreach loop.

abstract

Parameters

port: IPort
The port to check. The returned edges will have this port as a sourcePort or targetPort.
type?: AdjacencyTypes
The type of adjacency to consider. Default is ALL, which includes both incoming and outgoing edges.

Return Value

IListEnumerable<IEdge>
An enumeration of all adjacent edges of the given type (incoming, outgoing, or both).

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

Examples

Iterating over all edges at port 1
for (const edge of graph.edgesAt(port1)) {
  console.log(edge)
  // edge1, edge4, edge5
}
Iterating over the outgoing edges at port 1
for (const edge of graph.edgesAt(port1, AdjacencyTypes.OUTGOING)) {
  console.log(edge) // edge4, edge5
}
// is the same as
for (const edge of graph.outEdgesAt(port1)) {
  console.log(edge) // edge4, edge5
}

See Also

Developer's Guide
API
inEdgesAt, outEdgesAt, AdjacencyTypes
Returns an IListEnumerable<T> for the incoming, the outgoing, or all edges adjacent to the given port owner, depending on type.

If the given type is ALL, adjacent self-loops will appear twice in the returned enumerable. For INCOMING or OUTGOING, self-loops will only appear once.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases, it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the adjacent edges via a foreach loop.

abstract

Parameters

owner: IPortOwner
The port to check. The returned edges will have one of the ports at this owner as a sourcePort or targetPort.
type?: AdjacencyTypes
The type of adjacency to consider. Default is ALL, which includes both incoming and outgoing edges.

Return Value

IListEnumerable<IEdge>
An enumeration of all adjacent edges of the given type (incoming, outgoing, or both).

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

Examples

Iterating over all edges at the center node
for (const edge of graph.edgesAt(center)) {
  console.log(edge)
  // edge1, edge4, edge5, edge2, edge3, edge6
}

Note that the result is built by iterating over the edges at each port, in this example these are first the edges at port 1 (1, 4, 5), then the edges at port 2 (2, 3, 6)

Iterating over the outgoing edges at the center node
for (const edge of graph.edgesAt(center, AdjacencyTypes.OUTGOING)) {
  console.log(edge) // edge4, edge5, edge6
}
// is the same as
for (const edge of graph.outEdgesAt(center)) {
  console.log(edge) // edge4, edge5, edge6
}

See Also

Developer's Guide
API
inEdgesAt, outEdgesAt, AdjacencyTypes
Returns an enumerable over the children of the provided node.

This method returns the direct children, i.e. all nodes that have node as their parent. To get all descendants method getDescendants can be used.

To make a node a child of node, use setParent or create the node directly as a child with createNode

abstract

Parameters

node: INode
The node for which to return the children or null if the top-level nodes should be returned.

Return Value

IListEnumerable<INode>
All nodes that have node as their parent.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

Examples

// create a group node which contains three existing nodes
const groupNode = graph.groupNodes([node1, node2, node3])

// get the children of a group node
const children = graph.getChildren(groupNode) // node1, node2, node3
const childCount = children.size // 3

See Also

Developer's Guide
API
getDescendants, setParent, getParent, createNode
Finds an edge that connects from and to in the given graph.

Parameters

from: IPortOwner
The sourcePort owner of the edge to find.
to: IPortOwner
The targetPort owner of the edge to find.

Return Value

IEdge
An edge that satisfies the constraints or null, if none was found.

Throws

Exception ({ name: 'ArgumentError' })
from or to are not in this graph.

See Also

API
edgesAt
Finds an edge that connects sourcePort and targetPort in the given graph.

Parameters

sourcePort: IPort
The sourcePort of the edge to find.
targetPort: IPort
The targetPort of the edge to find.

Return Value

IEdge
An edge that satisfies the constraints or null, if none was found.

Throws

Exception ({ name: 'ArgumentError' })
sourcePort or targetPort are not in this graph.

See Also

API
edgesAt
Returns the edges between the specified source and target owners.
By default, only directed edges are returned. To retrieve all edges (both incoming and outgoing), set directed to false.

Parameters

source: IPortOwner
The owner from which the edges start.
target: IPortOwner
The owner at which the edges end.
directed?: boolean
Specifies whether to return only directed edges (default) or all edges regardless of direction.

Return Value

IEnumerable<IEdge>
An enumerable collection of edges connecting the source to the target.
Returns the edges between the specified source and target ports.
By default, only directed edges are returned. To retrieve all edges (both incoming and outgoing), set directed to false.

Parameters

sourcePort: IPort
The port from which the edges start.
targetPort: IPort
The port at which the edges end.
directed?: boolean
Specifies whether to return only directed edges (default) or all edges regardless of direction.

Return Value

IEnumerable<IEdge>
An enumerable collection of edges connecting the sourcePort to the targetPort.
Gets the ILabelDefaults for a given ILabelOwner in the context of the graph.

Parameters

owner: ILabelOwner
The item that the label defaults are returned for. If this is a group node, the groupNodeDefaults's label defaults will be returned, otherwise the nodeDefaults or edgeDefaults labels will be returned.

Return Value

ILabelDefaults
Appropriate ILabelDefaults for the provided owner.
Returns the parent node of the node or null if node is a top-level node.
abstract

Parameters

node: INode
The node to retrieve the parent node for.

Return Value

INode
The parent node in this hierarchy or null if node is a top-level node.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

Examples

// create a group node
const groupNode = graph.createGroupNode()

// set groupNode as parent of node1
graph.setParent(node1, groupNode)

// get the parent of a node
const node1Parent = graph.getParent(node1) // groupNode
const groupParent = graph.getParent(groupNode) // null

See Also

Developer's Guide
API
setParent, getChildren
Gets the IPortDefaults for a given IPortOwner in the context of the graph.

Parameters

owner: IPortOwner
The item that the label defaults are returned for. If this is a group node, the groupNodeDefaults's port defaults will be returned, otherwise the nodeDefaults or edgeDefaults ports will be returned.

Return Value

IPortDefaults
Appropriate IPortDefaults for the provided owner.
Groups the nodes in children into the provided group node.
The parent needs to be a group node at the time of the invocation. This operation is basically the same as calling setParent for each node in children whose parent is not part of the set.
How to create add multiple children to a group node
// create some nodes
const children = []
for (let i = 0; i < 5; i++) {
  children.push(graph.createNode())
}
// create a group node
const parent = graph.createGroupNode()
// add the nodes as children to the group
graph.groupNodes(parent, children)
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(parent)

Parameters

parent: INode
The node to use as the parent in the grouping hierarchy.
children: IEnumerable<INode>
The children to group into the group node.

Throws

Exception ({ name: 'ArgumentError' })
parent or one of children is not in this graph.

See Also

Developer's Guide
API
groupNodes, setParent, createGroupNode
Groups the nodes in children into a newly created group node.
The group node will be created at the common ancestor level of all nodes in children.
How to create a new group node with multiple children
// create some nodes
const children = []
for (let i = 0; i < 5; i++) {
  children.push(graph.createNode())
}
// create a group node and add the given nodes as children
const group = graph.groupNodes(children)
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(group)

Parameters

children: IEnumerable<INode>
The children to group into the new group node.
style?: INodeStyle
The style for the new group node
tag?: any
The group node's tag

Return Value

INode
The newly created group node.

Throws

Exception ({ name: 'ArgumentError' })
One of children is not in this graph.

See Also

Developer's Guide
API
getNearestCommonAncestor, groupNodes
Calculates the number of incoming edges at the given IPortOwner for this graph.

Parameters

owner: IPortOwner
The port owner to count the incoming edges of.

Return Value

number
The number of edges that have the port owner as their target port's owner.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

Developer's Guide
API
edgesAt
Calculates the number of incoming edges at the given IPort for this graph.

Parameters

port: IPort
The port to count the incoming edges of.

Return Value

number
The number of edges that have the port as their target port.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

See Also

Developer's Guide
API
edgesAt
Returns the incoming edges at the given owner.

This method delegates to edgesAt using INCOMING.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the incoming edges via a foreach loop.

Parameters

owner: IPortOwner
The owner of the edges.

Return Value

IListEnumerable<IEdge>
An enumerable for the edges.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

Developer's Guide
API
edgesAt, outEdgesAt
Returns the incoming edges at the given port.

This method delegates to edgesAt using INCOMING.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the incoming edges via a foreach loop.

Parameters

port: IPort
The port of the edges.

Return Value

IListEnumerable<IEdge>
An enumerable for the edges.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

See Also

Developer's Guide
API
edgesAt, outEdgesAt
Causes the displays-invalidated event to be triggered.
This method may be called by client code to invalidate all views of the graph that have registered with the displays-invalidated event. Views that need to be informed if non-structural changes have been made to the graph should register with the corresponding event.
abstract
Returns whether the given node is a group node.
Group nodes are nodes which can have children. They may have children but do not necessarily have to.
abstract

Parameters

node: INode
The node to check.

Return Value

boolean
Whether the node is considered a group node.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

Examples

How to set or query a node's group node state
// create a node in the graph
const node1 = graph.createNode()
// query whether it is a group node
const node1IsGroupNode = graph.isGroupNode(node1) // false

// create a group node in the graph
const node2 = graph.createGroupNode()
// query whether it is a group node
const node2IsGroupNode = graph.isGroupNode(node2) // true

// convert node1 into a group node
graph.setIsGroupNode(node1, true)
// convert node2 into a normal, i.e. non-group, node
graph.setIsGroupNode(node2, false)

// group is a group node with a child
const group = graph.groupNodes([node1])
// you cannot convert a group node with a child into a non-group node
graph.setIsGroupNode(group, false) // throws exception!

See Also

Developer's Guide
API
getChildren, setIsGroupNode
Returns an instance that implements the given type or null.
Typically, this method will be called to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile-time constraints. An instance implementing this method is not required to return non-null implementations for the types, nor does it have to return the same instance any time. Also, it depends on the type and context whether the instance returned stays up to date or needs to be re-obtained for further use.
abstract

Parameters

type: Constructor<T>
the type for which an instance shall be returned

Return Value

T
an instance that is assignable to the type or null

See Also

Developer's Guide

Defined in

ILookup.lookup
Enumerates the neighbors of a given INode.
Neighbors are calculated by going through all ports and inspecting the edges at these ports, collecting the opposites.

Parameters

node: INode
The node.

Return Value

IEnumerable<INode>
An enumerable over all neighbors.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

See Also

Developer's Guide
API
edgesAt
Calculates the number of outgoing edges at the given IPortOwner for this graph.

Parameters

owner: IPortOwner
The port owner to count the outgoing edges of.

Return Value

number
The number of edges that have the port owner as their source port's owner.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

Developer's Guide
API
edgesAt
Calculates the number of outgoing edges at the given IPort for this graph.

Parameters

port: IPort
The port to count the outgoing edges of.

Return Value

number
The number of edges that have the port as their source port.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

See Also

Developer's Guide
API
edgesAt
Returns the outgoing edges at the given owner.

This method delegates to edgesAt using OUTGOING.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the outgoing edges via a foreach loop.

Parameters

owner: IPortOwner
The owner of the edges.

Return Value

IListEnumerable<IEdge>
An enumerable for the edges.

Throws

Exception ({ name: 'ArgumentError' })
owner is not in this graph.

See Also

Developer's Guide
API
edgesAt, inEdgesAt
Returns the outgoing edges at the given port.

This method delegates to edgesAt using OUTGOING.

Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the outgoing edges via a foreach loop.

Parameters

port: IPort
The owner of the edges.

Return Value

IListEnumerable<IEdge>
An enumerable for the edges.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

See Also

Developer's Guide
API
edgesAt, inEdgesAt
Enumerates the predecessors of a given INode.
Predecessors are calculated by going through all ports and inspecting the incoming edges at these ports, collecting the sourcePort owners.

Parameters

node: INode
The node.

Return Value

IEnumerable<INode>
An enumerable over all predecessors.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

See Also

Developer's Guide
Removes the given item from this graph.

The item must be a part of this graph.

If the item is a node, the node-removed event will be triggered. This will remove all adjacent edges and their corresponding ports in proper order before the node will be removed. Also, this will trigger the removal of all labels owned by this instance.

If the item is an edge, the edge-removed event will be triggered. Also, this will trigger the removal of all labels and bends owned by this instance. An implementation may decide to remove the corresponding ports from the node if no other edge connects to them after the given edge has been removed. The implementations provided by yFiles do so according to the value set to autoCleanUp in their IPortDefaults.

If the item is a bend, the bend-removed event will be triggered.

If the item is a port, the port-removed event will be triggered. This will also remove all edges that are currently connected to the port and all labels and bends owned by this instance.

If the item is a label, the label-removed event will be triggered.

abstract

Parameters

item: IModelItem
the item to be removed from this graph instance

Throws

Exception ({ name: 'ArgumentError' })
item is not in this graph.

Examples

Removing an item from the graph
const node = graph.createNode()
console.log(graph.contains(node)) // true
graph.remove(node)
console.log(graph.contains(node)) // false
Removing an item removes its dependent items, too
const node = graph.createNode()
const label = graph.addLabel(node, 'Test')
console.log(graph.contains(label)) // true
graph.remove(node)
console.log(graph.contains(label)) // false
Removing items from their collections
// IMPORTANT: graph.nodes will throw exception if it is changed during   iteration
// therefore, we have to iterate over a copy of the node collection
// while we remove the nodes
const nodesToRemove = graph.nodes.toList()
for (const node of nodesToRemove) {
  graph.remove(node)
}

See Also

Developer's Guide
This also reverses the bends by clearing them and reinserting them in reverse order if there is more than one bend.

Parameters

edge: IEdge
The edge to reverse.

Throws

Exception ({ name: 'ArgumentError' })
edge is not in this graph.

See Also

Developer's Guide
API
setEdgePorts
Modifies the location of the given bend.
To query a bend location, use location.
abstract

Parameters

bend: IBend
the bend whose location is to be modified
location: Point
the new location of the bend

Throws

Exception ({ name: 'ArgumentError' })
bend is not in this graph, or location contains one or more NaN values.

Examples

Setting the location of a bend
graph.setBendLocation(bend, new Point(x, y))
Getting the location of a bend
const location = bend.location

See Also

Developer's Guide
API
addBend, location
Sets the source and target ports of the given edge to the new values.

This will trigger an edge-ports-changed event if source or target ports differ from the current ones. Both ports and the edge must belong to the current graph instance.

An implementation may decide to remove the corresponding ports if no other edge connects to them after the given edge has its source or target port changed. The implementations provided by yFiles do so according to the value set to autoCleanUp in their IPortDefaults.

To query the current source and target ports, you can use the sourcePort and targetPort properties.

abstract

Parameters

edge: IEdge
The edge to change the ports.
sourcePort: IPort
The new source port instance.
targetPort: IPort
The new target port instance.

Throws

Exception ({ name: 'ArgumentError' })
Either edge, sourcePort, or targetPort are not in this graph.

Examples

Setting source and target port of an edge
graph.setEdgePorts(edge, newSourcePort, newTargetPort)
Getting the target node of an edge
const sourcePort = edge.sourcePort
Getting the target port of an edge
const targetPort = edge.targetPort

See Also

Developer's Guide
API
sourcePort, targetPort
Changes whether the given node is a group node or not.

Group nodes are nodes which can have children. They may not necessarily have to, however.

Attempting to set a node to the non-group-node-status while it has children at the same time will result in an InvalidOperationError.

abstract

Parameters

node: INode
The node to set the group node status for.
isGroupNode: boolean
Whether to make the node a group node.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.
Exception ({ name: 'InvalidOperationError' })
node is null or currently has children and isGroupNode is false.

Examples

How to set or query a node's group node status
// create a node in the graph
const node1 = graph.createNode()
// query whether it is a group node
const node1IsGroupNode = graph.isGroupNode(node1) // false

// create a group node in the graph
const node2 = graph.createGroupNode()
// query whether it is a group node
const node2IsGroupNode = graph.isGroupNode(node2) // true

// convert node1 into a group node
graph.setIsGroupNode(node1, true)
// convert node2 into a normal, i.e. non-group, node
graph.setIsGroupNode(node2, false)

// group is a group node with a child
const group = graph.groupNodes([node1])
// you cannot convert a group node with a child into a non-group node
graph.setIsGroupNode(group, false) // throws exception!

See Also

Developer's Guide
API
getChildren, isGroupNode
Sets the label model parameter for the given label.
To query the label layout parameter, use layoutParameter.
abstract

Parameters

label: ILabel
The label.
layoutParameter: ILabelModelParameter
The new parameter.

Throws

Exception ({ name: 'ArgumentError' })
label is not in this graph, or layoutParameter cannot be used for label.

Examples

Setting the layout parameter of a label
graph.setLabelLayoutParameter(label, InteriorNodeLabelModel.CENTER)
Obtaining the layout parameter of a label
const parameter = label.layoutParameter

See Also

Developer's Guide
API
layoutParameter
Sets the preferred size of the label.
To query the label preferred size, use preferredSize.
abstract

Parameters

label: ILabel
The label.
preferredSize: Size
The new preferred size.

Throws

Exception ({ name: 'ArgumentError' })
label is not in this graph or preferredSize contains one or more NaN values.

Examples

Setting the preferred size of a label
graph.setLabelPreferredSize(label, new Size(width, height))
Obtaining the preferred size of a label
const size = label.preferredSize

See Also

Developer's Guide
API
preferredSize
Sets the label text of the given label.
To query the label text, use text.
abstract

Parameters

label: ILabel
the label to modify
text: string
the new text of the label

Throws

Exception ({ name: 'ArgumentError' })
label is not in this graph.

Examples

Setting the text of a label
graph.setLabelText(label, 'Some Text')
Obtaining the text of a label
const text = label.text

See Also

Developer's Guide
API
text
Sets the center of a node to the given world coordinates.
This implementation delegates to setNodeLayout

Parameters

node: INode
The node to recenter.
center: Point
The new center coordinates of the node in the world coordinate system.

Throws

Exception ({ name: 'ArgumentError' })
center contains one or more NaN values.

See Also

Developer's Guide
API
setNodeLayout
Sets the layout of the given node to the new value.
To query the node layout, use layout. To place the node center at an absolute location, you can use the setNodeCenter convenience method.
abstract

Parameters

node: INode
a live node that belongs to this graph
layout: Rect
The new layout of the node to assign to its layout.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph, or layout contains one or more NaN values.

Examples

Setting the layout of a node
graph.setNodeLayout(node, new Rect(x, y, width, height))
Obtaining the layout of a node
const layout = node.layout

See Also

Developer's Guide
API
layout, layout, setNodeCenter
Sets the parent node for a given node.

Use null as parent to make node a top-level node for this graph.

This method does not move or enlarge the parent to enclose its new node. Developers have to take care to adjust the node layout after grouping, e.g. by calling adjustGroupNodeLayout.

If parent is not a group node before the call it will be converted into one.

To query the parent of a node, use getParent.

abstract

Parameters

node: INode
The node to assign a new parent.
parent: INode
The parent group node to assign to node or null to make node a top-level node.

Throws

Exception ({ name: 'ArgumentError' })
Either node or parent is not in this graph.

Examples

// create a group node
const groupNode = graph.createGroupNode()

// set groupNode as parent of node1
graph.setParent(node1, groupNode)

// get the parent of a node
const node1Parent = graph.getParent(node1) // groupNode
const groupParent = graph.getParent(groupNode) // null

See Also

Developer's Guide
API
getParent
Tries to set the absolute coordinates of the given port to the given values.
For full control over the placement of the ports, the setPortLocationParameter method should be used instead. This implementation will use the port's locationParameter's model to obtain a new IPortLocationModelParameter via the createParameter method. This might result in the port using a different location, because the model might not support parameters that result in the given location. This will also trigger an invalidateDisplays call.

Parameters

port: IPort
The port to modify
location: Point
the new absolute coordinates of the port

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.
Exception ({ name: 'ArgumentError' })
location contains one or more NaN values.

See Also

API
addPort, setPortLocationParameter, setRelativePortLocation
Sets a new IPortLocationModelParameter for the given port.
To query the port location parameter, use locationParameter. To place the port at an absolute resp. relative location, you can use the setPortLocation resp. setRelativePortLocation convenience methods.
abstract

Parameters

port: IPort
The port to modify
locationParameter: IPortLocationModelParameter
The new parameter that determines the coordinates of the port

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph, or locationParameter cannot be used for port.

Examples

Setting the location parameter to a port
graph.setPortLocationParameter(port, FreeNodePortLocationModel.CENTER)
Obtaining the location parameter from a port
const parameter = port.locationParameter

See Also

Developer's Guide
API
locationParameter, setPortLocation, setRelativePortLocation
Tries to set the location of the port relative to its owner if the owner is a node.
If the port is not owned by a node that is part of this graph, this method will throw an ArgumentError. This method will delegate to setPortLocation.

Parameters

port: IPort
the port
relativeLocation: Point
the new coordinate offsets relative to the center of the node's layout's center.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph or has no owner.
Exception ({ name: 'ArgumentError' })
relativeLocation contains one or more NaN values.

See Also

API
layout, setPortLocation, setPortLocationParameter
Assigns the given style instance by reference to the node.

Style instances can be shared.

To query the node style, use style.

Styles are automatically converted between WebGL and SVG rendering modes. Due to differences in feature sets, conversion may not be exact. For better control, apply styles specific to the rendering mode or use a WebGLNodeStyleDecorator style when switching render modes.

abstract

Parameters

node: INode
The node that will be assigned the new style
style: INodeStyle
The style instance that will be assigned to the node.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

Examples

Setting the style of a node
graph.setStyle(node, new ShapeNodeStyle())
Obtaining the style of a node
const style = node.style

See Also

Developer's Guide
API
style, node-style-changed
Assigns the given style instance by reference to the label.

Style instances can be shared.

To query the label style, use style.

Styles are automatically converted between WebGL and SVG rendering modes. Due to differences in feature sets, conversion may not be exact. For better control, apply styles specific to the rendering mode or use a WebGLLabelStyleDecorator style when switching render modes.

abstract

Parameters

label: ILabel
The label that will be assigned the new style
style: ILabelStyle
The style instance that will be assigned to the label.

Throws

Exception ({ name: 'ArgumentError' })
label is not in this graph.

Examples

Setting the style of a label
graph.setStyle(label, new LabelStyle())
Obtaining the style of a label
const style = label.style

See Also

Developer's Guide
API
style, label-style-changed
Assigns the given style instance by reference to the edge.

Style instances can be shared.

To query the edge style, use style.

Styles are automatically converted between WebGL and SVG rendering modes. Due to differences in feature sets, conversion may not be exact. For better control, apply styles specific to the rendering mode or use a WebGLEdgeStyleDecorator style when switching render modes.

abstract

Parameters

edge: IEdge
The edge that will be assigned the new style
style: IEdgeStyle
The style instance that will be assigned to the edge.

Throws

Exception ({ name: 'ArgumentError' })
edge is not in this graph.

Examples

Setting the style of an edge
graph.setStyle(edge, new PolylineEdgeStyle())
Obtaining the style of an edge
const style = edge.style

See Also

Developer's Guide
API
style, edge-style-changed
Assigns the given style instance by reference to the port.

Style instances can be shared.

To query the port style, use style.

abstract

Parameters

port: IPort
The port that will be assigned the new style
style: IPortStyle
The style instance that will be assigned to the port.

Throws

Exception ({ name: 'ArgumentError' })
port is not in this graph.

Examples

Setting the style of a port
graph.setStyle(port, portStyle)
Obtaining the style of a port
const style = port.style

See Also

Developer's Guide
API
style, port-style-changed
Enumerates the successors of a given INode.
Successors are calculated by going through all ports and inspecting the outgoing edges at these ports, collecting the targetPort owners.

Parameters

node: INode
The node.

Return Value

IEnumerable<INode>
An enumerable over all successors.

Throws

Exception ({ name: 'ArgumentError' })
node is not in this graph.

See Also

Developer's Guide

Events

Occurs when a bend has been added to an edge in this graph.
This event is intended to provide notification of low level changes in the graph structure. Please use the bend-created event if you are interested only in bend creation events that result from user interaction.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the bend creation that has triggered this event.

Properties of

ItemEventArgs<IBend>
item: T
Gets the item that is the subject of the event.

See Also

Developer's Guide
API
addBend, bend-created
Occurs when the location of a bend has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

function(IBend, Point, this): void

See Also

Developer's Guide
API
setBendLocation
Occurs when a bend has been removed from an edge in this graph.

This event will be triggered, too, if an edge has been removed from the graph, for each of the bends that belonged to the edge.

This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in bend removal events that result from user interaction.

You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the bend removal that has triggered this event.

Properties of

BendEventArgs
index: number
Gets the former index of the bend in the bends list.
item: IBend
Gets the item that is the subject of the event.
owner: IEdge
Gets the owner of the bend that owned the bend before the event happened.

See Also

Developer's Guide
API
remove, deleted-item
Occurs when the tag of a bend has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<IBend, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag
Occurs when the graph has changed visually and the display should be updated to reflect the changes.
This event is invoked with EMPTY per default.

Properties of

EventArgs
Occurs when an edge has been created.
This event is intended to provide notification of low level changes in the graph structure. Please use the edge-created event if you are interested only in edge creation events that result from user interaction.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the edge creation that has triggered this event.

Properties of

ItemEventArgs<IEdge>
item: T
Gets the item that is the subject of the event.

See Also

Developer's Guide
API
createEdge, edge-created
Occurs when an edge had its sourcePort or targetPort changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

EdgeEventArgs
item: IEdge
Gets the item that is the subject of the event.
sourcePort: IPort
Gets the source port the edge was connected to before the event happened.
sourcePortOwner: IPortOwner
Gets the owner of the source port the edge was connected to before the event happened.
targetPort: IPort
Gets the target port the edge was connected to before the event happened.
targetPortOwner: IPortOwner
Gets the owner of the target port the edge was connected to before the event happened.

See Also

Developer's Guide
API
setEdgePorts
Occurs when an edge has been removed.

This event will be triggered, too, prior to a node removal.

This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in edge removal events that result from user interaction.

You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the edge removal that has triggered this event.

Properties of

EdgeEventArgs
item: IEdge
Gets the item that is the subject of the event.
sourcePort: IPort
Gets the source port the edge was connected to before the event happened.
sourcePortOwner: IPortOwner
Gets the owner of the source port the edge was connected to before the event happened.
targetPort: IPort
Gets the target port the edge was connected to before the event happened.
targetPortOwner: IPortOwner
Gets the owner of the target port the edge was connected to before the event happened.

See Also

Developer's Guide
API
remove, deleted-item
Occurs when an edge style has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setStyle
Occurs when the tag of an edge has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<IEdge, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag
Occurs when the tag of the graph has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<IGraph, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag
Occurs if the group node status of a node has changed.
You may not modify the graph in the event handler for this event.

Properties of

NodeEventArgs
isGroupNode: boolean
Gets whether the node was a group node before this event.
item: INode
Gets the item that is the subject of the event.
parent: INode
Gets the parent of the node before this event.

See Also

Developer's Guide
Occurs when a label has been added to this graph instance.
This event is intended to provide notification of low level changes in the graph structure. Please use the label-added event if you are interested only in label creation events that result from user interaction.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the label creation that has triggered this event.

Properties of

ItemEventArgs<ILabel>
item: T
Gets the item that is the subject of the event.

See Also

Developer's Guide
API
addLabel, label-added
Occurs when the model parameter of a label has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setLabelLayoutParameter
Occurs when the preferred size of a label has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setLabelPreferredSize
Occurs when a label has been removed from this graph instance.

This event will also be triggered, prior to the removal of the owner of the label.

This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in label removal events that result from user interaction.

You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the label removal that has triggered this event.

Properties of

LabelEventArgs
item: ILabel
Gets the item that is the subject of the event.
owner: ILabelOwner
Gets the owner of the label that owned the label before the event happened.

See Also

Developer's Guide
API
remove, deleted-item, label-edited
Occurs when a label style has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setStyle
Occurs when the tag of a label has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<ILabel, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag
Occurs when the text of a label has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<ILabel, string>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setLabelText
Occurs when a node has been created.
This event is intended to provide notification of low level changes in the graph structure. Please use the node-created event if you are interested only in node creation events that result from user interaction.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the node creation that has triggered this event.

Properties of

ItemEventArgs<INode>
item: T
Gets the item that is the subject of the event.

See Also

Developer's Guide
API
createNode, createNode, createGroupNode, node-created
Occurs when a node layout has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

function(INode, Rect, this): void

See Also

Developer's Guide
API
setNodeLayout
Occurs when a node has been removed.
This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in node removal events that result from user interaction.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the node removal that has triggered this event.

Properties of

NodeEventArgs
isGroupNode: boolean
Gets whether the node was a group node before this event.
item: INode
Gets the item that is the subject of the event.
parent: INode
Gets the parent of the node before this event.

See Also

Developer's Guide
API
remove, deleted-item
Occurs when a node style has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setStyle
Occurs when the tag of a node has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<INode, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag
Occurs if a node has been reparented in the model.
You may not modify the graph in the event handler for this event.

Properties of

NodeEventArgs
isGroupNode: boolean
Gets whether the node was a group node before this event.
item: INode
Gets the item that is the subject of the event.
parent: INode
Gets the parent of the node before this event.

See Also

Developer's Guide
Occurs when a port has been added to this graph instance.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the port creation that has triggered this event.

Properties of

ItemEventArgs<IPort>
item: T
Gets the item that is the subject of the event.

See Also

Developer's Guide
API
addPort, createEdge
Occurs when the location model parameter of a port has been changed.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setPortLocationParameter
Occurs when a port has been removed from its owner.

This event will also be triggered prior to the removal of the corresponding owner of the port.

This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in port removal events that result from user interaction.

You may not modify the graph in the event handler for this event. Especially you may not prevent/undo the port removal that has triggered this event.

Properties of

PortEventArgs
item: IPort
Gets the item that is the subject of the event.
owner: IPortOwner
Gets the owner of the port that was connected to before the event happened.

See Also

Developer's Guide
API
remove, deleted-item
Occurs when a port style has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
setStyle
Occurs when the tag of a port has been replaced.
This event is intended to provide notification of low level changes in the graph structure.
You may not modify the graph in the event handler for this event.

Properties of

ItemChangedEventArgs<IPort, any>
item: TItem
Gets the item that is the subject of the event.
oldValue: TValue
Gets the value of the property before the change.

See Also

Developer's Guide
API
tag