getVertices: Get vertices from a graph

Description Usage Arguments Value Examples

View source: R/getVertices.R

Description

# Vertices probababilites to be chosen can depend on 3 criterias: k - Their centrality index: degree, betweenness, etc (preferential attachment) t - Their topological distance from reference node(s) s - Their spatial distance from reference node(s) if all weigths are set to 0, its equals to random mode

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
getVertices(
  g,
  n = 1,
  vs = V(g),
  mode = c("random", "targeted", "proba"),
  ct.ind.FUN = betweenness,
  ct.ind.w = 1,
  v.dist.ref = V(g),
  sp.dist.attr = "dist",
  sp.dist.w = 0,
  topo.dist.w = 0
)

Arguments

g

igraph object.

n

numeric; number of vertices to return (default: 1).

vs

igraph.vs; sequence in which to choose the n vertices. (default: all graph vertices).

mode

character; method used to choose the n vertices , eitheer 'random', 'targeted' or 'proba'. Modes 'targeted' and 'proba' can use several criterias such as centrality index with ct.ind.FUN. (default: 'random').

ct.ind.FUN

function used to compute centrality index of the vertices sequence. Used only if ci.w > 0. Default is betweenness but can also be degree.

ct.ind.w

exponent weighting vertices centrality index in probabilities mix. If negative, less central vertices are more likely to be chosen. Default is 1.

v.dist.ref

igraph.vs of reference from which to compute sp.dist and topo.dist.

sp.dist.attr

Name of edge attribute containing spatial distance.

sp.dist.w

Exponent weighting spatial distance in probabilities mix.

topo.dist.w

Exponent weighting topological distance in probabilities mix.

Value

An igraph.vs vertex or vertices sequence.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(igraph)
set.seed(123)
g = erdos.renyi.game(100, 120, 'gnm')
## Get a random vertex
getVertices(g)
## Get vertex with highest betweenness
v = getVertices(g, mode="targ")
v==V(g)[which.max(betweenness(g))]
## Get vertex with highest degree
v = getVertices(g, mode="targeted", ct.ind.FUN=degree)
v==V(g)[which.max(degree(g))]

MiloMonnier/supplynet documentation built on Feb. 16, 2021, 8:03 p.m.