Learn R Programming

GeNetIt (version 0.1-6)

graph.metrics: Graph Metrics

Description

Metrics on structural properties of graph (at nodes)

Usage

graph.metrics(
  x,
  node.pts,
  node.name = NULL,
  direct = FALSE,
  metric = c("betweenness", "degree", "closeness")
)

Arguments

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

...

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org> and Melanie A. Murphy <melanie.murphy@uwyo.edu>

Examples

Run this code
 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)	   

Run the code above in your browser using DataLab