documentationfor yFiles for HTML 2.6

The interface used to model edges in an IGraph implementation.

Inheritance Hierarchy
Implemented Interfaces

Remarks

This interface provides read-only access to the properties of an edge. In order to modify the state of an instance use the various methods provided by the IGraph this instance belongs to. An edge connects to two ports and may consist of a number of bends. Also it can have zero or more labels. This interface combines the functionality of IPortOwner to get access to the ports that edges can optionally have, ILabelOwner to get access to the labels, and, like all items in an IGraph, edges support the lookup method inherited from the IModelItem interface that can be used to query additional aspects of each instance.

Examples

Working with an edge in the graph
const graph = graphComponent.graph
const node1 = graph.createNodeAt(new Point(0, 0))
const node2 = graph.createNodeAt(new Point(100, 0))

// create an edge between the nodes
const edge = graph.createEdge(
  node1,
  node2,
  new PolylineEdgeStyle({ targetArrow: IArrow.DEFAULT })
)

// the newly created edge is part of the graph
console.log(graph.contains(edge)) // true
console.log(graph.edges.size) // 1
console.log(graph.edges.get(0) === edge) // true

// the edge is linked via source and target port
// with its source and target nodes
console.log(edge.sourcePort?.owner === node1) // true
console.log(edge.targetPort?.owner === node2) // true

// removing the edge removes it from the graph
graph.remove(edge)
console.log(graph.contains(edge)) // false
console.log(graph.edges.size) // 0
Edges cannot live without source or target in graph
console.log(graph.contains(edge)) // true
graph.remove(edge.sourcePort.owner)
console.log(graph.contains(edge)) // falseconsole.log(graph.contains(edge)) // true
graph.remove(edge.sourcePort!.owner!)
console.log(graph.contains(edge)) // false

Related Reading in the Developer's Guide

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

Using the look-up mechanism is explained in the section Service Locator Pattern: Lookup.

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.graph.IEdge

See Also

Properties

Methods

Static Methods