IgraphFromEdgelist: Convert an edgelist to an igraph

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/IgraphFromEdgelist.R

Description

Given the adjacency matrix for a network return a data.frame listing all possible edges and the weights for each edge.

Usage

1
  IgraphFromEdgelist(elist, directed = TRUE)

Arguments

elist

data.frame, see 'Details' for formatting assumptions.

directed

logical, If TRUE, the returned igraph is directed.

Details

This assumes that elist is a data.frame with three columns. Each row is an edge in the network. The first column lists the node the edge is coming from, the second column lists the node the edge is going to, and the third column lists the weight of the edge.

Value

igraph, If the edgelist third column has values other than 0, 1 then the weights are stored in E(returned graph)$weight.

Author(s)

Stephen R. Haptonstahl srh@haptonstahl.org

References

https://github.com/shaptonstahl/

See Also

EdgelistFill

Examples

1
2
3
4
5
edgelist <- cbind(expand.grid(letters[1:2], letters[1:2]), runif(4))
g <- IgraphFromEdgelist(edgelist)
get.edgelist(g)
E(g)$weight
plot(g, edge.width=5*E(g)$weight, edge.curved=TRUE)

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

Loading required package: Rcpp
     [,1] [,2]
[1,]    1    1
[2,]    1    2
[3,]    2    1
[4,]    2    2
[1] 0.8669050 0.5712371 0.5928074 0.5292011

dils documentation built on May 2, 2019, 8:28 a.m.