nel2igraph: Produce an "igraph" object

Description Usage Arguments Details Value Author(s) Examples

View source: R/nel2igraph.r

Description

A function to produce an “igraph” object with the “nodelist” and “edgelist”, which could be returned by the function readshpnw.

Usage

1

Arguments

nodelist

A “nodelist” object

edgelist

An “edgelist” object

weight

A numberic vector to weight all the edges in the “edgelist”, of which the length equals to the number of edges;

eadf

A data frame of attributes corresponding to all the edges;

Directed

TRUE if edges are directed, FALSE otherwise;

Details

1. The weighting vector, “weight”, will be used as default for any weigted calculations with edges in the “igraph” object.

2. The coordinate of each node is attached as attributes “X” and “Y”, which could be retrived via the function “get.vertex.attribute” from the package igraph.

Value

gr

An “igraph” object

Author(s)

Binbin Lu lubinbin220@gmail.com

Examples

1
2
3
4
5
6
data(ORN)
rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE)
#Add the edge length as the weight for graph
igr<-nel2igraph(rtNEL[[2]],rtNEL[[3]],weight=rtNEL[[4]])
plot(igr, vertex.label=NA, vertex.size=2,vertex.size2=2)
#plot(ORN.nt)

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

shp2graph documentation built on May 1, 2019, 9:45 p.m.