Skip to contents

Place the vertices on the plane, or in 3D space, based on a physical model of springs.

Usage

layout_with_kk(
  graph,
  coords = NULL,
  dim = 2,
  maxiter = 50 * vcount(graph),
  epsilon = 0,
  kkconst = max(vcount(graph), 1),
  weights = NULL,
  minx = NULL,
  maxx = NULL,
  miny = NULL,
  maxy = NULL,
  minz = NULL,
  maxz = NULL,
  niter,
  sigma,
  initemp,
  coolexp,
  start
)

with_kk(...)

Arguments

graph

The input graph. Edge directions are ignored.

coords

If not NULL, then the starting coordinates should be given here, in a two or three column matrix, depending on the dim argument.

dim

Integer scalar, 2 or 3, the dimension of the layout. Two dimensional layouts are places on a plane, three dimensional ones in the 3d space.

maxiter

The maximum number of iterations to perform. The algorithm might terminate earlier, see the epsilon argument.

epsilon

Numeric scalar, the algorithm terminates, if the maximal delta is less than this. (See the reference below for what delta means.) If you set this to zero, then the function always performs maxiter iterations.

kkconst

Numeric scalar, the Kamada-Kawai vertex attraction constant. Typical (and default) value is the number of vertices.

weights

Edge weights, larger values will result longer edges. Note that this is opposite to layout_with_fr(). Weights must be positive.

minx

If not NULL, then it must be a numeric vector that gives lower boundaries for the ‘x’ coordinates of the vertices. The length of the vector must match the number of vertices in the graph.

maxx

Similar to minx, but gives the upper boundaries.

miny

Similar to minx, but gives the lower boundaries of the ‘y’ coordinates.

maxy

Similar to minx, but gives the upper boundaries of the ‘y’ coordinates.

minz

Similar to minx, but gives the lower boundaries of the ‘z’ coordinates.

maxz

Similar to minx, but gives the upper boundaries of the ‘z’ coordinates.

niter, sigma, initemp, coolexp

These arguments are not supported from igraph version 0.8.0 and are ignored (with a warning).

start

Deprecated synonym for coords, for compatibility.

...

Passed to layout_with_kk().

Value

A numeric matrix with two (dim=2) or three (dim=3) columns, and as many rows as the number of vertices, the x, y and potentially z coordinates of the vertices.

Details

See the referenced paper below for the details of the algorithm.

This function was rewritten from scratch in igraph version 0.8.0 and it follows truthfully the original publication by Kamada and Kawai now.

References

Kamada, T. and Kawai, S.: An Algorithm for Drawing General Undirected Graphs. Information Processing Letters, 31/1, 7--15, 1989.

Author

Gabor Csardi csardi.gabor@gmail.com

Examples


g <- make_ring(10)
E(g)$weight <- rep(1:2, length.out = ecount(g))
plot(g, layout = layout_with_kk, edge.label = E(g)$weight)