DiagrammeR (version 0.9.0)

get_betweenness: Get betweenness centrality scores

Description

Get the betweenness centrality scores for all nodes in a graph.

Usage

get_betweenness(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

a data frame with betweenness scores for each of the nodes.

Examples

Run this code
# NOT RUN {
# Create a random graph
graph <-
  create_random_graph(
    10, 22, set_seed = 1)

# Get the betweenness scores for nodes in the graph
get_betweenness(graph)
#>    id betweenness
#> 1   1    6.633333
#> 2   2    5.638095
#> 3   3    1.904762
#> 4   4    4.019048
#> 5   5    8.157143
#> 6   6    2.000000
#> 7   7   10.157143
#> 8   8    8.857143
#> 9   9    3.466667
#> 10 10    1.166667

# Add the betweenness values to the graph
# as a node attribute
graph <-
  graph %>%
  join_node_attrs(
    get_betweenness(.))
# }

Run the code above in your browser using DataLab