setDistCosts | R Documentation |
The function setDistCosts
sets the costs of a gGraph
object using the geographic distance. The cost associated to an edge is
defined as the great circle distance between the two nodes of this edge.
setDistCosts
actually relies on rdist.earth
of
the fields
package.
setDistCosts(x, ...)
## S4 method for signature 'gGraph'
setDistCosts(x, ...)
x |
a valid gGraph. |
... |
other arguments passed to other methods (currently unused). |
The notion of 'costs' in the context of gGraph objects is identical to the concept of 'weights' in graph (and thus graphNEL) objects. The larger it is for an edge, the less connectivity there is between the couple of concerned nodes.
For the gGraph method, a gGraph object with appropriate weights. Note that former weights will be removed from the object.
setDistCosts(gGraph)
: Method for gGraph object
The getCosts
accessor, returning costs of the edges
of a gGraph object in different ways.
if (require(fields)) {
## load data
plot(rawgraph.10k, reset = TRUE)
geo.zoomin(list(x = c(110, 150), y = c(-10, -40)))
plotEdges(rawgraph.10k)
## compute costs
x <- rawgraph.10k[isInArea(rawgraph.10k)]
x <- setDistCosts(x)
## replot edges
plotEdges(x) # no big differences can be seen
head(getCosts(x))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.