adjacency: Create adjacency matrix

Description Usage Arguments Value Author(s) Examples

View source: R/adjacency.R

Description

Create an adjacency matrix from a set of nodes and edges.

Usage

1
adjacency(from, to, weight = 1, directed = TRUE)

Arguments

from

a vector of nodes where the edges originate

to

a vector of nodes where the edges point to

weight

a numeric vector of weights

directed

logical. Are the edges directed (TRUE, the default) or bidirected(FALSE).

Value

Returns a sparse adjacency matrix

Author(s)

Claus Ekstrom ekstrom@sund.ku.dk

Examples

1
2
3
4
5
6
7
8
from <- c("A", "A", "A", "B", "C")
to <- c("B", "C", "D", "D", "E")
adjacency(from, to)

from <- c("A", "A", "A", "B", "C")
to <- c("B", "C", "D", "D", "E")
weights <- c(1, .5, 1, .7, 1)
adjacency(from, to, weights)

networkR documentation built on Sept. 20, 2019, 5:05 p.m.

Related to adjacency in networkR...