Learn R Programming

shp2graph (version 1-0)

Directed: Orientate all the edges in a given edgelist

Description

A function to orientate each edge according to the given vector.

Usage

Directed(edgelist, direction.v=rep(0,length(edgelist[,1])), eadf=NULL)

Value

A list consisted of:

newEdgelist

An “edgelist” object with directed edges

newEadf

A data frame of attributes for the new “edgelist”

Arguments

edgelist

An “edgelist” object

direction.v

A vector (of the length equalling to the number of edges in the given “edgelist”) with values of 1 (TRUE) or 0 (FALSE), 1 (TRUE) indicates a directed (one-way) edge, while 0 (FALSE) means an undirected (double-way) edge

eadf

A data frame of attributes corresponding to all the edges;

Author

Binbin Lu binbinlu@whu.edu.cn

Details

Within a road network, some road segments might be one-way while the rest are double-way. This suitation makes it complex to define directed or undirected edges in a graph. This function is to orientate each edge according to the given vector, “direction.v”: 1 (TRUE) indicates one-way, while 0 (FALSE) represents double-way. All the double-way (undirected) edges in the given “edgelist” are redefined as two directed edges (e.g. a double-way (undirected) edge(nid1, nid2) is redefined as two one-way (directed) edges, (nid1, nid2) and (nid2, nid1)). The one-way (directed) edges are left in their directed forms. In other words, all the edges returned by this function will be directed, and used to be construct a directed graph.