graph_plot_compar: Visualize the topological differences between two spatial...

View source: R/graph_plot_compar.R

graph_plot_comparR Documentation

Visualize the topological differences between two spatial graphs on a map

Description

The function enables to compare two spatial graphs by plotting them highlighting the topological similarities and differences between them. Both graphs should share the same nodes and cannot be directed graphs.

Usage

graph_plot_compar(x, y, crds)

Arguments

x

A graph object of class igraph. Its nodes must have the same names as in graph y.

y

A graph object of class igraph. Its nodes must have the same names as in graph x.

crds

A data.frame with the spatial coordinates of the graph nodes (both x and y). It must have three columns:

  • ID: Name of the graph nodes (character string). The names must be the same as the node names of the graphs of class igraph (igraph::V(graph)$name)

  • x: Longitude of the graph nodes (numeric or integer).

  • y: Latitude of the graph nodes (numeric or integer).

Details

The graphs x and y of class igraph must have node names (not necessarily in the same order as IDs in crds, given a merging is done).

Value

A ggplot2 object to plot

Author(s)

P. Savary

Examples

data(pts_pop_ex)
data(data_ex_genind)
mat_w <- mat_gen_dist(data_ex_genind, dist = "DPS")
mat_dist <- mat_geo_dist(data = pts_pop_ex,
                         ID = "ID",
                         x = "x",
                         y = "y")
mat_dist <- mat_dist[order(as.character(row.names(mat_dist))),
                   order(as.character(colnames(mat_dist)))]
g1 <- gen_graph_topo(mat_w = mat_w, topo = "mst")
g2 <- gen_graph_topo(mat_w = mat_w, mat_topo = mat_dist, topo = "gabriel")
g <- graph_plot_compar(x = g1, y = g2,
                       crds = pts_pop_ex)

graph4lg documentation built on Feb. 16, 2023, 5:43 p.m.