Distance Measures for Networks

Network is a prevalent form of data structure in many fields. As an object of analysis, many distance or metric measures have been proposed to define the concept of similarity between two networks. We provide a number of distance measures for networks. See Jurman et al (2011) for an overview on spectral class of inter-graph distance measures.

CRAN_Status_Badge Travis-CI Build Status

NetworkDistance package is a collection of inter-, *between-*graph distance measures. Instead of graph distance that measures the degree of farness between nodes within a graph, we consider each network as an object and compute distance between those objects.


You can install the released version of NetworkDistance from CRAN with:


or the development version from github:



Surely, the first thing we are always bound to do is to load the package,


Suppose you have N network objects represented as square adjacency matrices. All the functions in the package require your data to be in a form of list whose elements are your adjacency matrices. Let's load example data graph20.

data(graph20)     # use `help(graph20)' to see more details.
typeof(graph20)   # needs to be a list
#> [1] "list"

Before proceeding any further, since we have two types of graphs - densely and sparsely connected with p = 0.8 and p = 0.2 - we know that the distance matrix should show block-like pattern. Below is two example graphs from the dataset. Once you have your data in such a form, all you've got is to run a single-line code to acquire distance numerics, resulting in either a dist class object or a square matrix. For example, let's compute graph diffusion distance by Hammond et al. (2013) on our example set.

dist.gdd <- nd.gdd(graph20)  # return as a 'dist' object

and you can see the discriminating pattern from the distance matrix dist.gdd$D with black represents 0 and white represents the largest positive number, indicating large deviation from 0. Finally, let's compare different methods as well.

dist.wsd <- nd.wsd(graph20)              # spectrum-weighted distance
dist.dsd <- nd.dsd(graph20, type="SLap") # discrete spectral measure
dist.nfd <- nd.nfd(graph20)              # network flow distance

Code of Conduct

Please note that the 'NetworkDistance' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.


News for Package NetworkDistance

Changes in version 0.3.1

  • Error fixed in nd.him (Franck Lejzerowicz at UCSD).
  • Initialize the following documentation:
    • NEWS for keeping record of updates.
    • README to briefly introduce the method.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.3.4 by Kisung You, 5 months ago

Browse source code at https://github.com/cran/NetworkDistance

Authors: Kisung You [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports Matrix, Rcpp, Rdpack, RSpectra, doParallel, foreach, graphon, parallel, stats, igraph, network, pracma, utils

Suggests graphics, knitr, rmarkdown

Linking to Rcpp, RcppArmadillo

See at CRAN