documentationfor yFiles for HTML 2.6

The interface for node entities in an IGraph.

Inheritance Hierarchy
Implemented Interfaces

Remarks

This interface provides read-only access to the properties of a node. In order to modify the state of an instance use the various methods provided by the IGraph this instance belongs to. Nodes and edges are the main entities that make up an IGraph. Nodes have zero or more ports to which zero or more edges can connect. IGraph provides the edgesAt method for querying the edges that connect to nodes. Also it is possible to query the adjacent edges for each port that is owned by nodes. This interface combines the functionality of IPortOwner to get access to the ports, ILabelOwner to get access to the labels, and, like all items in an IGraph, nodes support the lookup method inherited from the IModelItem interface can be used to query additional aspects of each instance.

Examples

Working with a node in the graph
const graph = graphComponent.graph

// node creation
const node = graph.createNode(
  new Rect(0, 0, 60, 40),
  new ShapeNodeStyle({
    shape: ShapeNodeShape.RECTANGLE,
    stroke: Stroke.BLACK,
    fill: Fill.ORANGE
  })
)

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

// changing node properties have to be done via the graph
console.log(node.layout) // (0, 0, 60, 40)
graph.setNodeLayout(node, new Rect(100, 0, 60, 40))
console.log(node.layout) // (100, 0, 60, 40)

// removing the node removes it from the graph
graph.remove(node)
console.log(graph.contains(node)) // false
console.log(graph.nodes.size) // 0

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.INode

See Also

Properties

Methods