node_rank {tidygraph}R Documentation

Calculate node ranking

Description

This set of functions tries to calculate a ranking of the nodes in a graph so that nodes sharing certain topological traits are in proximity in the resulting order. These functions are of great value when composing matrix layouts and arc diagrams but could concievably be used for other things as well.

Usage

node_rank_hclust(
  method = "average",
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_anneal(
  cool = 0.5,
  tmin = 1e-04,
  swap_to_inversion = 0.5,
  step_multiplier = 100,
  reps = 1,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_branch_bound(
  weighted_gradient = FALSE,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_traveller(
  method = "two_opt",
  ...,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_two(
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_mds(
  method = "cmdscale",
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_leafsort(
  method = "average",
  type = "OLO",
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_visual(
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_spectral(
  normalized = FALSE,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_spin_out(
  step = 25,
  nstart = 10,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_spin_in(
  step = 5,
  sigma = seq(20, 1, length.out = 10),
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_quadratic(
  criterion = "2SUM",
  reps = 1,
  step = 2 * graph_order(),
  step_multiplier = 1.1,
  temp_multiplier = 0.5,
  maxsteps = 50,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_genetic(
  ...,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

node_rank_dendser(
  ...,
  dist = "shortest",
  mode = "out",
  weights = NULL,
  algorithm = "automatic"
)

Arguments

method

The method to use. See Functions section for reference

dist

The algorithm to use for deriving a distance matrix from the graph. One of

  • "shortest" (default): Use the shortest path between all nodes

  • "euclidean": Calculate the L2 norm on the adjacency matrix of the graph

  • "manhattan": Calculate the L1 norm on the adjacency matrix of the graph

  • "maximum": Calculate the supremum norm on the adjacenecy matrix of the graph

  • "canberra": Calculate a weighted manhattan distance on the adjacency matrix of the graph

  • "binary": Calculate distance as the proportion of agreement between nodes based on the adjacency matrix of the graph

or a function that takes a tbl_graph and return a dist object with a size matching the order of the graph.

mode

Which edges should be included in the distance calculation. For distance measures based on the adjacency matrix, 'out' will use the matrix as is, 'in' will use the transpose, and 'all' will take the mean of the two. Defaults to 'out'. Ignored for undirected graphs.

weights

An edge variable to use as weight for the shortest path calculation if dist = 'shortest'

algorithm

The algorithm to use for the shortest path calculation if dist = 'shortest'

cool

cooling rate

tmin

minimum temperature

swap_to_inversion

Proportion of swaps in local neighborhood search

step_multiplier

Multiplication factor for number of iterations per temperature

reps

Number of repeats with random initialisation

weighted_gradient

minimize the weighted gradient measure? Defaults to FALSE

...

Arguments passed on to other algorithms. See Functions section for reference

type

The type of leaf reordering, either 'GW' to use the "GW" method or 'OLO' to use the "OLO" method (both in seriation)

normalized

Should the normalized laplacian of the similarity matrix be used?

step

The number iterations to run per initialisation

nstart

The number of random initialisations to perform

sigma

The variance around the diagonal to use for the weight matrix. Either a single number or a decreasing sequence.

criterion

The criterion to minimize. Either "LS" (Linear Seriation Problem), "2SUM" (2-Sum Problem), "BAR" (Banded Anti-Robinson form), or "Inertia" (Inertia criterion)

temp_multiplier

Temperature multiplication factor between 0 and 1

maxsteps

The upper bound of iterations

Value

An integer vector giving the position of each node in the ranking

Functions

Examples

graph <- create_notable('zachary') %>%
  mutate(rank = node_rank_hclust())


[Package tidygraph version 1.3.1 Index]