from_igraph: Convert an igraph graph to a DiagrammeR one

Description Usage Arguments Value Examples

View source: R/from_igraph.R

Description

Convert an igraph graph to a DiagrammeR graph object.

Usage

1
from_igraph(igraph, graph_name = NULL, write_backups = FALSE)

Arguments

igraph

an igraph graph object.

graph_name

an optional string for labeling the graph object.

write_backups

an option to write incremental backups of changing graph states to disk. If TRUE, a subdirectory of the working directory will be used to store RDS files. The default value is FALSE so one has to opt in to use this functionality.

Value

a graph object of class dgr_graph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Create a DiagrammeR graph object
dgr_graph_orig <-
  create_random_graph(
    n = 36, m = 50,
    set_seed = 23,
    directed = TRUE)

# Convert the DiagrammeR graph to an
# igraph object
ig_graph <- to_igraph(dgr_graph_orig)

# Convert the igraph graph back to a
# DiagrammeR graph
dgr_graph_new <- from_igraph(ig_graph)

# Get some graph information
graph_info(dgr_graph_new)[, 1:6]
#>             name  n  e   dens mn_deg mx_deg
#> 1 graph_eUrgZI3e 36 50 0.0571      1      6

Example output

Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied
Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied
            name  n  e   dens mn_deg mx_deg
1 graph_eUrgZI3e 36 50 0.0571      1      6

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.