strength: Vertex strength: sum of weights of incident edges

Description Usage Arguments Details Value Examples

View source: R/weights.R

Description

This is also called weighed degree.

Usage

1
strength(graph, mode = c("out", "in", "total", "all"))

Arguments

graph

Input graph.

mode

Whether to consider incoming (in), outgoing (out) or all (total) edges.

Details

For non-weighted graphs, the degree is returned as a fallback.

Value

Named numeric vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
G <- graph(
  data.frame(
    stringsAsFactors = FALSE,
    id = c("a", "b", "c", "d")
  ),
  data.frame(
    stringsAsFactors = FALSE,
    from   = c("a", "a", "b", "b", "c"),
    to     = c("b", "d", "d", "c", "a"),
    weight = c( 1 ,  2 ,  1 ,  3 ,  2 )
  )
)
strength(G)

G2 <- graph(
  data.frame(
    stringsAsFactors = FALSE,
    id = c("a", "b", "c", "d")
  ),
  data.frame(
    stringsAsFactors = FALSE,
    from   = c("a", "a", "b", "b", "c"),
    to     = c("b", "d", "d", "c", "a")
  )
)
strength(G2)

MangoTheCat/simplegraph documentation built on May 7, 2019, 2:23 p.m.