grMAT function

Graph to adjacency matrix

Graph to adjacency matrix

grMAT generates the associated adjacency matrix to a given graph.

grMAT(agr)

Arguments

  • agr: A graph that can be a graphNEL or an igraph object or a vector of length 3e3e, where ee is the number of edges of the graph, that is a sequence of triples (type, node1label, node2label). The type of edge can be "a" (arrows from node1 to node2), "b" (arcs), and "l" (lines).

Returns

A matrix that consists 4 different integers as an ijij-element: 0 for a missing edge between ii and jj, 1 for an arrow from ii to jj, 10 for a full line between ii and jj, and 100 for a bi-directed arrow between ii and jj. These numbers are added to be associated with multiple edges of different types. The matrix is symmetric w.r.t full lines and bi-directed arrows.

Author(s)

Kayvan Sadeghi

Examples

## Generating the adjacency matrix from a vector exvec <-c ('b',1,2,'b',1,14,'a',9,8,'l',9,11,'a',10,8, 'a',11,2,'a',11,10,'a',12,1,'b',12,14,'a',13,10,'a',13,12) grMAT(exvec)