Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

adjacencyMatrix

Compute an Adjacency Matrix for a graphBAM object


Description

Though unwieldy for large matrices, a full adjacency matrix can be useful for debugging and export.

If the graph is “undirected” then recicprocal edges are explicit in the matrix.

Usage

adjacencyMatrix(object)

Arguments

object

A graphBAM object.

Details

Thus far only implemented for graphBAM objects.

Value

adjacencyMatrix returns an n x n matrix, where n is the number of nodes in the graph, ordered in the same manner as seen in the nodes method. All cells in the matrix are 0 except where edges are found.

Author(s)

P. Shannon

See Also

Examples

from   <- c("a", "a", "a", "x", "x", "c")
  to     <- c("b", "c", "x", "y", "c", "a")
  weight <- c(3.4, 2.6, 1.7, 5.3, 1.6, 7.9)
  df <- data.frame(from, to, weight, stringsAsFactors = TRUE)
  g1 <- graphBAM(df, edgemode = "directed")
  adjacencyMatrix(g1)

graph

graph: A package to handle graph data structures

v1.68.0
Artistic-2.0
Authors
R. Gentleman, Elizabeth Whalen, W. Huber, S. Falcon
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.