layoutGraph {Rgraphviz}R Documentation

A function to do layout graph objects

Description

This is a wrapper to layout graph objects using arbitrary layout engines.

Usage

layoutGraph(x, layoutFun = layoutGraphviz, ...)

Arguments

x A graph object
layoutFun A function that performs the graph layout and returns a graph object with all necessary rendering information
... Further arguments that are passed t layoutFun

Details

Layout of a graph and rendering are two separate processes. This function provides an API to use any algorithm for the layout. The only requirements to the layoutFun is to return a valid graph object with all the necessary rendering information stored in its renderInfo slot. This comprises

for nodes:

nodeX, nodeY
the locations of the nodes
lw, rw
the width components of the nodes, lw+rw=total width
height
the heights of the nodes
labelX, labelY
node label locations
label
node label text

for edges:

splines
representation of the edge splines as list of BezierCurve objects.
labelX, labelY
edge label locations
label
edge label text

To indicate that this information has been added to the graph, the function should also set the laidout flag in the graphData slot to TRUE and add the bounding box information in the format of a two-by-two matrix as item bbox in the graphData slot.

AT&T's Graphviz is the default layout algoritm to use when layoutGraph is called without a specific layoutFun function. See agopen for details about how to tweak Graphviz.

Value

An object inheriting from class graph

Author(s)

Florian Hahne, Deepayan Sarkar

See Also

renderGraph, graph.par, nodeRenderInfo, edgeRenderInfo

Examples

library(graph)
set.seed(123)
V <- letters[1:10]
M <- 1:4
g1 <- randomGraph(V, M, 0.8)
x <- layoutGraph(g1)

[Package Rgraphviz version 1.20.4 Index]