File: as_incidence_matrix.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 (58 lines) | stat: -rw-r--r-- 2,094 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
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/conversion.R
\name{as_incidence_matrix}
\alias{as_incidence_matrix}
\alias{get.incidence}
\title{Incidence matrix of a bipartite graph}
\usage{
as_incidence_matrix(graph, types = NULL, attr = NULL, names = TRUE,
  sparse = FALSE)
}
\arguments{
\item{graph}{The input graph. The direction of the edges is ignored in
directed graphs.}

\item{types}{An optional vertex type vector to use instead of the
\code{type} vertex attribute. You must supply this argument if the graph has
no \code{type} vertex attribute.}

\item{attr}{Either \code{NULL} or a character string giving an edge
attribute name. If \code{NULL}, then a traditional incidence matrix is
returned. If not \code{NULL} then the values of the given edge attribute are
included in the incidence matrix. If the graph has multiple edges, the edge
attribute of an arbitrarily chosen edge (for the multiple edges) is
included.}

\item{names}{Logical scalar, if \code{TRUE} and the vertices in the graph
are named (i.e. the graph has a vertex attribute called \code{name}), then
vertex names will be added to the result as row and column names. Otherwise
the ids of the vertices are used as row and column names.}

\item{sparse}{Logical scalar, if it is \code{TRUE} then a sparse matrix is
created, you will need the \code{Matrix} package for this.}
}
\value{
A sparse or dense matrix.
}
\description{
This function can return a sparse or dense incidence matrix of a bipartite
network. The incidence matrix is an \eqn{n} times \eqn{m} matrix, \eqn{n}
and \eqn{m} are the number of vertices of the two kinds.
}
\details{
Bipartite graphs have a \code{type} vertex attribute in igraph, this is
boolean and \code{FALSE} for the vertices of the first kind and \code{TRUE}
for vertices of the second kind.
}
\examples{
g <- make_bipartite_graph( c(0,1,0,1,0,0), c(1,2,2,3,3,4) )
as_incidence_matrix(g)
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\seealso{
\code{\link{graph_from_incidence_matrix}} for the opposite operation.
}
\keyword{graphs}