# Graph Layout Algorithms in MindFusion Diagramming Components

Most diagram components support the full list of automatic layout algorithms -

check the comparison table here.
## General Graph Layout Algorithms

### Decision Layout

Known also as Flowchart Layout, this algorithm arranges simple flowcharts consisting of decision boxes with up to three outgoing links per node and activity boxes with a single outgoing link per node. The nodes are arranged in columns and rows, whose distance depends on the

HorizontalPadding and

VerticalPadding property values.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Source Code Layout

The Flowchart Layout can be applied on diagrams, produced when parsing arbitrary source code. It is the ideal algorithm to arrange the nodes and connectors that represent the program entities in a way that best represents the flow of the program logic.
### Fractal Layout

Nodes at the lowest level are arranged directly in a circle around their parent. At the upper level, the already arranged nodes form branches that are arranged in a circle around the new parent node. The algorithm is recursively repeated till the highest level is reached.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Hierarchical Layout

The hierarchical layout places nodes at user-defined levels, such that if the source graph is level-planar, all links are guaranteed to have a single segent and will not intersect.
### Swimlane Layout

Known also as Process Flowchart Layout, this layout algorithm can be used to arrange process diagrams in which nodes representing activities are placed in swimlanes representing resources.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Composite Layout

CompositeLayout partitions the diagram into several subgraphs and applies the algorithm specified via the

SubgraphLayout property on each part. If the part is a tree, it is arranged using the algorithm specified via the

SubtreeLayout property, which is set to a radial

TreeLayout instance by default. Finally the algorithm specified via

MasterLayout is applied on the graph that represents the overall partition. By running the polynomial-complexity layout algorithms on small subgraphs, CompositeLayout is able to process a large graph much faster than if a layout algorithm is applied on the whole graph.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Treemap Layout

Treemap maps represent hierarchies by nesting child nodes within their parents, where the areas of leaf nodes are proportional to their

Weight values. Unlike other layout algorithms, TreemapMapLayout expects hierarchies to be defined via grouping or containment (see AttachTo method and ContainerNode class), and will ignore any links in the diagram.
Download the sample for WPF in C#

Download the sample for WPF in VB.NET

## Force-directed Graph Layout Algorithms

### Anneal Layout

Simulated Annealing is a general-purpose optimization method used to solve large-scale combinatorial problems by simulating the process of heating and cooling of metal to achieve freedom from defects. Finding a nice arrangement of a graph is a combinatorial problem that can be reduced to assigning costs to graph configurations and finding the minimum cost configuration. The algorithm assigns cost to a graph configuration by evaluating different aesthetic criteria chosen by the user such as distance between nodes, length of links and the number of link crossings.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Circular Layout

The CircularLayout class implements a circular graph layout algorithm. Nodes are distributed evenly on the circumference of a circle at positions that result in as few link crossing as possible.

### Clustered Layout

The EnableClusters property of SpringLayout makes diagrams laid out in distinct clusters as shown below.

### Grid Layout

The GridLayout algorithm arranges diagram nodes in a grid, keeping connected nodes close together. It also strives to achieve a small number of link crossings. The algorithm is based on an iterative process whose initial steps shuffle the grid nodes randomly. That leads to very different results each time the layout is applied to a diagram.

### Spring Layout

Spring-Embedder is force-directed layout algorithm. It simulates a physical system in which nodes repulse each other, and the links between them act as confining springs. Graphs processed by Spring-Embedder have their nodes distributed uniformly across the diagram area. Press the Layout button to have the Spring-Embedder algorithm applied on the graph below.

### Spring Layout 3D

The animated 3D SpringLayout algorithm displays nodes inside a DiagramView3D control. You can drag with the mouse to pan the camera, hold CTRL while dragging to rotate the camera. Use the mouse wheel to move the camera back and forth.
## Structural Graph Layout Algorithms

### Tree Layout

This layout arranges diagram elements in tree-like hierarchies. You may customize the layout in various ways, including direction of the tree, alignment of the items, the links styles, the spacing between the items and the tree levels, and more.

Download the sample for WPF in C#

Download the sample for WPF in VB.NET

### Binary Tree Layout

This is a Horizontal-vertical layout that can be applied to binary trees.

### Big Radial Layout

A radial tree, or simply radial layout, is a method of displaying a tree structure (e.g., a tree data structure) in a way that expands outwards, radially.

### Layered Layout

The Layered layout algorithm arranges diagram nodes in layers, according to several criteria. Most important criteria are: connected nodes must be placed close together; links must flow in one direction if possible; links must cross as few layers as possible; links must not cross other links.
## Topological Graph Layout Algorithms

### Cascade Layout

The cascade layout places vertices on a virtual grid and arranges edges orthogonally, such that if the source graph is planar it is guaranteed that all edges will have no more than two bends and will not intersect.

### Triangular Layout

The triangular layout places vertices on a virtual grid, such that if the source graph is planar it is guaranteed that all edges will have a single segment and will not intersect. If the graph is not planar, the intersecting edges are optionally segmented and bended in order to improve readability.

### Orthogonal Layout

The Orthogonal layout graph layout algorithm draws each link as a chain of alternating horizontal and vertical segments. Nodes are placed in a way that facilitates few links bends and crossings.

### Topological Layout

If the underlying graph if acyclic, TopologicalLayout arranges the nodes linearly in such a way that each node comes before all destination nodes of its outgoing links. The links are drawn as curves above the chain of nodes, with their height proportional to the distance between the nodes. If the graph is not acyclic, the layout algorithm finds an ordering with a minimal number of back links, and draws the back links below the chain of nodes.

### One-way Layout

The one-way layout ensures that links enter into nodes from the same general direction and exit them from the opposite side. If the graph contains cycles, some links bend around the nodes to keep the enter/exit direction consistent. The algorithm aims to minimize the number of such links.

### Arrow Routing Algorithm

Automatic arrow routing guides node connectors while weighing different criteria: turn and crossing cost, length cost, node vincinity cost and node vincinity size.
Copyright © 2001-2021 MindFusion LLC. All rights reserved.