R: Use igraph layout algorithms for layout_tbl_graph

layout_tbl_graph_igraph {ggraph} | R Documentation

## Use igraph layout algorithms for layout_tbl_graph

### 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_tbl_graph_igraph(
      graph,
      algorithm,
      circular,
      offset = pi/2,
      use.dummy = FALSE,
      ...
    )

### Arguments

`graph` | A `tbl_graph` object.
`algorithm` | The type of layout algorithm to apply. See Details or `igraph::layout_()` for links to the layouts supplied by igraph.
`circular` | Logical. Should the layout be transformed to a circular representation. Defaults to `FALSE`. Only applicable to `algorithm = 'tree'` and `algorithm = 'sugiyama'`.
`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`.
`...` | Arguments passed on to the respective layout functions

### 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 `igraph::as_tree()`

`sugiyama`

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

Standard layouts

`bipartite`

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

`star`

  Place one node in the center and the rest equidistantly around it. See `igraph::as_star()`

`circle`

  Place nodes in a circle in the order of their index. Consider using `layout_tbl_graph_linear()` with `circular=TRUE` for more control. See `igraph::in_circle()`

`nicely`

  Tries to pick an appropriate layout. See `igraph::nicely()` for a description of the simple decision tree it uses

`dh`

  Uses Davidson and Harels simulated annealing algorithm to place nodes. See `igraph::with_dh()`

`gem`

  Place nodes on the plane using the GEM force-directed layout algorithm. See `igraph::with_gem()`

`graphopt`

  Uses the Graphopt algorithm based on alternating attraction and repulsion to place nodes. See `igraph::with_graphopt()`

`grid`

  Place nodes on a rectangular grid. See `igraph::on_grid()`

`mds`

  Perform a multidimensional scaling of nodes using either the shortest path or a user supplied distance. See `igraph::with_mds()`

`sphere`

  Place nodes uniformly on a sphere - less relevant for 2D visualizations of networks. See `igraph::on_sphere()`

`randomly`

  Places nodes uniformly random. See `igraph::randomly()`

`fr`

  Places nodes according to the force-directed algorithm of Fruchterman and Reingold. See `igraph::with_fr()`

`kk`

  Uses the spring-based algorithm by Kamada and Kawai to place nodes. See `igraph::with_kk()`

`drl`

  Uses the force directed algorithm from the DrL toolbox to place nodes. See `igraph::with_drl()`

`lgl`

  Uses the algorithm from Large Graph Layout to place nodes. See `igraph::with_lgl()`

### Value

A data.frame with the columns `x`, `y`, `circular` as well as any information stored as node variables in the tbl_graph object.

### Note

This function is not intended to be used directly but by setting `layout = 'igraph'` in `create_layout()`

### See Also

Other layout_tbl_graph_*: `layout_tbl_graph_auto()`, `layout_tbl_graph_backbone()`, `layout_tbl_graph_centrality()`, `layout_tbl_graph_circlepack()`, `layout_tbl_graph_dendrogram()`, `layout_tbl_graph_eigen()`, `layout_tbl_graph_fabric()`, `layout_tbl_graph_focus()`, `layout_tbl_graph_hive()`, `layout_tbl_graph_linear()`, `layout_tbl_graph_manual()`, `layout_tbl_graph_matrix()`, `layout_tbl_graph_partition()`, `layout_tbl_graph_pmds()`, `layout_tbl_graph_stress()`, `layout_tbl_graph_treemap()`, `layout_tbl_graph_unrooted()`

[Package ggraph version 2.0.2 Index]