I want to compute the Everett-Valente Brokerage Score for each node in my directed network (Everett and Valente 2016). This score is based on betweenness centrality. Essentially, this controls for network size. The ability of a broker to control information/resource flows is moderated by network size and/or tie-redundancy. For an undirected graph, the Everett - Valente Brokerage Score is calculated thus:
- Compute node betweenness centrality.
- Double the computed betweenness centrality for each node and add (n - 1) to every non-pendant entry.
- Divide each non-zero score by the degree of the node.
I plan to use if_else statements to deal with non-pendant and zero scores e.g.
g <- g %>%
activate(nodes) %>%
mutate(betweenness = centrality_betweenness(),
ev_brokerage = if_else(..if_else(..)..))
I do not know how to implement the ev_brokerage (the conditional statements). To extend this to the directed case, Everett and Valente (2016) provide the following rules:
For in-EV brokerage:
- Compute node betweenness centrality for v.
- If node betweenness centrality = 0 add j, where j = number of vertices that can reach v.
- Divide each non-zero sum by the in-degree of v.
For out-EV brokerage:
- Compute node betweenness centrality for v.
- If node betweenness centrality = 0 add k, where k = number of vertices that v can reach.
- Divide each non-zero sum by the out-degree of v.
EV brokerage of v = average of in-EV and out-EV.
If somebody can help me with the mutate() statement, I would be grateful. I would like to know how I can work out j and k in the directed case, and figure out non-pendant nodes in the undirected case.
This would be a lot simpler to reason about (and generalize) if you just made it into a standalone function that calculated scores for an igraph object. Then it can be adapted to something tidygraph-friendly.
It's fairly straightforward with undirected graphs as you don't need to nest any control flow.
Here's an example directed graph...
Rather than nesting
ifelse()s inside each other, you can wrap them withdplyr::case_when()(but it still should go inside a proper function that can be tested and verified).Here's the full table to check the math: