R: Graph to adjacency matrix

grMAT {ggm} | R Documentation

## Graph to adjacency matrix

### Description

`grMAT` generates the associated adjacency matrix to a given graph.

### Usage

    grMAT(agr)

### Arguments

`agr` | A graph that can be a `graphNEL` or an `igraph` object or a vector of length 3e, where e 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).

### Value

A matrix that consists 4 different integers as an ij-element: 0 for a missing edge between i and j, 1 for an arrow from i to j, 10 for a full line between i and j, and 100 for a bi-directed arrow between i and j. 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 an igraph object
    exdag <- graph.formula(v7+-v8-+v5+-v6, v5-+v1+-v4-+v3, v1+-v2+-v3)
    grMAT(exdag)

    ## 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)

[Package ggm version 2.3 Index]