These functions wraps a set of functions that all measures quantities of the local neighborhood of each node. They all return a vector or list matching the node position.
local_size(order = 1, mode = "all", mindist = 0)
local_members(order = 1, mode = "all", mindist = 0)
local_triangles()
local_ave_degree(weights = NULL)
local_transitivity(weights = NULL)
Integer giving the order of the neighborhood.
Character constant, it specifies how to use the direction of
the edges if a directed graph is analyzed. For ‘out’ only the
outgoing edges are followed, so all vertices reachable from the source
vertex in at most order
steps are counted. For ‘"in"’ all
vertices from which the source vertex is reachable in at most order
steps are counted. ‘"all"’ ignores the direction of the edges. This
argument is ignored for undirected graphs.
The minimum distance to include the vertex in the result.
An edge weight vector. For local_ave_degree
: If this argument
is given, the average vertex strength is calculated instead of vertex degree.
For local_transitivity
: if given weighted transitivity using the approach by
A. Barrat will be calculated.
A numeric vector or a list (for local_members
) with elements
corresponding to the nodes in the graph.
local_size()
: The size of the neighborhood in a given distance from
the node. (Note that the node itself is included unless mindist > 0
). Wraps igraph::ego_size()
.
local_members()
: The members of the neighborhood of each node in a
given distance. Wraps igraph::ego()
.
local_triangles()
: The number of triangles each node participate in. Wraps igraph::count_triangles()
.
local_ave_degree()
: Calculates the average degree based on the neighborhood of each node. Wraps igraph::knn()
.
local_transitivity()
: Calculate the transitivity of each node, that is, the
propensity for the nodes neighbors to be connected. Wraps igraph::transitivity()
# Get all neighbors of each graph
create_notable('chvatal') %>%
activate(nodes) %>%
mutate(neighborhood = local_members(mindist = 1))
#> # A tbl_graph: 12 nodes and 24 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Node Data: 12 × 1 (active)
#> neighborhood
#> <list>
#> 1 <int [4]>
#> 2 <int [4]>
#> 3 <int [4]>
#> 4 <int [4]>
#> 5 <int [4]>
#> 6 <int [4]>
#> 7 <int [4]>
#> 8 <int [4]>
#> 9 <int [4]>
#> 10 <int [4]>
#> 11 <int [4]>
#> 12 <int [4]>
#> #
#> # Edge Data: 24 × 2
#> from to
#> <int> <int>
#> 1 6 7
#> 2 7 8
#> 3 8 9
#> # ℹ 21 more rows
# These are equivalent
create_notable('chvatal') %>%
activate(nodes) %>%
mutate(n_neighbors = local_size(mindist = 1),
degree = centrality_degree()) %>%
as_tibble()
#> # A tibble: 12 × 2
#> n_neighbors degree
#> <dbl> <dbl>
#> 1 4 4
#> 2 4 4
#> 3 4 4
#> 4 4 4
#> 5 4 4
#> 6 4 4
#> 7 4 4
#> 8 4 4
#> 9 4 4
#> 10 4 4
#> 11 4 4
#> 12 4 4