Learn R Programming

ggraph (version 0.1.1)

createLayout: Convert a graph object to a layout_ggraph object

Description

This function takes care of converting the different supported graph representations to a common format. It is called automatically by ggraph but can also be used stand-alone to save and reuse layouts. createLayout is an S3 generic with methods for the different supported object.

Usage

createLayout(graph, layout, circular, ...)
"createLayout"(graph, layout, ...)
"createLayout"(graph, layout, circular = FALSE, ...)
"createLayout"(graph, layout, circular = FALSE, ...)
"createLayout"(graph, layout, circular = FALSE, ...)
"createLayout"(graph, layout, circular = FALSE, ...)

Arguments

graph
The object representing the graph. Currently supported classes are igraph and dendrogram
layout
The layout to apply the range depends on the class of graph. See details.
circular
Should the layout be transformed into a circular representation afterward. Only meaningful for a subset of layouts.
...
Arguments passed on to the specific method

Value

An object inherting from layout_ggraph. layout_ggraph itself inherits from data.frame and can be considered as such. The data.frame contains the node positions in the x and y column along with additional columns generated by the specific layout, as well as node parameters inherited from the graph. Additional information is stored as attributes to the data.frame. The original graph object is stored in the graph attribute and the circular attribute contains a logical indicating whether the layout has been transformed to a circular representation.

Details

Dendrogram objects

The dendrogram class is used to store binary tree from e.g. hierarchical clustering. The layouts provided for this class is constrained to tree-like representations and include:

igraph objects

Any type of regular graph/network data can be represented as an igraph object. Because of this the different layouts that can be applied to igraph objects are quite diverse, but not all layouts makes sense to all types of graphs. It is up to the user to understand their data and choose an appropriate layout. For standard node-edge diagrams igraph itself defines a long range of different layout functions that are all available through the igraph layout. Furthermore ggraph itself defines additional layouts:

See Also

gEdges for extracting edge information from the layout and gCon for extracting path information.

Examples

Run this code
require(igraph)
gr <- make_graph('bull')
layout <- createLayout(gr, layout = 'igraph', algorithm = 'kk')

Run the code above in your browser using DataLab