View source: R/graph.metrics.R
graph.metrics | R Documentation |
Metrics on structural properties of graph (at nodes)
graph.metrics(
x,
node.pts,
node.name = NULL,
direct = FALSE,
metric = c("betweenness", "degree", "closeness")
)
x |
knn graph object from GeNetIt::knn.graph (sf LINESTRING) |
node.pts |
sf POINT or sp SpatialPointsDataFrame object used as nodes to build x |
node.name |
Column name in node.pts object that acts as the provides the unique ID. If not defined, defaults to row.names of node.pts |
direct |
(FALSE/TRUE) Evaluate directed graph |
metric |
... |
Please note; graph metrics are not valid for a saturated graph (all connections)
Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie A. Murphy <melanie.murphy@uwyo.edu>
library(sf)
data(ralu.site, package="GeNetIt")
graph <- knn.graph(ralu.site, row.names=ralu.site$SiteName,
max.dist = 2500)
plot(st_geometry(graph))
( m <- graph.metrics(graph, ralu.site, "SiteName") )
ralu.site <- merge(ralu.site, m, by="SiteName")
# plot node betweenness
plot(st_geometry(graph), col="grey")
plot(ralu.site["betweenness"], pch=19, cex=1.25, add=TRUE)
# plot node degree
plot(st_geometry(graph), col="grey")
plot(ralu.site["degree"], pch=19, cex=1.25, add=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.