Learn R Programming

ggraph (version 1.0.2)

layout_igraph_auto: Use igraph layout algorithms for layout_igraph

Description

This layout function makes it easy to apply one of the layout algorithms supplied in igraph when plotting with ggraph. Layout names are auto completed so there is no need to write layout_with_graphopt or layout_as_tree, just graphopt and tree (though the former will also work if you want to be super explicit). Circular layout is only supported for tree-like layout (tree and sugiyama) and will throw an error when applied to other layouts.

Usage

layout_igraph_auto(graph, circular, ...)

layout_igraph_igraph(graph, algorithm, circular, offset = pi/2, use.dummy = FALSE, ...)

Arguments

graph

An igraph object.

circular

Logical. Should the layout be transformed to a circular representation. Defaults to FALSE. Only applicable to algorithm = 'tree' and algorithm = 'sugiyama'.

...

Arguments passed on to the respective layout functions

algorithm

The type of layout algorithm to apply. See layout_ for links to the layouts supplied by igraph.

offset

If circular = TRUE, where should it begin. Defaults to pi/2 which is equivalent to 12 o'clock.

use.dummy

Logical. In the case of algorithm = 'sugiyama' should the dummy-infused graph be used rather than the original. Defaults to FALSE.

Value

A data.frame with the columns x, y, circular as well as any information stored as vertex attributes on the igraph object.

Details

igraph provides a huge amount of possible layouts. They are all briefly described below:

Hierarchical layouts

tree

Uses the Reingold-Tilford algorithm to place the nodes below their parent with the parent centered above its children. See as_tree

sugiyama

Designed for directed acyclic graphs (that is, hierarchies where multiple parents are allowed) it minimizes the number of crossing edges. See with_sugiyama

Standard layouts

bipartite

Minimize edge-crossings in a simple two-row (or column) layout for bipartite graphs. See as_bipartite

star

Place one node in the center and the rest equidistantly around it. See as_star

circle

Place nodes in a circle in the order of their index. Consider using layout_igraph_linear with circular=TRUE for more control. See in_circle

nicely

Tries to pick an appropriate layout. See nicely for a description of the simpe decision tree it uses

dh

Uses Davidson and Harels simulated annealing algorithm to place nodes. See with_dh

gem

Place nodes on the plane using the GEM force-directed layout algorithm. See with_gem

graphopt

Uses the Graphopt algorithm based on alternating attraction and repulsion to place nodes. See with_graphopt

grid

Place nodes on a rectangular grid. See on_grid

mds

Perform a multidimensional scaling of nodes using either the shortest path or a user supplied distance. See with_mds

sphere

Place nodes uniformly on a sphere - less relevant for 2D visualizations of networks. See on_sphere

randomly

Places nodes uniformly random. See randomly

fr

Places nodes according to the force-directed algorithm of Fruchterman and Reingold. See with_fr

kk

Uses the spring-based algorithm by Kamada and Kawai to place nodes. See with_kk

drl

Uses the force directed algorithm from the DrL toolbox to place nodes. See with_drl

lgl

Uses the algorithm from Large Graph Layout to place nodes. See with_lgl

See Also

Other layout_igraph_*: layout_igraph_circlepack, layout_igraph_dendrogram, layout_igraph_hive, layout_igraph_linear, layout_igraph_manual, layout_igraph_partition, layout_igraph_treemap