adjacency {networkR}R Documentation

Create adjacency matrix

Description

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

Usage

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


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)


[Package networkR version 0.1.2 Index]