Central interface that models a graph which can be displayed in a canvas or GraphControl.

Namespace: yWorks.yFiles.UI.Model
Assembly: yWorks.yFilesSilverlight.Viewer (in yWorks.yFilesSilverlight.Viewer.dll) Version:


public interface IGraph : ILookup
Visual Basic
Public Interface IGraph _ Inherits ILookup


This interface can be used to query structural information, it also offers methods that change the structure of the graph and its attributes. A number of events will trigger appropriate events 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 source port and a target port. It is up to the algorithms and the visualization to possibly treat them as undirected.

The EdgesAt(IPort, AdjacencyTypes) and EdgesAt(IPortOwner, AdjacencyTypes) methods can be used to query adjacency information from the graph's structure.

Each element in the graph can be associated with a visual 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 the IMapperRegistry that can be obtained from the MapperRegistry property can be used to associate arbitrary data sets with the items in this graph.

This interface contains core methods that may use complicated argument lists. GraphExtensions is a static utility class that contains extension methods for this interface that improve the usability of this interface dramatically.

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.

Related Reading in the Developer's Guide

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

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

See Also