Skip to contents

Summing up the edge weights of the adjacent edges for each vertex.

Usage

strength(
  graph,
  vids = V(graph),
  mode = c("all", "out", "in", "total"),
  loops = TRUE,
  weights = NULL
)

Arguments

graph

The input graph.

vids

The vertices for which the strength will be calculated.

mode

Character string, “out” for out-degree, “in” for in-degree or “all” for the sum of the two. For undirected graphs this argument is ignored.

loops

Logical; whether the loop edges are also counted.

weights

Weight vector. If the graph has a weight edge attribute, then this is used by default. If the graph does not have a weight edge attribute and this argument is NULL, then a degree() is called. If this is NA, then no edge weights are used (even if the graph has a weight edge attribute).

Value

A numeric vector giving the strength of the vertices.

References

Alain Barrat, Marc Barthelemy, Romualdo Pastor-Satorras, Alessandro Vespignani: The architecture of complex weighted networks, Proc. Natl. Acad. Sci. USA 101, 3747 (2004)

See also

Author

Gabor Csardi csardi.gabor@gmail.com

Examples


g <- make_star(10)
E(g)$weight <- seq(ecount(g))
strength(g)
#>  [1] 45  1  2  3  4  5  6  7  8  9
strength(g, mode = "out")
#>  [1] 0 1 2 3 4 5 6 7 8 9
strength(g, mode = "in")
#>  [1] 45  0  0  0  0  0  0  0  0  0

# No weights, a warning is given
g <- make_ring(10)
strength(g)
#>  [1] 2 2 2 2 2 2 2 2 2 2