Returns the edges of a graph (or edges not in a graph) where the graph can be either a graphNEL object, an igraph object or an adjacency matrix.

edgeList(object, matrix = FALSE)

edgeListMAT(adjmat, matrix = FALSE)

nonEdgeList(object, matrix = FALSE)

nonEdgeListMAT(adjmat, matrix = FALSE)

Arguments

object

An igraph object, a dense matrix or a sparse dgCMatrix (the two latter representing an adjacency matrix).

matrix

If TRUE the result is a matrix; otherwise the result is a list.

adjmat

An adjacency matrix.

Examples

## A graph with edges
g  <- ug(~a:b + b:c + c:d)
gm <- as(g, "matrix")
edgeList(g)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "b" "c"
#> 
#> [[3]]
#> [1] "c" "d"
#> 
edgeList(gm)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "b" "c"
#> 
#> [[3]]
#> [1] "c" "d"
#> 
edgeListMAT(gm)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "b" "c"
#> 
#> [[3]]
#> [1] "c" "d"
#> 
edgeList(g, matrix=TRUE)
#>      [,1] [,2]
#> [1,] "a"  "b" 
#> [2,] "b"  "c" 
#> [3,] "c"  "d" 
edgeList(gm, matrix=TRUE)
#>      [,1] [,2]
#> [1,] "a"  "b" 
#> [2,] "b"  "c" 
#> [3,] "c"  "d" 
edgeListMAT(gm, matrix=TRUE)
#>      [,1] [,2]
#> [1,] "a"  "b" 
#> [2,] "b"  "c" 
#> [3,] "c"  "d" 
nonEdgeList(g)
#> [[1]]
#> [1] "a" "c"
#> 
#> [[2]]
#> [1] "a" "d"
#> 
#> [[3]]
#> [1] "b" "d"
#> 
nonEdgeList(gm)
#> [[1]]
#> [1] "a" "c"
#> 
#> [[2]]
#> [1] "a" "d"
#> 
#> [[3]]
#> [1] "b" "d"
#> 
nonEdgeListMAT(gm)
#> [[1]]
#> [1] "a" "c"
#> 
#> [[2]]
#> [1] "a" "d"
#> 
#> [[3]]
#> [1] "b" "d"
#> 
## A graph without edges
g  <- ug(~a + b + c)
gm <- as(g, "matrix")
edgeList(g)
#> list()
edgeList(gm)
#> list()
edgeListMAT(gm)
#> list()
edgeList(g, matrix=TRUE)
#>      [,1] [,2]
edgeList(gm, matrix=TRUE)
#>      [,1] [,2]
edgeListMAT(gm, matrix=TRUE)
#>      [,1] [,2]
nonEdgeList(g)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "a" "c"
#> 
#> [[3]]
#> [1] "b" "c"
#> 
nonEdgeList(gm)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "a" "c"
#> 
#> [[3]]
#> [1] "b" "c"
#> 
nonEdgeListMAT(gm)
#> [[1]]
#> [1] "a" "b"
#> 
#> [[2]]
#> [1] "a" "c"
#> 
#> [[3]]
#> [1] "b" "c"
#>