Adapter class that can be used to obtain a IGraphLayout and IGraphInterface from an IGraph.

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

Syntax

C#
public class LayoutGraphAdapter : IGraphLayout, IGraphInterface
Visual Basic
Public Class LayoutGraphAdapter _ Implements IGraphLayout, IGraphInterface

Remarks

This adapter needs to be used in order to apply layout algorithms to IGraph instances. The following pattern should be used:
CopyC#
// build the adapter
LayoutGraphAdapter adapter = new LayoutGraphAdapter(graph, selectionModel);

// create a copy for improved performance and stability
CopiedLayoutGraph layoutGraph = new CopiedLayoutGraph(adapter, adapter);

// perform the layout on the copy
layouter.DoLayout(layoutGraph);

// apply the results to the original IGraph
layoutGraph.CommitLayoutToOriginalGraph();
Alternatively one can use the LayoutMorpherWrapper to morph the layout:
CopyC#
// build the adapter
LayoutGraphAdapter adapter = new LayoutGraphAdapter(graph, selectionModel);

// create a copy for improved performance and stability
CopiedLayoutGraph layoutGraph = new CopiedLayoutGraph(adapter, adapter);

// perform the layout on the copy
layouter.DoLayout(layoutGraph);

// create the animation object
LayoutMorpherWrapper morpher = new LayoutMorpherWrapper(graph, layoutGraph, TimeSpan.FromSeconds(1));

// and play
Animator animator = new Animator(view);
animator.Animate(morpher);
Class CopiedLayoutIGraph is a convenience class that can be used to quickly assign new layouts to an IGraph:
CopyC#
// build the adapter copy
CopiedLayoutIGraph copy = new CopiedLayoutIGraph(graph);

// perform the layout on the copy
layouter.DoLayout(copy);

// apply the results to the original IGraph
copy.CommitLayoutToOriginalGraph();
or even:
CopyC#
CopiedLayoutIGraph.ApplyLayout(graph, layouter);

This class will use the provided SelectionModel to attach IDataProvider instances to the GraphInterface for the SelectedNodesDpKey and SelectedEdgesDpKey data provider keys. Also it will automatically wrap IMapper<(Of <(<'K, V>)>)> instances registered with the IMapperRegistry found in the Lookup(Type) of the IGraph and wrap those instances in IDataProvider instances.

Also this class provides a mechanism to adapt the edge to edge connection feature that is available for IGraphs, where IEdges can also be adjacent to other edges. Since this construct is not available for IGraphInterface, using the EdgeToEdgeConnectionsIncluded property, this type can be told to insert small dummy nodes into the graph as the end points for edges connected to other edges.

Related Reading in the Developer's Guide

The chapter Using yFiles Layout Functionality From yFiles for Silverlight Viewer describes how automatic layout and graph analysis algorithms from the yFiles Layout and yFiles Basic library components can be accessed from yFiles for Silverlight Viewer.

Inheritance Hierarchy

System..::..Object
  yWorks.yFiles.UI.Model..::..LayoutGraphAdapter

See Also