igraph (version 0.5.5-1)

graph.incidence: Create graphs from an incidence matrix

Description

graph.incidence creates a bipartite igraph graph from an incidence matrix.

Usage

graph.incidence(incidence, directed = FALSE, mode = c("all", "out", 
    "in", "total"), multiple = FALSE, weighted = NULL, add.names = NULL)

Arguments

incidence
The input incidence matrix. It can also be a sparse matrix from the Matrix package.
directed
Logical scalar, whether to create a directed graph.
mode
A character constant, defines the direction of the edges in directed graphs, ignored for undirected graphs. If out, then edges go from vertices of the first kind (corresponding to rows in the incidence matrix) to
multiple
Logical scalar, specifies how to interpret the matrix elements. See details below.
weighted
This argument specifies whether to create a weighted graph from the incidence matrix. If it is NULL then an unweighted graph is created and the multiple argument is used to determine the edges of the graph. If it is a
add.names
A character constant, NA or NULL. graph.incidence can add the row and column names of the incidence matrix as vertex attributes. If this argument is NULL (the default) and the incidence matri

Value

  • A bipartite igraph graph. In other words, an igraph graph that has a vertex attribute type.

concept

  • Bipartite graph
  • Two-mode network

Details

Bipartite graphs have a type vertex attribute in igraph, this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind.

graph.incidence can operate in two modes, depending on the multiple argument. If it is FALSE then a single edge is created for every non-zero element in the incidence matrix. If multiple is TRUE, then the matrix elements are rounded up to the closest non-negative integer to get the number of edges to create between a pair of vertices.

See Also

graph.bipartite for another way to create bipartite graphs

Examples

Run this code
inc <- matrix(sample(0:1, 15, repl=TRUE), 3, 5)
colnames(inc) <- letters[1:5]
rownames(inc) <- LETTERS[1:3]
graph.incidence(inc)

Run the code above in your browser using DataCamp Workspace