# sample_degseq

##### Generate random graphs with a given degree sequence

It is often useful to create a graph with given vertex degrees. This is
exactly what `sample_degseq`

does.

- Keywords
- graphs

##### Usage

```
sample_degseq(out.deg, in.deg = NULL, method = c("simple", "vl",
"simple.no.multiple"))
```degseq(...)

##### Arguments

- out.deg
- Numeric vector, the sequence of degrees (for undirected
graphs) or out-degrees (for directed graphs). For undirected graphs its sum
should be even. For directed graphs its sum should be the same as the sum of
`in.deg`

. - in.deg
- For directed graph, the in-degree sequence. By default this is
`NULL`

and an undirected graph is created. - method
- Character, the method for generating the graph. Right now the
simple ,simple.no.multiple andvl methods are implemented. - ...
- Passed to
`sample_degree`

.

##### Details

The

The

The `in.deg`

argument to it. The algorithm relies on
first creating an initial (possibly unconnected) simple undirected graph
with the given degree sequence (if this is possible at all). Then some
rewiring is done to make the graph connected. Finally a Monte-Carlo
algorithm is used to randomize the graph. The

##### Value

- The new graph object.

##### See Also

`sample_gnp`

, `sample_pa`

,
`simplify`

to get rid of the multiple and/or loops edges.

##### Examples

```
## The simple generator
g <- sample_degseq(rep(2,100))
degree(g)
is_simple(g) # sometimes TRUE, but can be FALSE
g2 <- sample_degseq(1:10, 10:1)
degree(g2, mode="out")
degree(g2, mode="in")
## The vl generator
g3 <- sample_degseq(rep(2,100), method="vl")
degree(g3)
is_simple(g3) # always TRUE
## Exponential degree distribution
## Note, that we correct the degree sequence if its sum is odd
degs <- sample(1:100, 100, replace=TRUE, prob=exp(-0.5*(1:100)))
if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
g4 <- sample_degseq(degs, method="vl")
all(degree(g4) == degs)
## Power-law degree distribution
## Note, that we correct the degree sequence if its sum is odd
degs <- sample(1:100, 100, replace=TRUE, prob=(1:100)^-2)
if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
g5 <- sample_degseq(degs, method="vl")
all(degree(g5) == degs)
```

*Documentation reproduced from package igraph, version 1.0.0, License: GPL (>= 2)*