Skip to contents

Embed Graph in 2D or 3D Space

Usage

graph.embedding(
  graph,
  edge.attribute = NULL,
  transform = c("identity", "reciprocal"),
  dim = 2,
  method = c("fr", "kk"),
  verbose = FALSE,
  stage = "final"
)

Arguments

graph

A dgraph object.

edge.attribute

Explicit edge quantity, such as "length" or "conductance"; NULL uses an unweighted layout.

transform

Use selected values directly ("identity") or their reciprocals ("reciprocal"). Selected values must be strictly positive. Fruchterman-Reingold treats larger values as stronger attraction, whereas Kamada-Kawai uses them as distances.

dim

Embedding dimension, either 2 or 3.

method

Layout method, "fr" or "kk".

verbose

Logical; print timing messages.

stage

Stored graph stage used for both topology and edge attributes.

Value

Numeric layout matrix with one row per embedded vertex.

Examples

set.seed(1)
graph <- create.graph("cycle", 6)
graph.embedding(graph, dim = 2, method = "fr")
#>          [,1]      [,2]
#> [1,] 3.354656 -1.982073
#> [2,] 4.709072 -2.074136
#> [3,] 5.320061 -3.289049
#> [4,] 4.583550 -4.425156
#> [5,] 3.226970 -4.332774
#> [6,] 2.610600 -3.113814