Description Usage Arguments Details Value Note Author(s) References See Also Examples

Generating random directed acyclic graphs (DAGs) with fixed expected
number of neighbours. Several different methods are provided, each
intentionally biased towards certain properties. The methods are based
on the analogue `*.game`

functions in the igraph package.

1 2 |

`n` |
integer, at least |

`d` |
a positive number, corresponding to the expected number of neighbours per node, more precisely the expected sum of the in- and out-degree. |

`method` |
a string, specifying the method used for generating the random graph. See details below. |

`par1, par2` |
optional additional arguments, dependent on the method. See details. |

`DAG` |
logical, if |

`weighted` |
logical indicating if edge weights are computed according to |

`wFUN` |
a |

A (weighted) random graph with `n`

nodes and expected number of
neighbours `d`

is constructed. For `DAG=TRUE`

, the graph is
oriented to a DAG. There are eight different random graph models
provided, each selectable by the parameters `method`

,
`par1`

and `par2`

, with `method`

, a string,
taking one of the following values:

`regular`

:Graph where every node has exactly

`d`

incident edges.`par1`

and`par2`

are not used.`watts`

:Watts-Strogatz graph that interpolates between the regular (

`par1->0`

) and Erdoes-Renyi graph (`par1->1`

). The parameter`par1`

is per default`0.5`

and has to be in`(0,1)`

.`par2`

is not used.`er`

:Erdoes-Renyi graph where every edge is present independently.

`par1`

and`par2`

are not used.`power`

:A graph with power-law degree distribution with expectation

`d`

.`par1`

and`par2`

are not used.`bipartite`

:Bipartite graph with at least

`par1*n`

nodes in group 1 and at most`(1-par1)*n`

nodes in group 2. The argument`par1`

has to be in`[0,1]`

and is per default`0.5`

.`par2`

is not used.`barabasi`

:A graph with power-law degree distribution and preferential attachement according to parameter

`par1`

. It must hold that`par1 >= 1`

and the default is`par1=1`

.`par2`

is not used.`geometric`

:A geometric random graph in dimension

`par1`

, where`par1`

can take values from`{2,3,4,5}`

and is per default`2`

. If`par2="geo"`

and`weighted=TRUE`

, then the weights are computed according to the Euclidean distance. There are currently no other option for`par2`

implemented.`interEr`

:A graph with

`par1`

islands of Erdoes-Renyi graphs, every pair of those connected by a certain number of edges proportional to`par2`

(fraction of inter-connectivity). It is required that*n/s*be integer and`par2`

in*(0,1)*. Defaults are`par1=2`

and`par2=0.25`

, respectively.

A graph object of class `graphNEL`

.

The output is *not* topologically sorted (as opposed to the
output of `randomDAG`

).

Markus Kalisch ([email protected]) and Manuel Schuerch.

These methods are mainly based on the analogue functions in the igraph package.

the package `igraph`

, notably help pages such as
`random.graph.game`

or `barabasi.game`

;

`unifDAG`

from package unifDAG for generating uniform random DAGs.

`randomDAG`

a limited and soon deprecated version of `randDAG`

;
`rmvDAG`

for generating multivariate data according to a DAG.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ```
set.seed(37)
dag1 <- randDAG(10, 4, "regular")
dag2 <- randDAG(10, 4, "watts")
dag3 <- randDAG(10, 4, "er")
dag4 <- randDAG(10, 4, "power")
dag5 <- randDAG(10, 4, "bipartite")
dag6 <- randDAG(10, 4, "barabasi")
dag7 <- randDAG(10, 4, "geometric")
dag8 <- randDAG(10, 4, "interEr", par2 = 0.5)
## require("Rgraphviz")
par(mfrow=c(4,2))
plot(dag1,main="Regular graph")
plot(dag2,main="Watts-Strogatz graph")
plot(dag3,main="Erdoes-Renyi graph")
plot(dag4,main="Power-law graph")
plot(dag5,main="Bipartite graph")
plot(dag6,main="Barabasi graph")
plot(dag7,main="Geometric random graph")
plot(dag8,main="Interconnected island graph")
set.seed(45)
dag0 <- randDAG(6,3)
dag1 <- randDAG(6,3, weighted=FALSE)
dag2 <- randDAG(6,3, DAG=FALSE)
par(mfrow=c(1,2))
plot(dag1)
plot(dag2) ## undirected graph
dag0@edgeData ## note the uniform weights between 0.1 and 1
dag1@edgeData ## note the constant weights
wFUN <- function(m,lB,uB) { runif(m,lB,uB) }
dag <- randDAG(6,3,wFUN=list(wFUN,1,4))
dag@edgeData ## note the uniform weights between 1 and 4
``` |

```
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit, which, which.max, which.min
An object of class "attrData"
Slot "data":
$`1|3`
$`1|3`$weight
[1] 0.6959312
$`1|6`
$`1|6`$weight
[1] 0.9516079
$`2|1`
$`2|1`$weight
[1] 0.4681046
$`2|3`
$`2|3`$weight
[1] 0.3878854
$`2|5`
$`2|5`$weight
[1] 0.9682997
$`3|6`
$`3|6`$weight
[1] 0.7736513
$`4|1`
$`4|1`$weight
[1] 0.2276639
$`4|3`
$`4|3`$weight
[1] 0.216235
$`4|5`
$`4|5`$weight
[1] 0.4695182
$`4|6`
$`4|6`$weight
[1] 0.9019628
$`5|1`
$`5|1`$weight
[1] 0.3141022
$`5|3`
$`5|3`$weight
[1] 0.6269516
$`5|6`
$`5|6`$weight
[1] 0.1622838
Slot "defaults":
$weight
[1] 1
An object of class "attrData"
Slot "data":
$`1|2`
$`1|2`$weight
[1] 1
$`1|3`
$`1|3`$weight
[1] 1
$`1|6`
$`1|6`$weight
[1] 1
$`3|2`
$`3|2`$weight
[1] 1
$`4|1`
$`4|1`$weight
[1] 1
$`4|2`
$`4|2`$weight
[1] 1
$`4|3`
$`4|3`$weight
[1] 1
$`4|5`
$`4|5`$weight
[1] 1
$`4|6`
$`4|6`$weight
[1] 1
$`5|2`
$`5|2`$weight
[1] 1
$`5|6`
$`5|6`$weight
[1] 1
$`6|3`
$`6|3`$weight
[1] 1
Slot "defaults":
$weight
[1] 1
An object of class "attrData"
Slot "data":
$`1|3`
$`1|3`$weight
[1] 1.281848
$`1|4`
$`1|4`$weight
[1] 2.740531
$`3|2`
$`3|2`$weight
[1] 2.633159
$`4|2`
$`4|2`$weight
[1] 1.516612
$`5|4`
$`5|4`$weight
[1] 1.815226
Slot "defaults":
$weight
[1] 1
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.