File: sample_k_regular.Rd

package info (click to toggle)
r-cran-igraph 1.0.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,232 kB
  • sloc: ansic: 173,538; cpp: 19,365; fortran: 4,550; yacc: 1,164; tcl: 931; lex: 484; makefile: 149; sh: 9
file content (54 lines) | stat: -rw-r--r-- 1,471 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/games.R
\name{sample_k_regular}
\alias{k.regular.game}
\alias{sample_k_regular}
\title{Create a random regular graph}
\usage{
sample_k_regular(no.of.nodes, k, directed = FALSE, multiple = FALSE)
}
\arguments{
\item{no.of.nodes}{Integer scalar, the number of vertices in the generated
graph.}

\item{k}{Integer scalar, the degree of each vertex in the graph, or the
out-degree and in-degree in a directed graph.}

\item{directed}{Logical scalar, whether to create a directed graph.}

\item{multiple}{Logical scalar, whether multiple edges are allowed.}
}
\value{
An igraph graph.
}
\description{
Generate a random graph where each vertex has the same degree.
}
\details{
This game generates a directed or undirected random graph where the degrees
of vertices are equal to a predefined constant k. For undirected graphs, at
least one of k and the number of vertices must be even.

The game simply uses \code{\link{sample_degseq}} with appropriately
constructed degree sequences.
}
\examples{
## A simple ring
ring <- sample_k_regular(10, 2)
plot(ring)

## k-regular graphs on 10 vertices, with k=1:9
k10 <- lapply(1:9, sample_k_regular, no.of.nodes=10)

layout(matrix(1:9, nrow=3, byrow=TRUE))
sapply(k10, plot, vertex.label=NA)
}
\author{
Tamas Nepusz \email{ntamas@gmail.com}
}
\seealso{
\code{\link{sample_degseq}} for a generator with prescribed degree
sequence.
}
\keyword{graphs}