netemd_single_pair: Internal function to compute the minimum Earth Mover's...

View source: R/measures_net_emd.R

netemd_single_pairR Documentation

Internal function to compute the minimum Earth Mover's Distance between standarized and translated histograms

Description

Calculates the minimum Earth Mover's Distance (EMD) between two discrete histograms after normalising each histogram to unit mass and variance. This is calculated as follows: 1. Normalise each histogram to have unit mass and unit variance 2. Find the minimum EMD between the histograms

Usage

netemd_single_pair(
  dhist1,
  dhist2,
  method = "optimise",
  smoothing_window_width = 0
)

Arguments

method

The method to use to find the minimum EMD across all potential offsets for each pair of histograms. Default is "optimise" to use R's built-in stats::optimise method to efficiently find the offset with the minimal EMD. However, this is not guaranteed to find the global minimum if multiple local minima EMDs exist. You can alternatively specify the "exhaustive" method, which will exhaustively evaluate the EMD between the histograms at all offsets that are candidates for the minimal EMD.

smoothing_window_width

Width of "top-hat" smoothing window to apply to "smear" point masses across a finite width in the real domain. Default is 0, which results in no smoothing. Care should be taken to select a smoothing_window_width that is appropriate for the discrete domain (e.g.for the integer domain a width of 1 is the natural choice)

dhists_1

A dhist discrete histogram object or a list of such objects

dhists_2

A dhist discrete histogram object or a list of such objects

Value

A list with the following named elements net_emd: the NetEMD for the set of histogram pairs, min_offsets: the associated offsets giving the minimal EMD for each pair of histograms and min_offset_std: Offset used in the standardised histograms.

Examples

 require(igraph)
 goldstd_1 <- graph.lattice(c(8,8)) 
 goldstd_2 <- graph.lattice(c(44,44)) 
 props_1 <- count_orbits_per_node(graph = goldstd_1,max_graphlet_size = 5)
 props_2 <- count_orbits_per_node(graph = goldstd_2,max_graphlet_size = 5)
 dhists_1<- graph_features_to_histograms(props_1)
 dhists_2<- graph_features_to_histograms(props_2)
 # Obtain the minimum NetEMD_edges between the histograms 
 netemd_single_pair(dhists_1[[1]],dhists_2[[1]],method = "optimise",smoothing_window_width = 0)

alan-turing-institute/network-comparison documentation built on June 7, 2022, 10:41 p.m.