Learn R Programming

dils (version 0.8.1)

EdgelistFromIgraph: Convert an igraph to filled edgelist

Description

Given an igraph object for a network return a data.frame listing all possible edges and the weights for each edge.

Usage

EdgelistFromIgraph(g, useWeight = FALSE)

Arguments

g
igraph, from igraph package.
useWeight
logical, Should E(g)$weight be used as the weights for the edges?

Value

data.frame, full list of all possible edges with weights for each in third column.

Details

This function is preferred to the igraph function get.edgelist because get.edgelist only returns rows for edges that have non-zero weight and does not return weights, if present.

References

https://github.com/shaptonstahl/

See Also

EdgelistFromAdjacency

Examples

Run this code
g <- erdos.renyi.game(10, 2/10)
EdgelistFromIgraph(g)

V(g)$name <- letters[1:vcount(g)]
EdgelistFromIgraph(g)

E(g)$weight <- runif(ecount(g))
EdgelistFromIgraph(g, useWeight=TRUE)

Run the code above in your browser using DataLab