File: graph_from_adj_list.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 (70 lines) | stat: -rw-r--r-- 2,279 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/conversion.R
\name{graph_from_adj_list}
\alias{graph.adjlist}
\alias{graph_from_adj_list}
\title{Create graphs from adjacency lists}
\usage{
graph_from_adj_list(adjlist, mode = c("out", "in", "all", "total"),
  duplicate = TRUE)
}
\arguments{
\item{adjlist}{The adjacency list. It should be consistent, i.e. the maximum
throughout all vectors in the list must be less than the number of vectors
(=the number of vertices in the graph). Note that the list is expected to be
0-indexed.}

\item{mode}{Character scalar, it specifies whether the graph to create is
undirected (\sQuote{all} or \sQuote{total}) or directed; and in the latter
case, whether it contains the outgoing (\sQuote{out}) or the incoming
(\sQuote{in}) neighbors of the vertices.}

\item{duplicate}{Logical scalar. For undirected graphs it gives whether
edges are included in the list twice. E.g. if it is \code{TRUE} then for an
undirected \code{{A,B}} edge \code{graph_from_adj_list} expects \code{A}
included in the neighbors of \code{B} and \code{B} to be included in the
neighbors of \code{A}.

This argument is ignored if \code{mode} is \code{out} or \code{in}.}
}
\value{
An igraph graph object.
}
\description{
An adjacency list is a list of numeric vectors, containing the neighbor
vertices for each vertex. This function creates an igraph graph object from
such a list.
}
\details{
Adjacency lists are handy if you intend to do many (small) modifications to
a graph. In this case adjacency lists are more efficient than igraph graphs.

The idea is that you convert your graph to an adjacency list by
\code{\link{as_adj_list}}, do your modifications to the graphs and finally
create again an igraph graph by calling \code{graph_from_adj_list}.
}
\examples{
## Directed
g <- make_ring(10, dir=TRUE)
al <- as_adj_list(g, mode="out")
g2 <- graph_from_adj_list(al)
graph.isomorphic(g, g2)

## Undirected
g <- make_ring(10)
al <- as_adj_list(g)
g2 <- graph_from_adj_list(al, mode="all")
graph.isomorphic(g, g2)
ecount(g2)
g3 <- graph_from_adj_list(al, mode="all", duplicate=FALSE)
ecount(g3)
which_multiple(g3)
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\seealso{
\code{\link{as_edgelist}}
}
\keyword{graphs}