MyNixOS website logo
Description

Approximate Maximisation of Nestedness in Bipartite Graphs.

Functions to generate graphs that maximise the NODF (nestedness metric based on overlap and decreasing fill) metric for a given number of rows, columns and links. NODF was originally defined by Almeida-Neto et al. (2008) <doi:10.1111/j.0030-1299.2008.16644.x>. As nestedness in ecological networks depends on the size of the networks we require normalisation to make them comparable. We offer three highly optimised algorithms to find the optimising graphs so that users can choose an appropriate trade off between computation time and NODF value for the task at hand.

BuildStatus codecov

Overview

maxnodf calculates the maximum NODF value that can be achieved in a bipartite network with a given number of rows, columns and links.

Installation

You can install maxnodf from github with:

install.packages("devtools") # install devtools if needed
devtools::install_github("christophhoeppke/maxnodf")

Use

maxnodf has three functions:

maxnodf()

For a given network, maxnodf calculates the maximum nestedness that can be achieved in a network with a given number of rows, columns and links, subject to the constraint that all rows and columns must have at least one link (i.e. row and column totals must always be >= 1). As input, maxnodf() takes either a numeric matrix describing a bipartite network (a bipartite incidence matrix where elements are positive numbers if nodes interact, and 0 otherwise) or a numeric vector of length three of the form c(#Rows, #Columns, #Links).

This allows nestedness values to be normalised as NODF/max(NODF) following Song et al (2017), where NODF is the raw NODF of the network and max(NODF) is the maximum nestedness that can be achieved in a network with the same number of rows, columns and links as web, subject to the constraint that all rows and columns must have at least one link (as calculated by maxnodf())

maxnodf has three algorithms for finding the maximum nestedness of a bipartite network. These can be set using the quality argument. Lower quality settings are faster, but find worse optima. Higher quality settings are slower, but find better optima.

  • quality = 0, uses a greedy algorithm.
  • quality = 1, uses a greedy algorithm plus hillclimbing.
  • quality = 2, uses a simulated annealing algorithm, with the greedy algorithm output as the start point. Best results, but requires the most computation time.

NODFc()

To control for maximum nestedness, connectance and network size, Song et al. (2017) propose the NODF_c metric: (NODF/max(NODF))/(C * log(S)) where C is the network connectance, S is the geometric mean of the number of plants and pollinators in the network, NODF is the raw NODF of the network and max(NODF) is the maximum nestedness that can be achieved in a network with the same number of rows, columns and links as web, subject to the constraint that all rows and columns must have at least one link (as calculated by maxnodf()). NODFc calculates this NODF_c metric. As input, NODFc takes a numeric matrix describing a bipartite network, as well as the same quality argument values described above.

nodf_cpp()

A simple function that takes a bipartite matrix as input, and returns the raw NODF value of the matrix. Used internally by maxnodf. Calculation is quick, because it is implemented in C++.

Example

m <- matrix(0,10,10) # initialise an empty network
m[1,] <- 1 # ensure all row species have at least one link
m[,1] <- 1 # ensure all column species have at least one link
m[2:10,2:10] <- sample(0:1, 9 * 9, replace = TRUE) # randomise the rest of the matrix
maxnodf(web = m, quality = 2) # calculate the maximum nestedness

License

The code is released under the MIT license (see LICENSE file).

References

Song, C., Rohr, R.P. and Saavedra, S., 2017. Why are some plant–pollinator networks more nested than others? Journal of Animal Ecology, 86(6), pp.1417-1424.

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows