node_in_community() returns a single community partition of a network,
drawing on all the community detection algorithms available for that
type of network.
By default it selects a partition. Where feasible (a small enough network), the optimal problem solving technique is used to ensure the maximal modularity partition. For larger networks, it identifies the applicable algorithms, runs each of them, and returns the partition with the largest modularity score.
Where consensus = TRUE it combines the partitions instead.
Each applicable algorithm is run, the stochastic ones repeatedly,
and the algorithms are then rerun on how often each pair of nodes
is placed together until they agree.
This costs considerably more time than selection,
but does not rest the answer on a single run of a single algorithm.
node_in_community(
.data,
k = NULL,
max_k = 8L,
consensus = FALSE,
times = 20,
Kmax = NULL
)A network object of class stocnet, igraph, tbl_graph, network, or similar.
Internally any of these will be coerced to an efficient implementation.
For more information on possible coercions, see e.g. manynet::as_stocnet().
Integer indicating the target number of communities to return.
By default NULL, in which case the algorithm returns the number of
communities that it finds itself.
Alternatively, a character string naming a selection method:
"silhouette" selects the number that maximises the mean silhouette
width over geodesic distances, "elbow" selects the number at the
elbow of the coverage curve, and "strict" returns the partition in
which no tie crosses a group, i.e. the components.
Prefer "silhouette"; the elbow method is unreliable where the
coverage curve has no clear elbow.
If the algorithm cannot return exactly the number of communities
requested, a warning is given and the nearest number is returned.
Integer indicating the maximum number of communities to
evaluate for "silhouette" and "elbow". By default 8.
Otherwise ignored.
Note that for node_in_louvain() and node_in_leiden() each candidate
requires its own search over the resolution parameter,
so a large max_k is costly on large networks.
Logical, whether to combine the partitions of all the
applicable algorithms instead of selecting the one with the highest
modularity. By default FALSE, since combining them costs more time.
This argument is ignored on a network small enough for
node_in_optimal(), which already returns the maximum modularity
partition.
Integer scalar, how many times the algorithm repeats its work. Where the algorithm is stochastic, this is how many times it runs, and the best or the most frequent result is kept. Where the algorithm searches, this is how many steps the search takes. More repetitions give a more reliable result and take longer, so each function documents its own default.
Deprecated. The former spelling of max_k.
Still accepted, but warns; please use max_k instead.
A node_member character vector the length of the nodes in the network,
of group memberships "A", "B", etc for each node.
If the network is labelled,
then the assignments will be labelled with the nodes' names.
times applies only when consensus = TRUE, and is 20 by default.
Deterministic algorithms are run once however it is set.
Lancichinetti, Andrea, and Santo Fortunato. 2012. "Consensus clustering in complex networks". Scientific Reports 2: 336. doi:10.1038/srep00336
Tagarelli, Andrea, Alessia Amelio, and Francesco Gullo. 2017. "Ensemble-based Community Detection in Multilayer Networks". Data Mining and Knowledge Discovery 31: 1506-1543. doi:10.1007/s10618-017-0528-8
Other community:
member_community_hier,
member_community_non
Other memberships:
member_brokerage,
member_cliques,
member_community_hier,
member_community_non,
member_components,
member_core,
member_diffusion,
member_equivalence
Other nodal:
mark_core,
mark_degree,
mark_diff,
mark_nodes,
mark_select_node,
measure_assort_node,
measure_broker_node,
measure_brokerage,
measure_central_between,
measure_central_close,
measure_central_degree,
measure_central_eigen,
measure_closure_node,
measure_core,
measure_diffusion_node,
measure_diverse_node,
member_brokerage,
member_cliques,
member_community_hier,
member_community_non,
member_components,
member_core,
member_diffusion,
member_equivalence,
motif_brokerage_node,
motif_clique,
motif_composition,
motif_exposure,
motif_node,
motif_path
node_in_community(ison_adolescents)
#> 3 groups
#> Betty Sue Alice Jane Dale Pam Carol Tina
#> 1 A A B B B C C C