| Title: | Analysis and Visualization of Complex Networks |
|---|---|
| Description: | Provides tools for the analysis, visualization, and manipulation of dynamical, social (Saqr et al. (2024) <doi:10.1007/978-3-031-54464-4_10>) and complex networks (Saqr et al. (2025) <doi:10.1145/3706468.3706513>). The package supports multiple network formats and offers flexible tools for heterogeneous, multi-layer, and hierarchical network analysis with simple syntax and extensive toolset. |
| Authors: | Mohammed Saqr [aut, cph], Sonsoles López-Pernas [aut, cre, cph] |
| Maintainer: | Sonsoles López-Pernas <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.7.6 |
| Built: | 2026-10-08 09:18:43 UTC |
| Source: | https://github.com/sonsoleslp/cograph |
Abbreviates labels to a maximum length, adding ellipsis if truncated.
abbrev_label(label, abbrev = NULL, n_labels = NULL) label_abbrev(label, abbrev = NULL, n_labels = NULL)abbrev_label(label, abbrev = NULL, n_labels = NULL) label_abbrev(label, abbrev = NULL, n_labels = NULL)
label |
Character vector of labels to abbreviate. |
abbrev |
Abbreviation control:
|
n_labels |
Number of labels (used for "auto" mode). If NULL, uses length(label). |
Character vector of (possibly abbreviated) labels.
abbrev_label(colnames(regulation_net), abbrev = 4)abbrev_label(colnames(regulation_net), abbrev = 4)
Appends edges between existing nodes. An endpoint that is not a node of the
network raises a cograph_bad_selection error.
add_edges(x, from, to, weight = 1, ..., keep_format = FALSE, directed = NULL)add_edges(x, from, to, weight = 1, ..., keep_format = FALSE, directed = NULL)
x |
Network input. |
from |
Source nodes, by label or index. |
to |
Target nodes, by label or index. The same length as |
weight |
Numeric weight for the new edges, length 1 or
|
... |
Named vectors of extra edge attributes, length 1 or
|
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network with the new edges, or the input format
when keep_format = TRUE. An edge that already exists has its weight
replaced, and a cograph_edges_replaced warning says how many.
When the igraph package is attached it masks this function with
igraph::add_edges(), which takes an igraph object. Use
cograph::add_edges() to be explicit.
remove_edges, add_nodes,
bind_networks
add_edges(regulation_net, from = "Share", to = "Explore", weight = 0.5)add_edges(regulation_net, from = "Share", to = "Explore", weight = 0.5)
Appends new nodes, identified by label, to a network. A label that already
exists raises a cograph_bad_selection error.
add_nodes(x, labels, ..., keep_format = FALSE, directed = NULL)add_nodes(x, labels, ..., keep_format = FALSE, directed = NULL)
x |
Network input. |
labels |
Character vector of labels for the new nodes. |
... |
Named vectors of node attributes for the new nodes, each of
length 1 (recycled) or |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network with the new nodes appended (isolated until
edges are added), or the input format when keep_format = TRUE.
remove_nodes, add_edges,
mutate_nodes
add_nodes(regulation_net, labels = "Revise")add_nodes(regulation_net, labels = "Revise")
Combines multiple network layers into a single network.
aggregate_layers( layers, method = c("sum", "mean", "max", "min", "union", "intersection"), weights = NULL ) lagg( layers, method = c("sum", "mean", "max", "min", "union", "intersection"), weights = NULL )aggregate_layers( layers, method = c("sum", "mean", "max", "min", "union", "intersection"), weights = NULL ) lagg( layers, method = c("sum", "mean", "max", "min", "union", "intersection"), weights = NULL )
layers |
List of adjacency matrices of the same dimensions |
method |
Aggregation: "sum" (default), "mean", "max", "min", "union"
or "intersection". |
weights |
Optional numeric vector of layer weights, one per layer,
used only by |
The aggregated adjacency matrix, with the dimnames of the first
layer. A list with a single layer is aggregated the same way, so
"union" and "intersection" binarize it and "sum"
multiplies it by its layer weight.
layers <- list(forward = regulation_net, backward = t(regulation_net)) aggregate_layers(layers, method = "mean")layers <- list(forward = regulation_net, backward = t(regulation_net)) aggregate_layers(layers, method = "mean")
Aggregates a vector of edge weights into a single value. The method names
follow those of igraph's edge.attr.comb argument.
aggregate_weights(w, method = "sum", n_possible = NULL) wagg(w, method = "sum", n_possible = NULL)aggregate_weights(w, method = "sum", n_possible = NULL) wagg(w, method = "sum", n_possible = NULL)
w |
Numeric vector of edge weights. |
method |
Aggregation method: "sum", "mean", "median", "max", "min",
"prod", "density", "geomean". Default "sum". Any other value is an error.
|
n_possible |
Number of possible edges (used only by
|
A single numeric value, or 0 when no non-zero, non-NA weight remains.
aggregate_weights(regulation_net, method = "mean")aggregate_weights(regulation_net, method = "mean")
as_cograph() creates a cograph_network object from a matrix,
an edge list, or a network object of another package. to_cograph()
is an alias. The object is a named list that every cograph function
accepts.
as_cograph(x, directed = NULL, simplify = FALSE, ...) to_cograph(x, directed = NULL, ...) ## S3 method for class 'cograph_network' as.data.frame( x, row.names = NULL, optional = FALSE, ..., what = c("edges", "nodes") )as_cograph(x, directed = NULL, simplify = FALSE, ...) to_cograph(x, directed = NULL, ...) ## S3 method for class 'cograph_network' as.data.frame( x, row.names = NULL, optional = FALSE, ..., what = c("edges", "nodes") )
x |
Network input. One of a square numeric weight matrix, a data frame
edge list, an igraph object, a statnet network object, a qgraph object, a
tna object, or an existing |
directed |
Logical. Forces a directed or undirected interpretation.
|
simplify |
Logical or character. If |
... |
Passed from |
row.names |
|
optional |
Logical, as for |
what |
Which table |
A cograph_network prints a short description of its nodes, edges and
source, summary() reports counts and edge weight statistics,
plot() plots it with sn_render, and
as.data.frame() returns its edge or node table.
The accessor and setter functions are documented in get_nodes.
Producer packages may attach plotting hints under meta$splot. The
recognized fields are renderer (the cograph renderer to use),
weight (the edge column or matrix plotted as weight), and
defaults (a named list of renderer arguments). Entries in
defaults are defaults only, and arguments passed to splot
override them. renderer and weight define which view is plotted
and are not overridden by plot arguments.
as_cograph() and to_cograph() return a
cograph_network object, a named list with components:
nodesData frame with id, label, and optional
layout or metadata columns.
edgesData frame with integer from and to
columns (row numbers into nodes), weight, and extra
columns such as session and time for tna input. Repeated
rows of an edge list are kept as separate edges.
directedLogical. Whether the network is directed.
weightsThe n x n weight matrix for matrix and tna input,
or NULL (for example for an edge list).
dataThe original estimation data (sequence data, edge
list), or NULL.
metaMetadata list with source (input type), a
tna entry for tna input (type, group name and group index)
and, optionally, splot (rendering hints read by
splot).
node_groupsOptional data frame of node groupings.
as.data.frame() returns a base data frame. For
what = "edges" it has one row per edge with columns from and
to (node labels), weight, and any extra edge columns the
network carries, such as session or columns computed by
mutate_edges. For what = "nodes" it has one row per
node with the node table columns (id, label, layout
coordinates and any custom columns). to_df returns only
from, to and weight.
net <- as_cograph(regulation_net) as.data.frame(net, what = "edges")net <- as_cograph(regulation_net) as.data.frame(net, what = "edges")
Converts an object to the mcml class, a representation of a
multi-cluster network that does not depend on the tna package.
as_mcml(x, ...) ## S3 method for class 'cluster_summary' as_mcml(x, ...) ## S3 method for class 'group_tna' as_mcml(x, clusters = NULL, method = "sum", type = "tna", directed = TRUE, ...) ## S3 method for class 'mcml' as_mcml(x, ...) ## Default S3 method: as_mcml(x, ...)as_mcml(x, ...) ## S3 method for class 'cluster_summary' as_mcml(x, ...) ## S3 method for class 'group_tna' as_mcml(x, clusters = NULL, method = "sum", type = "tna", directed = TRUE, ...) ## S3 method for class 'mcml' as_mcml(x, ...) ## Default S3 method: as_mcml(x, ...)
x |
A |
... |
Additional arguments passed to methods. |
clusters |
Integer or character vector of row-to-group assignments.
Required when the |
method |
Aggregation method for macro weights (default |
type |
Transition type (default |
directed |
Logical; whether the network is directed (default |
An mcml object with components macro, clusters,
cluster_members, and meta.
An mcml object.
An mcml object. When clusters is provided,
macro$data contains the cluster assignments and macro$weights
is NULL.
The input mcml object unchanged.
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) as_mcml(csum(regulation_net, clusters = clusters, type = "tna"))clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) as_mcml(csum(regulation_net, clusters = clusters, type = "tna"))
Converts a cluster_summary or mcml object to tna models that
can be used with the functions of the tna package. The result holds a macro
(cluster-level) model and one model of the internal transitions of each
cluster, as a flat group_tna object.
as_tna(x) ## S3 method for class 'cluster_summary' as_tna(x) ## S3 method for class 'mcml' as_tna(x) ## Default S3 method: as_tna(x)as_tna(x) ## S3 method for class 'cluster_summary' as_tna(x) ## S3 method for class 'mcml' as_tna(x) ## Default S3 method: as_tna(x)
x |
A |
The tna package must be installed. Without it, the function raises an error.
A per-cluster tna cannot be created when:
The cluster has only 1 node (no internal transitions possible)
Some nodes in the cluster have no outgoing edges (row sums to 0)
These clusters are left out of the result with a warning of class
cograph_cluster_dropped, which names each cluster and the nodes
that have no transition within it. The macro (cluster-level) model still
includes all clusters.
A group_tna object, a flat named list of tna objects. The
first element is named "macro" and holds the cluster-level
transitions. The remaining elements are named by cluster and hold the
internal transitions of each cluster.
A tna object of cluster-level transitions, with
weights (k x k transition matrix), inits (initial
distribution) and labels (cluster names).
One tna object per cluster, with weights
(n_i x n_i matrix), inits (initial distribution) and
labels (node labels). A cluster that cannot become a tna
model is left out with a warning (see Excluded Clusters).
A group_tna object (flat list of tna objects: macro + per-cluster).
A group_tna object (flat list of tna objects: macro + per-cluster).
A tna object constructed from the input.
csum to create the input object,
plot_mcml for visualization without conversion,
tna::tna for the underlying tna constructor
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) as_tna(csum(regulation_net, clusters = clusters, type = "tna"))clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) as_tna(csum(regulation_net, clusters = clusters, type = "tna"))
Computes the degree assortativity coefficient, measuring the tendency of nodes to connect to other nodes with similar degree. Positive values indicate assortative mixing (high-degree nodes connect to high-degree nodes), negative values indicate disassortative mixing.
assortativity(x, directed = NULL, type = NULL, digits = NULL, ...)assortativity(x, directed = NULL, type = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
type |
Character string specifying which degree correlation to compute,
or NULL (default) to choose automatically: |
digits |
Integer or NULL. Round result to this many decimal places. Default NULL (no rounding). |
... |
Not used. Any argument supplied here raises an
|
The degree assortativity coefficient is defined as the Pearson correlation coefficient between the degrees of nodes at either end of each edge (Newman 2002):
where is the fraction of edges connecting degree- to
degree- vertices, is the excess degree distribution, and
its variance.
Because the Pearson correlation is invariant to subtracting a constant, the implementation computes the correlation of the raw degrees at the two ends of each edge, counting every undirected edge in both orientations. This is numerically identical to the formula above. Degrees are unweighted counts of edges, so edge weights do not enter the coefficient.
For directed networks, the coefficient is the Pearson correlation between
the source-end and target-end degrees over each edge in its stored
orientation, with the degree mode at each end chosen by type
(Foster et al. 2010).
The coefficient is NA when the network has no edges or when either
degree vector has zero variance.
An object of class "cograph_assortativity" with components:
Numeric scalar: the assortativity coefficient in
.
Character: the degree type used.
Logical: whether the network was treated as directed.
Numeric: number of nodes.
Numeric: number of edges.
The original input network.
Newman, M.E.J. (2002). Assortative mixing in networks. Physical Review Letters, 89(20), 208701. doi:10.1103/PhysRevLett.89.208701
Foster, J.G., Foster, D.V., Grassberger, P., & Paczuski, M. (2010). Edge direction and the structure of networks. PNAS, 107(24), 10815-10820. doi:10.1073/pnas.0912671107
assortativity_attribute, centrality,
network_summary
cograph::assortativity(regulation_net)cograph::assortativity(regulation_net)
Computes assortativity with respect to a node attribute, measuring the tendency of nodes to connect to others with similar attribute values. For categorical attributes, this computes the modularity-based nominal assortativity. For numeric attributes, this computes the Pearson correlation between attribute values at edge endpoints.
assortativity_attribute(x, values, directed = NULL, digits = NULL, ...) homophily(x, values, directed = NULL, digits = NULL, ...)assortativity_attribute(x, values, directed = NULL, digits = NULL, ...) homophily(x, values, directed = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
values |
Named vector of attribute values whose names cover every node name, or an unnamed vector of length equal to the number of nodes, in node order. A numeric vector is treated as scalar and any other vector as nominal. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
digits |
Integer or NULL. Round the coefficient to this many decimal places. Default NULL (no rounding). |
... |
Not used. Any argument supplied here raises an
|
For categorical (nominal) attributes, the coefficient is:
where is the mixing matrix with = fraction of
edges connecting type to type .
For numeric (scalar) attributes, the coefficient is the Pearson correlation
between attribute values at edge endpoints (computed over both orientations
of every edge when the network is undirected). Any non-numeric
values vector (character or factor) is treated as nominal.
The coefficient is NA when the network has no edges, when a nominal
attribute has a single category, or when either value vector has zero
variance.
An object of class "cograph_assortativity" with components:
Numeric scalar: assortativity coefficient.
Character: "nominal" or "scalar".
Logical: whether the network was treated as directed.
Numeric: number of nodes.
Numeric: number of edges.
The attribute values used, named by node and in node order.
The original input network.
Newman, M.E.J. (2003). Mixing patterns in networks. Physical Review E, 67(2), 026126. doi:10.1103/PhysRevE.67.026126
assortativity, detect_communities
cograph::assortativity_attribute(regulation_net, values = rep(c("self", "social"), each = 5))cograph::assortativity_attribute(regulation_net, values = rep(c("self", "social"), each = 5))
Replaces every surviving weight with 1 and drops edges whose weight is at
or below the threshold. The operation corresponds to
sna::event2dichot() with an absolute threshold.
binarize( x, threshold = 0, absolute = TRUE, signed = FALSE, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )binarize( x, threshold = 0, absolute = TRUE, signed = FALSE, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
threshold |
Numeric. Edges whose weight exceeds this value are kept and set to 1. Default 0, which keeps every existing edge. |
absolute |
Logical. Compare |
signed |
Logical. If TRUE, negative edges become |
keep_isolates |
Logical. Keep nodes that end up with no edges? Default TRUE. |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network whose weights are all 1 (or, when
signed = TRUE, 1 for a positive edge and -1 for a
negative one), or the input format when keep_format = TRUE. Nodes
left without edges are kept and reported in a
cograph_isolates_created warning, unless
keep_isolates = FALSE.
Butts, C. T. (2008). Social network analysis with sna. Journal of Statistical Software, 24(6), 1–51.
threshold_edges, normalize_weights
binarize(regulation_net, threshold = 0.1)binarize(regulation_net, threshold = 0.1)
Aligns two networks on node labels and combines their edges.
bind_networks( x, y, method = c("union", "intersection", "difference"), weight = c("sum", "mean", "max", "min", "first"), keep_format = FALSE, directed = NULL )bind_networks( x, y, method = c("union", "intersection", "difference"), weight = c("sum", "mean", "max", "min", "first"), keep_format = FALSE, directed = NULL )
x, y
|
Network inputs. |
method |
How to combine the edge sets:
|
weight |
How to combine the weights of an edge present in both:
|
keep_format |
Logical. Return |
directed |
Logical or NULL. If NULL (default), the result is directed when either input is. |
A cograph_network over the combined node set, or x's
format when keep_format = TRUE. Nodes are ordered with x's
first, then any node only y has.
bind_networks(regulation_net, t(regulation_net))bind_networks(regulation_net, t(regulation_net))
Computes centrality measures for nodes in a network and returns a tidy data frame. Accepts matrices, edge-list data frames, igraph objects, cograph_network, or tna objects.
centrality( x, type = c("basic", "extended", "all"), measures = NULL, include = NULL, mode = "all", normalized = FALSE, weighted = TRUE, directed = NULL, loops = TRUE, simplify = "sum", digits = NULL, sort_by = NULL, cutoff = -1, invert_weights = NULL, alpha = 1, damping = 0.85, personalized = NULL, transitivity_type = "local", isolates = "nan", lambda = 1, diffusion_method = NULL, k = 3, states = NULL, decay_parameter = 0.5, dmnc_epsilon = 1.7, membership = NULL, katz_alpha = 0.1, hubbell_weight = 0.5, shapley_k = 2, shapley_cutoff = 2, s_shell_a = 0.5, discount_p = 0.01, ncvote_theta = 0.5, comm_r = "max_intra", ld_radius = 2, enrenew_depth = 2, voterank_lambda = 0.1, contraction_rho = 5, wks_alpha = 1, wks_beta = 1, renewed_threshold = 2, kpath_k = 3, kpath_len = 3, epc_threshold = 0.5, epc_runs = 1000, epc_seed = NULL, betweenness_delta = 1, closeness_delta = 1, gravity_mass = "kshell", gravity_radius = 3, mdd_lambda = 0.7, volume_radius = 2, diffusion_q = 1, diffusion_steps = 3, ds_beta = 0.1, ds_mu = 1, ds_steps = 5, cda_alpha = 0.5, icc_alpha = 0.2, exogenous_base = "reverse_closeness", wlr_alpha = 1, alr_h_mode = "all", grc_gamma = 1, rwd_decay = 0.5, rwd_node_weights = NULL, linerank_aggregation = "probability", bridging_steps = 2, bridging_values = NULL, proximal_variant = "source", exf_alpha = 2, beta_direction = "positive", ninl_order = 3, ninl_radius = NULL, map_flow = "unrecorded", map_convention = "paper", sr_prior = 0, mcgm_radius = 2, mcgm_alpha = NULL, dkgm_radius = 2, nd_order = 2, nd_decay = 0.2, nd_mass = "degree", ira_mass = "coreness", ira_alpha = 1, ira_tol = 1e-06, ira_max_iter = 1000, iira_beta = 0.2, iira_steps = 50, hcc_delta = 0.5, lhc_radius = 2, tpr_alpha = 0.85, tpr_k = 0.85, tpr_decay = 1, tpr_tol = 1e-14, tpr_max_iter = 1000, rsp_beta = 0.01, rsp_cost = c("inverse", "weight"), re_indexes = c("degree", "closeness", "betweenness", "constraint"), re_negative = NULL, tna_network = NULL, psych_network = NULL, ... )centrality( x, type = c("basic", "extended", "all"), measures = NULL, include = NULL, mode = "all", normalized = FALSE, weighted = TRUE, directed = NULL, loops = TRUE, simplify = "sum", digits = NULL, sort_by = NULL, cutoff = -1, invert_weights = NULL, alpha = 1, damping = 0.85, personalized = NULL, transitivity_type = "local", isolates = "nan", lambda = 1, diffusion_method = NULL, k = 3, states = NULL, decay_parameter = 0.5, dmnc_epsilon = 1.7, membership = NULL, katz_alpha = 0.1, hubbell_weight = 0.5, shapley_k = 2, shapley_cutoff = 2, s_shell_a = 0.5, discount_p = 0.01, ncvote_theta = 0.5, comm_r = "max_intra", ld_radius = 2, enrenew_depth = 2, voterank_lambda = 0.1, contraction_rho = 5, wks_alpha = 1, wks_beta = 1, renewed_threshold = 2, kpath_k = 3, kpath_len = 3, epc_threshold = 0.5, epc_runs = 1000, epc_seed = NULL, betweenness_delta = 1, closeness_delta = 1, gravity_mass = "kshell", gravity_radius = 3, mdd_lambda = 0.7, volume_radius = 2, diffusion_q = 1, diffusion_steps = 3, ds_beta = 0.1, ds_mu = 1, ds_steps = 5, cda_alpha = 0.5, icc_alpha = 0.2, exogenous_base = "reverse_closeness", wlr_alpha = 1, alr_h_mode = "all", grc_gamma = 1, rwd_decay = 0.5, rwd_node_weights = NULL, linerank_aggregation = "probability", bridging_steps = 2, bridging_values = NULL, proximal_variant = "source", exf_alpha = 2, beta_direction = "positive", ninl_order = 3, ninl_radius = NULL, map_flow = "unrecorded", map_convention = "paper", sr_prior = 0, mcgm_radius = 2, mcgm_alpha = NULL, dkgm_radius = 2, nd_order = 2, nd_decay = 0.2, nd_mass = "degree", ira_mass = "coreness", ira_alpha = 1, ira_tol = 1e-06, ira_max_iter = 1000, iira_beta = 0.2, iira_steps = 50, hcc_delta = 0.5, lhc_radius = 2, tpr_alpha = 0.85, tpr_k = 0.85, tpr_decay = 1, tpr_tol = 1e-14, tpr_max_iter = 1000, rsp_beta = 0.01, rsp_cost = c("inverse", "weight"), re_indexes = c("degree", "closeness", "betweenness", "constraint"), re_negative = NULL, tna_network = NULL, psych_network = NULL, ... )
x |
Network input (matrix, edge-list data frame, igraph, network, cograph_network, tna object). |
type |
Character scalar selecting a curated tier of measures when
Passing |
measures |
Character vector of measure names to compute. When
The remaining measures are described under Details. |
include |
Character vector of costly measures to add to a tier, or
|
mode |
For directed networks: "all" (default), "in", or "out".
Affects the mode-aware measures, whose output columns carry a mode
suffix. These include degree, strength, closeness, eccentricity,
coreness, harmonic, diffusion, leverage, kreach, the distance-based
measures, most community-aware measures, and expected influence (the
|
normalized |
Logical. If |
weighted |
Logical. Use edge weights if available. Default TRUE.
With |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
loops |
Logical. If TRUE (default), keep self-loops. Set to FALSE to
remove them before calculation. |
simplify |
How to combine multiple edges between the same node pair
(possible only from edge-list, cograph_network or igraph input).
Options: "sum" (default), "mean", "max", "min". |
digits |
Integer or NULL. Round all numeric columns to this many decimal places. Default NULL (no rounding). |
sort_by |
Character or NULL. Column name to sort results by (descending order). Default NULL (original node order). A name that is not a column of the result raises an error. |
cutoff |
Maximum path length to consider for betweenness, closeness, harmonic centrality and the distance-based closeness variants (radiality, lin, decay, residual_closeness, dangalchev, generalized_closeness, harary, average_distance, barycenter, wiener, centroid, closeness_vitality, delta_closeness). Default -1 (no limit). A positive value ignores longer paths, which shortens computation on large networks and changes the values. |
invert_weights |
Logical or NULL. Whether path- and distance-based
measures (for example betweenness, closeness, harmonic, k-reach,
radiality, decay, stress, flow betweenness and related variants) invert
the weights, so that higher weights mean shorter paths. A message reports
the inversion. Eccentricity always reads the raw edge weights as
distances. The default |
alpha |
Numeric. Exponent for weight transformation when |
damping |
PageRank damping factor. Default 0.85. Must be between 0 and 1. |
personalized |
Non-negative numeric vector of reset probabilities for personalized PageRank, one value per node. A named vector is matched to the node names, an unnamed one is taken in node order. The vector is rescaled to sum to 1. Default NULL (standard PageRank). |
transitivity_type |
Type of transitivity to calculate: "local" (default),
"global", "undirected", "localundirected", "barrat" (weighted),
"weighted", or "onnela". The first six follow the conventions of
|
isolates |
Value of local transitivity at nodes where it is undefined: "nan" (default) returns NaN, "zero" returns 0. |
lambda |
Diffusion scaling factor for diffusion centrality. Default 1.
Only used when |
diffusion_method |
Character or NULL. Selects the diffusion-centrality
formula. |
k |
Distance bound for |
states |
Numeric vector of percolation states for percolation
centrality, one per node. Each value represents how "activated" or
"infected" a node is. A named vector is matched to the node labels,
missing nodes get state 1, and values are clipped to 0-1. Default NULL
gives every node state 1, which makes percolation equal to betweenness
divided by |
decay_parameter |
Numeric. Decay parameter for decay and generalized
closeness centrality, strictly between 0 and 1; smaller values discount
distant nodes more. Other values raise a |
dmnc_epsilon |
Numeric. Epsilon exponent for DMNC (Density of Maximum
Neighborhood Component), a single positive number. Default 1.7, as
recommended by Lin et al. (2008). centiserve uses 1.67. Other values
raise a |
membership |
Integer vector of community assignments (one per node) for
the community-aware measures listed under |
katz_alpha |
Attenuation factor for Katz centrality. The Katz series
converges only for |
hubbell_weight |
Weight factor |
shapley_k |
Neighbor threshold |
shapley_cutoff |
Hop cutoff for |
s_shell_a |
Exponent of the asymmetric link weights for
|
discount_p |
Propagation probability for |
ncvote_theta |
Weight of the plain vote in |
comm_r |
Scale |
ld_radius |
Radius for |
enrenew_depth |
Renewal radius for |
voterank_lambda |
Suppression factor for |
contraction_rho |
|
wks_alpha, wks_beta
|
Degree and strength exponents for
|
renewed_threshold |
Diffusion-importance threshold for
|
kpath_k |
Maximum path length for |
kpath_len |
Maximum path length for |
epc_threshold |
Edge removal probability for |
epc_runs |
Number of percolation realizations for |
epc_seed |
Random seed for |
betweenness_delta |
Decay exponent for |
closeness_delta |
Distance exponent for |
gravity_mass |
Mass in |
gravity_radius |
Largest distance each gravity source reaches in
|
mdd_lambda |
Exhausted-degree weight for |
volume_radius |
Closed neighborhood radius for |
diffusion_q |
Multiplier between 0 and 1 for |
diffusion_steps |
Nonnegative integer horizon for
|
ds_beta |
Spreading rate for |
ds_mu |
Recovery rate for |
ds_steps |
Nonnegative integer horizon for |
cda_alpha |
Degree-versus-strength weight for |
icc_alpha |
Shortest-path multiplicity exponent for
|
exogenous_base |
Base for |
wlr_alpha |
Finite in-degree exponent for |
alr_h_mode |
H-index convention for |
grc_gamma |
Finite nonnegative regularization strength for
|
rwd_decay |
Finite first-arrival discount in |
rwd_node_weights |
Nonnegative starting weights for
|
linerank_aggregation |
LineRank endpoint aggregation: probability
(default) or weight. See |
bridging_steps |
Nonnegative bridging-capital walk horizon, default two. |
bridging_values |
Optional source-destination value matrix for
|
proximal_variant |
Proximal betweenness role: source (default),
target, sum, or union. See |
exf_alpha |
Modified Expected Force degree factor, default two, finite and greater than one. |
beta_direction |
BG-index orientation, positive (default) or negative.
See |
ninl_order |
Nonnegative NINL iteration count, default three. |
ninl_radius |
NINL hop radius, NULL for ceiling of mean path length.
See |
map_flow |
Map equation flow model, unrecorded (default) or recorded. |
map_convention |
Map equation coding convention, paper (default) or
infomap. See |
sr_prior |
SpectralRank diagonal prior, default zero; scalar or one
value per node. See |
mcgm_radius |
MCGM hop cutoff, default two; NULL includes all reachable nodes. |
mcgm_alpha |
MCGM coefficient, NULL for the published adaptive rule.
See |
dkgm_radius |
DKGM hop cutoff, default two as in the paper's printed
example; NULL or infinity includes all reachable nodes and "auto"
applies the paper's half-mean-distance rule with cograph rounding.
See |
nd_order |
Steps of neighbors summed by |
nd_decay |
Per-step decay for |
nd_mass |
Benchmark centrality summed by
|
ira_mass |
Node centrality allocated by |
ira_alpha |
Exponent on the |
ira_tol |
Stopping tolerance for |
ira_max_iter |
Iteration bound for |
iira_beta |
Spreading rate for |
iira_steps |
Iterations for |
hcc_delta |
Weight on a node's own degree in the extended degree
used by |
lhc_radius |
Radius of the ball |
tpr_alpha |
Jump probability of the trust-PageRank iteration used
by |
tpr_k |
Weight of the degree ratio in the trust value of
|
tpr_decay |
Attenuation factor of the similarity recursion used by
|
tpr_tol |
Convergence tolerance on the largest relative change of
either trust-PageRank recursion, a single positive number, default
|
tpr_max_iter |
Iteration bound for both trust-PageRank recursions, a
whole number of at least one, default 1000. Reaching it raises a
|
rsp_beta |
Inverse temperature of the randomized-shortest-paths
model used by |
rsp_cost |
How an edge weight becomes a traversal cost for
|
re_indexes |
Constituent indexes integrated by
|
re_negative |
Which of |
tna_network |
Logical or NULL. Umbrella switch that forces tna-style
conventions across all measures. |
psych_network |
Logical or NULL. Switch for signed psychometric
network conventions. |
... |
Additional arguments (currently unused) |
The following centrality measures are available:
Count of edges (supports mode: in/out/all)
Weighted degree (supports mode: in/out/all)
Shortest path centrality
Inverse distance centrality (supports mode: in/out/all)
Influence-based centrality
Random walk centrality (supports damping and personalization)
HITS authority score
HITS hub score
Maximum distance to other nodes (supports mode).
Distances use the raw edge weights whatever invert_weights
says, and hop counts with weighted = FALSE.
K-core membership (supports mode: in/out/all)
Burt's constraint (structural holes)
Local clustering coefficient (supports multiple types)
Harmonic centrality, the sum of inverse distances. It stays finite on disconnected graphs (supports mode: in/out/all)
Diffusion degree centrality. With
diffusion_method = "kandhway_kuri" it is the scaled degree of
the node plus the scaled degrees of its neighbors (supports mode:
in/out/all, lambda scaling)
Leverage centrality. Influence over neighbors based on relative degree differences (supports mode: in/out/all)
K-reach centrality. Number of nodes reachable within
k steps (supports mode: in/out/all)
Alpha centrality. Influence through paths, attenuated by length, with a unit exogenous contribution at every node (supports mode: in/out/all)
Bonacich power centrality. Influence based on connections to other influential nodes (supports mode: in/out/all)
Subgraph centrality. Participation in closed walks, with shorter walks weighted more heavily
Laplacian centrality with the local formula of Qi et
al. (2012). Matches NetworkX and centiserve::laplacian()
Load centrality. Share of shortest-path load passing through the node, with load split evenly at each branching point
Information centrality. Closeness based on electrical current flow (requires a connected graph)
Random-walk betweenness. Betweenness based on electrical current flow (requires a connected graph)
VoteRank. Influential spreaders selected by iterative
voting. The value is the election order rescaled so that the first
elected node scores 1 and the last scores
Percolation centrality. Shortest-path betweenness
weighted by the node states in states. With equal states it is
betweenness divided by
Radiality centrality (centiserve). Sum of (diam + 1 - d) normalized by n-1.
Lin's centrality. Reachable nodes squared divided by sum of distances.
Decay centrality. Sum of over all nodes,
the node itself included, with = decay_parameter.
Residual closeness. Sum of over
all nodes, the node itself included.
Dangalchev closeness. Same values as
residual_closeness.
Generalized closeness. Same formula as
decay, using decay_parameter.
Harary centrality. Sum of 1/d^2 for all reachable pairs.
Average distance (centiserve). Sum of distances / (n+1).
Barycenter centrality. 1 / sum of distances.
Wiener index. Total sum of shortest path distances from node.
Closeness vitality. Drop in Wiener index when node removed.
Total communicability. Row sums of matrix exponential.
Communicability betweenness. Fraction of communicability through each node.
Random walk centrality. Inverse sum of random walk distances (requires connected graph).
Stress centrality. Number of shortest paths through node.
Flow betweenness. Max-flow based betweenness.
Lobby index (h-index of neighborhood).
Graph entropy centrality. Entropy change on node removal.
Semi-local centrality. Triple-nested neighborhood sum.
ClusterRank. Clustering coefficient times neighbor degree sum.
Bottleneck centrality. Count of shortest path trees where node is critical.
Centroid value. Minimum f(v,i) across all nodes.
Maximum Neighborhood Component size.
Density of Maximum Neighborhood Component.
Topological coefficient. Shared neighbor ratio.
Bridging centrality. Betweenness times bridging coefficient.
Local bridging. (1/degree) times bridging coefficient.
Burt's effective size. Degree minus redundancy.
Diversity centrality. Shannon entropy of edge weight distribution.
Cross-clique connectivity. Count of cliques containing node.
Markov centrality. Inverse mean first passage time (requires connected graph).
Integration centrality. Distance-based influence.
Expected centrality. Sum of neighbor degrees.
Gil-Schmidt power index. Sum of 1/d normalized by n-1.
SALSA authority scores (directed graphs only).
LeaderRank. PageRank with ground node (directed graphs only).
Participation coefficient. Diversity of inter-community
connections (requires membership).
Within-module degree z-score. Intra-community
connectivity (requires membership).
Gateway coefficient. Inter-community brokerage weighted by
centrality (requires membership).
Normalized Shannon entropy of a node's hop-distance profile. It is 1 when the distances are spread evenly and 0 when all lie at one distance.
Growth exponent of the ball around a node
(slope of on ). Lower values mark more
influential nodes.
Entropy-weighted local dimension over boxes up to half the node's eccentricity. Higher values mark more influential nodes.
Mean degree of a node's neighbors (average neighbor degree); isolates score 0.
Drop in modularity when the node is removed
under a fixed partition. Positive values mark community hubs and
negative values mark bridges (requires membership).
Shapley value of the
node in the coverage games of Michalak et al. (2013): one-hop
coverage, shapley_k-neighbor coverage, and coverage within
shapley_cutoff hops. Values sum to the node count.
Mean bits needed to reach every other node along shortest paths without a map. Low values mark well-connected nodes.
Mean bits others need to find the node. High values mark hidden nodes.
Log rumor centrality on the node's BFS tree: log of the number of spreading orders that could start there.
Community size times intra-community
degree plus number of other communities touched times
inter-community degree (requires membership).
Drop in
the Shannon entropy of the degree (by mode) or betweenness
distribution when the node is deleted; signed, nats.
Shell index of the strength-based peeling with
asymmetric topological link weights, exponent s_shell_a.
Greedy seed-selection order
under degree discounting (discount_p) or unit discounting,
scored 1 for the first selected down to 1/n.
VoteRank with voters weighted by normalized
neighborhood coreness (ncvote_theta); election order scored
like voterank.
Links
weighted by the size of the community they reach; Gupta's scaled
intra/inter-degree combination (comm_r); base-2 entropy of the
link distribution over communities times degree share (all require
membership).
Silva-Costa estimator at ld_radius;
slope of the fuzzy ball, where higher values mark more influential
nodes; slope of the degree volume, where lower values mark more
important nodes.
Election orders of the
weighted, entropy-based (enrenew_depth) and degree-weighted
(voterank_lambda) VoteRank variants, scored like
voterank.
One minus the
agglomeration ratio after contracting the node with its neighbors;
the improved form adds the same score of its edges on the line graph
(contraction_rho).
Number of node pairs whose most likely two-way random-walk route passes through the node.
Farness minus mean neighbor farness. Lower values mark more central nodes.
Share of neighbor pairs linked through the node but not directly.
. Lower values
mark more central nodes.
h-index over topological link weights
repeated times.
Mean degree of the neighbors inside the ego network; degree minus effective size.
k-shell on after Garas' weight normalization (wks_alpha,
wks_beta).
k-core of the graph after removing links whose
diffusion importance is below renewed_threshold.
Number of shortest paths of length at most
kpath_k starting at the node.
Global efficiency of the subgraph induced on
the node's neighbors, the node itself removed. This differs from
igraph::local_efficiency(), which measures the distances
between those neighbors through the rest of the network.
Largest strength threshold whose s-core still contains the node; the k-core number when weights are absent.
Distance-weighted fragmentation of the network after deleting the node. Higher means a more disruptive removal.
Number of simple paths of length at most
kpath_len that the node lies on, endpoints included.
Edge percolated component: mean size of the node's
component over epc_runs bond-percolation realizations, as a
share of the network. A Monte Carlo estimate; epc_seed makes
it reproducible.
Betweenness with each separated pair
weighted by .
Betweenness with the pair weight
(betweenness_delta), where is the number of edges
on a shortest path.
Betweenness inside the node's own ego network.
(closeness_delta).
Node truss number (k-2 triangles convention) and
mixed-degree shell threshold (mdd_lambda). Both use the
simple undirected skeleton; see centrality_truss.
Reciprocal-degree ratio, count of unconnected neighbor pairs, and count of triangle-supported relationships on the simple undirected skeleton.
Sum of degrees in the closed volume_radius-hop
neighborhood on the simple undirected skeleton.
Maximal clique centrality: sum of over
incident maximal cliques of size at least two. Costly; see
centrality_mcc for isolate and precision conventions.
Finite-horizon weighted outgoing walks:
, with diffusion_q and
diffusion_steps. Distinct from diffusion degree.
Relative spectral-radius loss on vertex
deletion, evaluated by repeated eigendecomposition. Costly; see
centrality_dynamical_importance for zero-radius graphs.
Finite-time spreading score including
ds_beta, ds_mu and ds_steps; uses the simple
undirected skeleton.
Sum of focal-to-neighbor degree ratios on the simple undirected skeleton; the reciprocal of the bridging coefficient on nonisolated vertices.
One minus half the incident conductance
times effective-resistance sum. Weighted, componentwise and costly;
see centrality_resistance_curvature.
Sum of neighbors' neighborhood coreness; equivalently the squared simple adjacency times core numbers.
Gravity with the degree k-shell index as the mass at both
ends, default radius two; see centrality_dkgm.
Benchmark centrality plus its decayed sums
over non-backtracking walks of up to nd_order steps. See
centrality_neighbor_distance.
Steady state of a unit resource repeatedly reallocated to
neighbors in proportion to their ira_mass; conserved, so the
scores of a component sum to its size. Warns
cograph_no_converge where no steady state exists. See
centrality_ira.
The same recursion with each share scaled by
for the iira_beta spreading rate,
run iira_steps times.
Decays geometrically, so only the order is meaningful. See
centrality_iira.
Local neighbor contribution: the cubed degree times the
binomial own-contribution factor times the
neighbors' degree sum over . Parameter-free; raw scores
depend on the whole graph's order. See centrality_lnc.
KED method: the degree times one plus the normalized
entropy of the neighbors' degrees times for the
neighbor-degree sum and the whole graph's order
. Parameter-free. See centrality_ked.
Hybrid characteristic centrality: the extended degree
over its maximum,
plus the E-shell peeling round in which the node leaves over the
number of rounds. Raw scores lie in and are not
component-local. See centrality_hcc.
Extended hybrid characteristic centrality: the
closed-neighborhood sum of hcc, the focal node counted once.
See centrality_ehcc.
Lhc index: the degree-and-triangle-share influence
over the ball of
radius lhc_radius, summed over the open neighborhood. The
triangle share is normalized by , three
times the number of distinct triangles, and is written as zero on a
triangle-free graph. Raw scores are not component-local. See
centrality_lhc.
Immediate effects centrality: the reciprocal mean length
of the influence sequences that end at a node,
for the mean first passage times
of the influence chain
built with .
Direction-sensitive and costly (one eigenproblem and two dense
solves). NA at every node when the chain is reducible or the
graph has one node. Not the same measure as markov. See
centrality_iec.
Degree and importance of lines: the degree plus the share
of each incident line's importance that the node's own degree claims,
, with
the number of triangles on the line. Two-hop local and
component-local; never below the node's degree. See
centrality_dil.
Trust-PageRank: a damped PageRank whose split of
a node's score among its neighbors is the column-stochastic
trust-value , with the fixed point of SimRank
restricted to the lines of the graph. Scores sum to one when no node
is isolated. NA at every node of a component that has lines
but no triangle, where the similarity vanishes and the ratio is
undefined. Costly
(two fixed-point recursions over dense matrices). See
centrality_trust_pagerank.
Simple randomized shortest paths betweenness:
the expected number of visits a node receives over the Boltzmann
distribution on absorbing walks, summed over every ordered
source-target pair. rsp_beta interpolates between the
random-walk and shortest-path readings. Direction-sensitive,
component-local, and costly (one dense inverse). See
centrality_rsp_betweenness.
Normalized geometric mean of several index
distributions, the minimum-relative-entropy integration of
re_indexes; sums to one. See
centrality_relative_entropy.
Gravity with focal core-number and partner-degree masses, default radius three.
Sum of immediate neighbors' raw mixed gravitational centralities.
Sum of neighbors' raw k-shell gravity scores,
with gravity_radius applied around each neighbor.
Weighted degree and strength, adjusted by Barrat clustering,
plus weighted neighbor contributions; uses cda_alpha.
Closeness using distances divided by the
number of shortest paths raised to icc_alpha.
Contribution to all other nodes' base centrality,
measured by deletion. Selects a base using exogenous_base.
Exponential focal coreness times distance-discounted partner coreness (GSM).
Exponential degree-coreness influences with an adaptive distance exponent (H-GSM).
Exponential focal degree with partner degrees discounted by a global mean-degree distance exponent (IGSM).
Stationary scores with ground-node outgoing
weights determined by original in-degree and wlr_alpha.
PageRank on the line graph, aggregated at endpoints;
uses damping and linerank_aggregation.
Entropy of onward boundary degrees over all two-event transmission sequences.
Multi-characteristics gravity with degree, coreness and eigenvector masses; default radius two.
Outgoing Perron eigenvector with a unit-linked
ground node; sr_prior supplies optional diagonal information.
Smallest eigenvalue of each grounded symmetric
row-Laplacian; see centrality_controlrank.
Codelength saving on silencing a node, conditional on the supplied partition, flow model and coding convention.
Finite neighbor propagation of closed-neighborhood degree
volume; uses ninl_order and ninl_radius.
BG power shared by successors among predecessors;
beta_direction selects positive or negative orientation.
Betweenness in one-hop or two-hop ego networks times the original bridging coefficient.
Expected Force multiplied by
log degree with the scaling parameter exf_alpha.
First/last shortest-path intermediaries;
uses proximal_variant on the directed unweighted skeleton.
Counts four-edge nonbacktracking walks with each node at the middle, using original neighbor excess degrees.
Concentration of dyadic Burt constraints across contacts; isolates zero and single-contact nodes one.
Information-walk loss under single-entry deletion;
uses bridging_steps and bridging_values.
Weighted sum of discounted first arrivals
from random walks; uses rwd_decay and rwd_node_weights.
Reciprocal diagonal of the inverse
regularized weighted Laplacian, using grc_gamma.
Stationary scores with destination weights
determined by original H-indices using alr_h_mode.
A base data.frame with one row per node, in the input's node
order unless sort_by is given, and the columns:
node: character, the node labels (the index as a string
when the input carried no names)
One numeric column per requested measure, with a mode suffix for
the mode-aware measures (e.g., degree_in,
closeness_all); see list_centralities for which
measures carry a suffix. A measure that a tier supplied but that has
no value on this input is an all-NA column.
The community-aware
measures warn and return an all-NA column when
membership is missing, and the brokerage roles do the same on an
undirected graph. "relative_entropy" has no value when one of
its constituent indexes is zero at every node. Named in
measures or include, it then raises a
cograph_undefined_index error. Supplied by a tier, it gives a
cograph_undefined_measure warning and an all-NA column,
and the other measures of the tier are still computed.
"flow_betweenness" requires the igraph package. Without igraph,
naming it raises a cograph_needs_igraph error, and a tier gives
the same warning and all-NA column.
centrality(regulation_net)centrality(regulation_net)
Access and hide information (Rosvall et al. 2005; Sneppen, Trusina and
Rosvall 2005) measure the number of bits a walker needs to follow a
shortest path without a map. The search information from to
sums over all shortest paths , with the
degree of the source and the choices left at each
intermediate node:
Access information averages
over targets , and hide information averages
over sources.
centrality_access_information(x, ...) centrality_hide_information(x, ...)centrality_access_information(x, ...) centrality_hide_information(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. On a directed
network every step uses the out-degree. The average runs over the nodes
a walker can reach, or be reached from, so values stay finite on a
disconnected network and equal the source's average on a
connected one. Hubs score high on access information and low on hide
information. On a star with five leaves the hub has access information
1.93 bits and hide information 0, and each leaf has access information
1.33 bits. The Centrality Zoo states the star case in reverse, and the
values above follow the formulas and the source papers.
A named numeric vector with one score per node, in input node order, in bits.
Rosvall, M., Trusina, A., Minnhagen, P., & Sneppen, K. (2005). Networks and cities: An information perspective. Physical Review Letters, 94, 028701.
Sneppen, K., Trusina, A., & Rosvall, M. (2005). Hide-and-seek on complex networks. Europhysics Letters, 69(5), 853-859.
centrality_closeness, centrality.
centrality_access_information(regulation_net) centrality_hide_information(regulation_net)centrality_access_information(regulation_net) centrality_hide_information(regulation_net)
Adaptive LeaderRank (Xu and Wang 2017) adds a ground node with H-index
1 that is linked in both directions to every node, and weights each arc
from to by the H-index of its target. The
H-index of a node is the largest such that at least of
its neighbors have degree at least . The score is the stationary
resource of the random walk on the row-normalized weights, started with
one unit on every node and none on the ground.
centrality_adaptive_leaderrank(x, alr_h_mode = "all", ...)centrality_adaptive_leaderrank(x, alr_h_mode = "all", ...)
x |
Network input accepted by |
alr_h_mode |
Neighbors and degrees used for the H-index:
|
... |
Further arguments to |
The random walk keeps the direction of the arcs, and an undirected edge
counts as two opposite arcs. Edge weights, loops and parallel arcs are
ignored, and mode has no effect. H-indices are computed once on
the original network. With alr_h_mode = "all" they use the
simple undirected skeleton, "out" uses the out-degrees of
out-neighbors and "in" the in-degrees of in-neighbors. The
returned scores omit the ground, so they sum to less than . A
node with H-index 0 scores 0, and when every H-index is 0 all scores are
NaN with a cograph_undefined_measure warning.
A named numeric vector with one score per node, in input node order.
Xu, S., & Wang, P. (2017). Identifying important nodes by adaptive LeaderRank. Physica A, 469, 654-664. doi:10.1016/j.physa.2016.11.034.
centrality_weighted_leaderrank,
centrality_lobby, centrality.
centrality_adaptive_leaderrank(regulation_net)centrality_adaptive_leaderrank(regulation_net)
Alpha centrality (Bonacich and Lloyd 2001) gives every node an exogenous score of one plus the scores of the nodes that point to it:
The attenuation is fixed at and is a
vector of ones, the defaults of igraph::alpha_centrality().
centrality_alpha(x, mode = "all", ...)centrality_alpha(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
holds the edge weights, or ones with weighted = FALSE,
with the diagonal set to zero. The
alpha argument of centrality is the weight-inversion
exponent, which this measure does not read. The
scores are positive when the spectral radius of is below one and
can be negative otherwise. A singular system or a negative edge weight
raises an error of class cograph_singular_system.
On a directed network mode = "in" sums over incoming ties as above
and equals igraph::alpha_centrality(), mode = "out" uses
in place of and so sums over outgoing ties, and
mode = "all" (default) uses the symmetrized weights
. On an undirected network the three modes agree.
A named numeric vector with one score per node, in input node order.
Bonacich, P., & Lloyd, P. (2001). Eigenvector-like measures of centrality for asymmetric relations. Social Networks, 23(3), 191-201. doi:10.1016/S0378-8733(01)00038-7.
centrality_katz, centrality_eigenvector,
centrality.
centrality_alpha(regulation_net)centrality_alpha(regulation_net)
The HITS algorithm (Kleinberg 1999) assigns each node an authority score from the hubs that point to it and a hub score from the authorities it points to:
Authorities are the dominant eigenvector of and hubs
the dominant eigenvector of .
centrality_authority(x, ...) centrality_hub(x, ...)centrality_authority(x, ...) centrality_hub(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
holds the edge weights, or ones with weighted = FALSE.
Both scores are scaled to a maximum
of one, so they lie between 0 and 1. On an undirected network both equal
eigenvector centrality. A network without edges gives every node a score
of one. centrality_hub() returns the hub scores.
A named numeric vector with one score per node, in input node order.
Kleinberg, J. M. (1999). Authoritative sources in a hyperlinked environment. Journal of the ACM, 46(5), 604-632. doi:10.1145/324133.324140.
centrality_eigenvector,
centrality_pagerank, centrality.
centrality_authority(regulation_net) centrality_hub(regulation_net)centrality_authority(regulation_net) centrality_hub(regulation_net)
Average distance is the sum of the shortest-path distances from a node to
every node, divided by as in the centiserve package:
Lower values mark more central nodes.
centrality_average_distance(x, mode = "all", ...)centrality_average_distance(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths. A node that
cannot reach every other node scores Inf, so on a disconnected
network every score is Inf.
A named numeric vector with one score per node, in input node order.
centrality_barycenter,
centrality_closeness, centrality.
centrality_average_distance(regulation_net)centrality_average_distance(regulation_net)
Barycenter centrality is the reciprocal of the total shortest-path distance from a node to the nodes it reaches:
Unreachable nodes are left out of the sum.
centrality_barycenter(x, mode = "all", ...)centrality_barycenter(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths. The formula is
the one centrality_closeness computes, and with the default
weighted = TRUE the two agree on every node that reaches another
node. A node that reaches no other node scores 0, where closeness returns
NaN.
A named numeric vector with one score per node, in input node order.
centrality_closeness,
centrality_average_distance, centrality.
centrality_barycenter(regulation_net)centrality_barycenter(regulation_net)
The beta measure, or BG-index (van den Brink and Gilles 2000), gives
node the sum, over its successors , of one divided
by the in-degree of . Each node with predecessors thus shares
one unit of domination power equally among them:
The negative variant applies the measure to the reversed network (Boldi and Vigna 2014).
centrality_beta_measure(x, beta_direction = "positive", ...)centrality_beta_measure(x, beta_direction = "positive", ...)
x |
Network input accepted by |
beta_direction |
|
... |
Further arguments to |
The measure is computed on the simple unweighted network with direction kept, so weights, loops and parallel edges are ignored. An undirected edge is a pair of reciprocal arcs, so on an undirected network both variants equal the sum of the reciprocal degrees of the neighbors. A node without successors has positive score zero, and a node without predecessors has negative score zero. The positive scores sum to the number of nodes with nonzero in-degree, and the negative scores sum to the number of nodes with nonzero out-degree.
A named numeric vector with one score per node, in input node order.
van den Brink, R. and Gilles, R. P. (2000). Measuring domination in directed networks. Social Networks, 22, 141-157. doi:10.1016/S0378-8733(00)00019-8.
Boldi, P. and Vigna, S. (2014). Axioms for centrality. Internet Mathematics, 10, 222-262. doi:10.1080/15427951.2013.865686.
centrality_indegree,
centrality_prestige_domain, centrality.
centrality_beta_measure(regulation_net)centrality_beta_measure(regulation_net)
Betweenness centrality (Freeman 1977) sums, over pairs of other nodes, the fraction of shortest paths between them that pass through the node:
where is the number of shortest paths from
to and the number of
those through .
centrality_betweenness(x, ...)centrality_betweenness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
On a directed network the sum runs over ordered pairs along the edge
direction, and on an undirected network over unordered pairs. Edge weights
are read as path lengths, and invert_weights = TRUE uses
instead. weighted = FALSE uses hop
counts. cutoff drops paths longer
than the given length. normalized = TRUE divides the scores by
their maximum.
A named numeric vector with one score per node, in input node order.
Freeman, L. C. (1977). A set of measures of centrality based on betweenness. Sociometry, 40(1), 35-41. doi:10.2307/3033543.
centrality_load, centrality_stress,
centrality.
centrality_betweenness(regulation_net)centrality_betweenness(regulation_net)
Bottleneck centrality (Przulj, Wigle and Jurisica 2004) counts the
shortest-path trees in which a node is a bottleneck. For each source
, every shortest path from to every reachable node is
enumerated, and a node scores one for that source
when it lies on more than of these paths.
centrality_bottleneck(x, mode = "all", ...)centrality_bottleneck(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. mode sets the
direction in which the paths leave the source. Paths that end at
count toward its total. A network with one node gives that node a score of
one.
A named integer vector with one score per node, in input node order.
Przulj, N., Wigle, D. A., & Jurisica, I. (2004). Functional topology in a network of protein interactions. Bioinformatics, 20(3), 340-348. doi:10.1093/bioinformatics/btg415.
centrality_stress,
centrality_betweenness, centrality.
centrality_bottleneck(regulation_net)centrality_bottleneck(regulation_net)
Bridging centrality (Hwang et al. 2008) is the product of betweenness
and the bridging coefficient, which compares the inverse degree
of a node with the inverse degrees of its neighbors:
High values mark nodes that lie on many shortest paths and connect densely linked regions.
centrality_bridging(x, ...)centrality_bridging(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The betweenness factor reads edge weights as path lengths and follows the
edge direction of a directed network. weighted = FALSE uses hop
counts, and invert_weights has no effect. The
degrees are total degrees, and on a directed network a reciprocated
neighbor enters the sum twice. An isolated node scores 0.
A named numeric vector with one score per node, in input node order.
Hwang, W., Kim, T., Ramanathan, M., & Zhang, A. (2008). Bridging centrality: Graph mining from element level to group level. In Proceedings of the 14th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 336-344). doi:10.1145/1401890.1401934.
centrality_local_bridging,
centrality_betweenness, centrality.
centrality_bridging(regulation_net)centrality_bridging(regulation_net)
Bridging capital (Jackson 2020, section 3.3) credits node
with the expected number of walks of length at most that are
lost when one entry of the transmission matrix is
deleted, summed over and weighted by source-destination
values :
centrality_bridging_capital(x, bridging_steps = 2, bridging_values = NULL, ...)centrality_bridging_capital(x, bridging_steps = 2, bridging_values = NULL, ...)
x |
Network input accepted by |
bridging_steps |
Horizon |
bridging_values |
Nonnegative n by n matrix of source-destination
values |
... |
Further arguments to |
Edge weights are the transmission probabilities in and must
lie between zero and one, and an unweighted edge has probability one. A
weight above one raises an error. Direction and loops are kept, and the
two entries of an undirected edge are deleted separately. Walks may
repeat nodes and edges, and a walk that uses the deleted entry several
times is counted once. Isolated nodes score zero, and
bridging_steps = 0 gives zero scores. The function computes the
expected walk count EInf of the source paper.
A named numeric vector with one score per node, in input node order.
Jackson, M. O. (2020). A typology of social capital and associated network measures. Social Choice and Welfare, 54, 311-336. doi:10.1007/s00355-019-01189-3.
centrality_bridging,
centrality_diffusion_centrality, centrality.
centrality_bridging_capital(regulation_net)centrality_bridging_capital(regulation_net)
Coordinator brokerage (Gould and Fernandez 1989) counts the open two-paths
through node in which ,
and all belong to the same group. A two-path is open when
the network has no edge from to . This role is
in the notation of the source.
centrality_brokerage_coordinator(x, membership = NULL, ...)centrality_brokerage_coordinator(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Group labels, one per node. |
... |
Further arguments to |
The measure is defined for directed networks. On an undirected network it
returns NA with a cograph_undefined_measure warning, and the
same happens when membership is missing, where the warning also has
class cograph_bad_membership. A membership whose length
differs from the number of nodes raises a cograph_bad_membership
error. Group labels may be numbers
or strings. Edge weights and self-loops are ignored. The other four roles
are centrality_brokerage_itinerant,
centrality_brokerage_representative,
centrality_brokerage_gatekeeper and
centrality_brokerage_liaison.
A named integer vector with one count per node, in input node
order. normalized = TRUE returns a numeric vector.
Gould, R. V., & Fernandez, R. M. (1989). Structures of mediation: A formal approach to brokerage in transaction networks. Sociological Methodology, 19, 89-126. doi:10.2307/270949.
centrality_brokerage_gatekeeper,
centrality_gateway, centrality.
centrality_brokerage_coordinator(regulation_net, membership = rep(1:2, each = 5))centrality_brokerage_coordinator(regulation_net, membership = rep(1:2, each = 5))
Gatekeeper brokerage (Gould and Fernandez 1989) counts the open two-paths
through node in which and
belong to the same group and to another group. The broker
admits contact from outside to a member of its own group. A two-path is
open when the network has no edge from to . This role is
in the notation of the source.
centrality_brokerage_gatekeeper(x, membership = NULL, ...)centrality_brokerage_gatekeeper(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Group labels, one per node. |
... |
Further arguments to |
The measure is defined for directed networks. On an undirected network it
returns NA with a cograph_undefined_measure warning, and the
same happens when membership is missing, where the warning also has
class cograph_bad_membership. A membership whose length
differs from the number of nodes raises a cograph_bad_membership
error. Group labels may be numbers
or strings. Edge weights and self-loops are ignored.
A named integer vector with one count per node, in input node
order. normalized = TRUE returns a numeric vector.
Gould, R. V., & Fernandez, R. M. (1989). Structures of mediation: A formal approach to brokerage in transaction networks. Sociological Methodology, 19, 89-126. doi:10.2307/270949.
centrality_brokerage_representative,
centrality_brokerage_coordinator, centrality.
centrality_brokerage_gatekeeper(regulation_net, membership = rep(1:2, each = 5))centrality_brokerage_gatekeeper(regulation_net, membership = rep(1:2, each = 5))
Itinerant brokerage (Gould and Fernandez 1989), also called the consultant
role, counts the open two-paths through
node in which and belong to the same group and
to another group. A two-path is open when the network has no edge
from to . This role is in the notation of
the source.
centrality_brokerage_itinerant(x, membership = NULL, ...)centrality_brokerage_itinerant(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Group labels, one per node. |
... |
Further arguments to |
The measure is defined for directed networks. On an undirected network it
returns NA with a cograph_undefined_measure warning, and the
same happens when membership is missing, where the warning also has
class cograph_bad_membership. A membership whose length
differs from the number of nodes raises a cograph_bad_membership
error. Group labels may be numbers
or strings. Edge weights and self-loops are ignored.
A named integer vector with one count per node, in input node
order. normalized = TRUE returns a numeric vector.
Gould, R. V., & Fernandez, R. M. (1989). Structures of mediation: A formal approach to brokerage in transaction networks. Sociological Methodology, 19, 89-126. doi:10.2307/270949.
centrality_brokerage_coordinator,
centrality_brokerage_liaison, centrality.
centrality_brokerage_itinerant(regulation_net, membership = rep(1:2, each = 5))centrality_brokerage_itinerant(regulation_net, membership = rep(1:2, each = 5))
Liaison brokerage (Gould and Fernandez 1989) counts the open two-paths
through node in which ,
and belong to three different groups. A two-path is open
when the network has no edge from to . This role is
in the notation of the source.
centrality_brokerage_liaison(x, membership = NULL, ...)centrality_brokerage_liaison(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Group labels, one per node. |
... |
Further arguments to |
The measure is defined for directed networks. On an undirected network it
returns NA with a cograph_undefined_measure warning, and the
same happens when membership is missing, where the warning also has
class cograph_bad_membership. A membership whose length
differs from the number of nodes raises a cograph_bad_membership
error. Group labels may be numbers
or strings. With fewer than three groups every count is 0. Edge weights and
self-loops are ignored.
A named integer vector with one count per node, in input node
order. normalized = TRUE returns a numeric vector.
Gould, R. V., & Fernandez, R. M. (1989). Structures of mediation: A formal approach to brokerage in transaction networks. Sociological Methodology, 19, 89-126. doi:10.2307/270949.
centrality_brokerage_itinerant,
centrality_brokerage_coordinator, centrality.
centrality_brokerage_liaison(regulation_net, membership = rep(1:3, length.out = 10))centrality_brokerage_liaison(regulation_net, membership = rep(1:3, length.out = 10))
Representative brokerage (Gould and Fernandez 1989) counts the open
two-paths through node in which
and belong to the same group and to another group.
The broker passes contact from its own group to the outside. A two-path is
open when the network has no edge from to . This role is
in the notation of the source.
centrality_brokerage_representative(x, membership = NULL, ...)centrality_brokerage_representative(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Group labels, one per node. |
... |
Further arguments to |
The measure is defined for directed networks. On an undirected network it
returns NA with a cograph_undefined_measure warning, and the
same happens when membership is missing, where the warning also has
class cograph_bad_membership. A membership whose length
differs from the number of nodes raises a cograph_bad_membership
error. Group labels may be numbers
or strings. Edge weights and self-loops are ignored.
A named integer vector with one count per node, in input node
order. normalized = TRUE returns a numeric vector.
Gould, R. V., & Fernandez, R. M. (1989). Structures of mediation: A formal approach to brokerage in transaction networks. Sociological Methodology, 19, 89-126. doi:10.2307/270949.
centrality_brokerage_gatekeeper,
centrality_brokerage_coordinator, centrality.
centrality_brokerage_representative(regulation_net, membership = rep(1:2, each = 5))centrality_brokerage_representative(regulation_net, membership = rep(1:2, each = 5))
The clustering degree algorithm (CDA; Wang et al. 2018) scores a node by
its clustering degree
plus the clustering
degrees of its neighbors, each scaled by the edge weight:
Here is the degree, the strength, the
weighted clustering coefficient of Barrat et al., and
the largest edge weight in the network.
centrality_cda(x, cda_alpha = 0.5, ...)centrality_cda(x, cda_alpha = 0.5, ...)
x |
Network input accepted by |
cda_alpha |
Weight |
... |
Further arguments to |
The measure works on an undirected weighted network. On a directed
network the weights of the two arcs between a pair are added, and
weighted = FALSE uses the simple undirected skeleton. Self-loops
are removed, and mode and invert_weights have no effect.
A node with fewer than two neighbors has clustering 0, and an isolated
node scores 0. Negative or non-finite weights raise an error. With
cda_alpha = 1 the scores are unchanged when every weight is
multiplied by a constant, and with cda_alpha = 0 they scale by
that constant. On an unweighted network cda_alpha has no effect.
A named numeric vector with one score per node, in input node order.
Wang, Q., Ren, J., Wang, Y., Zhang, B., Cheng, Y., & Zhao, X. (2018). CDA: A Clustering Degree Based Influential Spreader Identification Algorithm in Weighted Complex Network. IEEE Access, 6, 19550-19559. doi:10.1109/ACCESS.2018.2822844.
centrality_strength,
centrality_transitivity, centrality.
centrality_cda(regulation_net)centrality_cda(regulation_net)
The centroid value (Koschuetzki et al. 2005) compares a node with every
other node by the number of nodes each one is closer to. With
the number of nodes strictly closer to
than to ,
The minimum includes , so the score is at most 0, and values
closer to 0 mark more central nodes.
centrality_centroid(x, mode = "all", ...)centrality_centroid(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths.
A named numeric vector with one score per node, in input node order.
Koschuetzki, D., Lehmann, K. A., Peeters, L., Richter, S., Tenfelde-Podehl, D., & Zlotowski, O. (2005). Centrality indices. In U. Brandes & T. Erlebach (Eds.), Network Analysis: Methodological Foundations (pp. 16-61). Springer. doi:10.1007/978-3-540-31955-9_3.
centrality_closeness,
centrality_closeness_vitality, centrality.
centrality_centroid(regulation_net)centrality_centroid(regulation_net)
Closeness centrality (Sabidussi 1966) is the reciprocal of the total shortest-path distance from a node to the nodes it reaches:
Unreachable nodes are left out of the sum, as in
igraph::closeness().
centrality_closeness(x, mode = "all", ...) centrality_incloseness(x, ...) centrality_outcloseness(x, ...)centrality_closeness(x, mode = "all", ...) centrality_incloseness(x, ...) centrality_outcloseness(x, ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths, and invert_weights = TRUE
uses instead. weighted = FALSE uses
hop counts. mode = "out" follows paths
leaving the node and mode = "in" paths arriving at it.
centrality_outcloseness() and centrality_incloseness() are
these two forms. A node that reaches no other node returns NaN.
normalized = TRUE multiplies each score by the number of other
nodes the node reaches, as igraph does.
A named numeric vector with one score per node, in input node order.
Sabidussi, G. (1966). The centrality index of a graph. Psychometrika, 31(4), 581-603. doi:10.1007/BF02289527.
centrality_harmonic,
centrality_barycenter, centrality.
centrality_closeness(regulation_net)centrality_closeness(regulation_net)
Closeness vitality (Koschuetzki et al. 2005) is the drop in the Wiener index when a node is removed:
The Wiener index sums the finite distances over ordered pairs, as in
networkx::closeness_vitality().
centrality_closeness_vitality(x, mode = "all", ...)centrality_closeness_vitality(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths. Pairs that are
not connected contribute nothing to either index. An isolated node scores
0.
A named numeric vector with one score per node, in input node order.
Koschuetzki, D., Lehmann, K. A., Peeters, L., Richter, S., Tenfelde-Podehl, D., & Zlotowski, O. (2005). Centrality indices. In U. Brandes & T. Erlebach (Eds.), Network Analysis: Methodological Foundations (pp. 16-61). Springer. doi:10.1007/978-3-540-31955-9_3.
centrality_wiener, centrality_centroid,
centrality.
centrality_closeness_vitality(regulation_net)centrality_closeness_vitality(regulation_net)
ClusterRank (Chen et al. 2013) combines the local clustering coefficient
of a node with the degrees of its neighbors:
centrality_clusterrank(x, mode = "all", ...)centrality_clusterrank(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode sets both the neighbor set and the
degrees, and on a directed network a reciprocated neighbor enters the sum
twice under mode = "all". The clustering coefficient ignores edge
direction. A node with fewer than two neighbors has no clustering
coefficient and returns NaN. Chen et al. weight the sum by
, and the measure here multiplies by
itself, as the centiserve package does.
A named numeric vector with one score per node, in input node order.
Chen, D.-B., Gao, H., Lu, L., & Zhou, T. (2013). Identifying influential nodes in large-scale directed networks: The role of clustering. PLoS ONE, 8(10), e77455. doi:10.1371/journal.pone.0077455.
centrality_transitivity,
centrality_expected, centrality.
centrality_clusterrank(regulation_net)centrality_clusterrank(regulation_net)
The Coleman-Theil index (Burt 1992) measures how concentrated Burt's
dyadic constraint is across the contacts of node
. Let be the share of the mutual tie
strength of invested in ,
the constraint, and the constraint
divided by its mean over the contacts. Then
centrality_coleman_theil(x, ...)centrality_coleman_theil(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The mutual tie strength of a pair is the sum of the weights in both
directions, so direction is combined and loops are removed. Edge weights
must be finite and nonnegative, and weighted = FALSE gives every
edge weight one before the directions are combined. The index lies
between zero, for equal constraints, and one, for constraint
concentrated on one contact. Following Burt's STRUCTURE 4.2 manual
(pages 181-183), an isolated node scores zero and a node with one
contact scores one. The organizational and oligopoly multipliers of
STRUCTURE are fixed at one. A weight range beyond double precision
raises an error.
A named numeric vector with one score per node, in input node order.
Burt, R. S. (1992). Structural Holes: The Social Structure of Competition. Harvard University Press. doi:10.4159/9780674029095.
centrality_constraint,
centrality_effective_size, centrality.
centrality_coleman_theil(regulation_net)centrality_coleman_theil(regulation_net)
Total communicability (Estrada and Hatano 2008; Benzi and Klymko 2013) sums
the walks of every length that start at a node, a walk of length
weighted by :
centrality_communicability(x, ...)centrality_communicability(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
is the binary adjacency matrix, so edge weights are ignored. On an
undirected network the matrix exponential is formed from the
eigendecomposition of the symmetric . On a directed network it is
computed by scaling and squaring with a Pade approximation (Moler and Van
Loan 2003), and the scores are the row sums of , the
walks that leave each node. directed = FALSE gives the undirected
reading.
A named numeric vector with one score per node, in input node order.
Estrada, E., & Hatano, N. (2008). Communicability in complex networks. Physical Review E, 77(3), 036111. doi:10.1103/PhysRevE.77.036111.
Benzi, M., & Klymko, C. (2013). Total communicability as a centrality measure. Journal of Complex Networks, 1(2), 124-149. doi:10.1093/comnet/cnt007.
Moler, C., & Van Loan, C. (2003). Nineteen dubious ways to compute the exponential of a matrix, twenty-five years later. SIAM Review, 45(1), 3-49. doi:10.1137/S00361445024180.
centrality_subgraph,
centrality_communicability_betweenness,
centrality.
centrality_communicability(regulation_net, directed = FALSE)centrality_communicability(regulation_net, directed = FALSE)
Communicability betweenness (Estrada, Higham and Hatano 2009) is the share
of the communicability between other pairs of nodes that is lost when the
node is removed. With and
the same exponential after the edges of are deleted,
centrality_communicability_betweenness(x, ...)centrality_communicability_betweenness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
is the binary adjacency matrix, so edge weights are ignored. The
scores lie between 0 and 1. The measure is defined for undirected networks.
On a directed network and are computed by
scaling and squaring with a Pade approximation, as in
centrality_communicability, so the measure is defined there
as well. directed = FALSE gives the undirected reading.
A named numeric vector with one score per node, in input node order.
Estrada, E., Higham, D. J., & Hatano, N. (2009). Communicability betweenness in complex networks. Physica A, 388(5), 764-774. doi:10.1016/j.physa.2008.11.011.
centrality_communicability,
centrality_betweenness, centrality.
centrality_communicability_betweenness(regulation_net, directed = FALSE)centrality_communicability_betweenness(regulation_net, directed = FALSE)
Three measures that score a node from a partition membership.
Community-based centrality (Zhao et al. 2015) is
, where
counts the links of into community of
size . Comm centrality (Gupta, Singh and Cherifi 2016)
combines intra-community degree and inter-community
degree :
with the mean inter-link fraction in the community of
. Community-based mediator centrality (Tulu, Hou and Younas 2018)
is ,
with the base-2 entropy of the links of over the
communities.
centrality_community_based(x, membership = NULL, mode = "all", ...) centrality_comm_centrality( x, membership = NULL, mode = "all", comm_r = "max_intra", ... ) centrality_community_mediator(x, membership = NULL, mode = "all", ...)centrality_community_based(x, membership = NULL, mode = "all", ...) centrality_comm_centrality( x, membership = NULL, mode = "all", comm_r = "max_intra", ... ) centrality_community_mediator(x, membership = NULL, mode = "all", ...)
x |
Network input accepted by |
membership |
Community labels, one per node, for example from
|
mode |
For directed networks: |
... |
Further arguments to |
comm_r |
Scale |
Edge weights and self-loops are ignored. Under mode = "out" or
mode = "in" only out-links or in-links count, and the default
ignores direction. Higher values mark more central nodes in all three.
The default comm_r = "max_intra" sets to the largest
intra-community degree of each community, the choice the source
recommends. The prose of Gupta et al. writes where their
equation has , and the equation is implemented.
Nodes
linked to one community only score 0 on the mediator measure. Without
membership each function raises a warning of classes cograph_bad_membership and
cograph_undefined_measure and
returns NA. A membership that is not one non-missing label per node
raises an error of class cograph_bad_membership, and an invalid
comm_r raises cograph_bad_parameter.
A named numeric vector with one score per node, in input node order.
Zhao, Z., Wang, X., Zhang, W., & Zhu, Z. (2015). A community-based approach to identifying influential spreaders. Entropy, 17(4), 2228-2252.
Gupta, N., Singh, A., & Cherifi, H. (2016). Centrality measures for networks with community structure. Physica A, 452, 46-59.
Tulu, M. M., Hou, R., & Younas, T. (2018). Identifying influential nodes based on community structure to speed up the dissemination of information in complex network. IEEE Access, 6, 7390-7401.
centrality_community_hub_bridge,
centrality_participation, centrality.
centrality_community_based(regulation_net, membership = rep(1:2, each = 5)) centrality_comm_centrality(regulation_net, membership = rep(1:2, each = 5)) centrality_community_mediator(regulation_net, membership = rep(1:2, each = 5))centrality_community_based(regulation_net, membership = rep(1:2, each = 5)) centrality_comm_centrality(regulation_net, membership = rep(1:2, each = 5)) centrality_community_mediator(regulation_net, membership = rep(1:2, each = 5))
Community hub-bridge centrality (Ghalmane, El Hassouni and Cherifi 2019) scores nodes that are hubs inside their community and bridges between communities:
where is the size of the community of ,
and its
numbers of links inside and outside that community, and
the number of other communities it links to.
centrality_community_hub_bridge(x, membership = NULL, mode = "all", ...)centrality_community_hub_bridge(x, membership = NULL, mode = "all", ...)
x |
Network input accepted by |
membership |
Community labels, one per node, for example from
|
mode |
For directed networks: |
... |
Further arguments to |
Edge weights and self-loops are ignored. Under mode = "out" or
mode = "in" only out-links or in-links count, and the default
ignores direction. This is the raw form of the original article. Later
work by the same group uses a normalized variant with the same name.
Without membership the function raises a warning of classes cograph_bad_membership and
cograph_undefined_measure
and returns NA for every node. A membership that is not one
non-missing label per node raises an error of class
cograph_bad_membership.
A named numeric vector with one score per node, in input node order.
Ghalmane, Z., El Hassouni, M., & Cherifi, H. (2019). Immunization of networks with non-overlapping community structure. Social Network Analysis and Mining, 9, 45.
centrality_community_based,
centrality_modularity_vitality, centrality.
centrality_community_hub_bridge(regulation_net, membership = rep(1:2, each = 5))centrality_community_hub_bridge(regulation_net, membership = rep(1:2, each = 5))
Burt's constraint measures how much a node's ties are concentrated in
contacts that are themselves tied to each other. With
the proportion of the tie strength of invested in ,
Low constraint marks access to structural holes.
centrality_constraint(x, ...)centrality_constraint(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Ties are symmetrized as before the
proportions are formed, so edge direction is ignored. With
weighted = FALSE every tie has weight one. The values match
igraph::constraint(). An isolated node returns NaN, and a
node whose only tie is a self-loop scores 0.
A named numeric vector with one score per node, in input node order.
centrality_effective_size,
centrality_bridging, centrality.
centrality_constraint(regulation_net)centrality_constraint(regulation_net)
ControlRank (Zhou, Yu and Lu 2019) is the smallest eigenvalue of the
symmetric part of the graph Laplacian after
the row and column of the node are deleted:
Larger values rank higher.
centrality_controlrank(x, ...)centrality_controlrank(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights must be finite and nonnegative, weighted = FALSE
gives every edge weight one, and loops are removed. In a directed
network is the arc from to ,
holds the out-strengths and scores can be negative. On a
connected undirected network with at least two nodes all scores are
positive, and on a disconnected undirected network every score is zero.
A single node scores zero. With normalized = TRUE the scores are
divided by their maximum when it is positive, so negative directed
scores stay negative. For matrix input with very small weights, set
directed = TRUE explicitly, because symmetry detection is
approximate. A weight range beyond double precision or an unresolved
spectrum raises an error.
A named numeric vector with one score per node, in input node order.
Zhou, J., Yu, X. and Lu, J.-A. (2019). Node Importance in Controlled Complex Networks. IEEE Transactions on Circuits and Systems II: Express Briefs, 66(3), 437-441. doi:10.1109/TCSII.2018.2845940.
centrality_laplacian,
centrality_spectralrank, centrality.
centrality_controlrank(regulation_net)centrality_controlrank(regulation_net)
Coreness (Seidman 1983) is the largest for which a node belongs to
the -core, the maximal subnetwork in which every node has degree at
least . It is found by repeatedly removing the nodes of lowest
degree.
centrality_coreness(x, mode = "all", ...)centrality_coreness(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode = "in" and mode = "out" peel
by in-degree and out-degree, and mode = "all" by total degree, in
which a reciprocated tie counts twice. A self-loop adds a fixed amount to
the degree of its node throughout the peeling. The values match
igraph::coreness().
A named numeric vector with one score per node, in input node order.
Seidman, S. B. (1983). Network structure and minimum degree. Social Networks, 5(3), 269-287. doi:10.1016/0378-8733(83)90028-X.
centrality_degree,
centrality_s_core, centrality.
centrality_coreness(regulation_net)centrality_coreness(regulation_net)
Cross-clique connectivity (Faghani and Nguyen 2013) counts the cliques that contain a node. Every complete subnetwork counts, including the node itself and each of its edges, so a node of an isolated triangle scores 4.
centrality_cross_clique(x, ...)centrality_cross_clique(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge direction, edge weights and self-loops are ignored.
A named integer vector with one count per node, in input node order.
Faghani, M. R., & Nguyen, U. T. (2013). A study of XSS worm propagation and detection mechanisms in online social networks. IEEE Transactions on Information Forensics and Security, 8(11), 1815-1826. doi:10.1109/TIFS.2013.2280884.
centrality_coreness,
centrality_transitivity, centrality.
centrality_cross_clique(regulation_net)centrality_cross_clique(regulation_net)
Current-flow betweenness (Brandes and Fleischer 2005), also known as
random-walk betweenness (Newman 2005), treats the network as an electrical
circuit with the edge weights as conductances. One unit of current is sent
between every pair , and the score is the average current
that flows through the node:
where are the node potentials of that pair, taken from
the pseudoinverse of the Laplacian, and the inner sum is set to zero for
and .
centrality_current_flow_betweenness(x, ...)centrality_current_flow_betweenness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is defined for connected undirected networks. On a
disconnected network every score is NA, with a
cograph_undefined_measure warning.
On a directed network the Laplacian is built from the asymmetric weight
matrix, and directed = FALSE gives the undirected reading. The
potentials and the currents come from the same weights, and
weighted = FALSE gives every edge conductance one.
The fixed factor is the normalization of
networkx::current_flow_betweenness_centrality().
A named numeric vector with one score per node, in input node order.
Brandes, U., & Fleischer, D. (2005). Centrality measures based on current flow. In STACS 2005, Lecture Notes in Computer Science, 3404 (pp. 533-544). Springer. doi:10.1007/978-3-540-31856-9_44.
Newman, M. E. J. (2005). A measure of betweenness centrality based on random walks. Social Networks, 27(1), 39-54. doi:10.1016/j.socnet.2004.11.009.
centrality_current_flow_closeness,
centrality_betweenness, centrality.
centrality_current_flow_betweenness(regulation_net, directed = FALSE)centrality_current_flow_betweenness(regulation_net, directed = FALSE)
Current-flow closeness (Brandes and Fleischer 2005), equal to the
information centrality of Stephenson and Zelen (1989), replaces the
shortest-path distance in closeness by the effective resistance
of the network read as an electrical circuit with the
edge weights as conductances:
with the pseudoinverse of the Laplacian.
centrality_current_flow_closeness(x, ...)centrality_current_flow_closeness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is defined for connected undirected networks. On a
disconnected network every score is NA, with a
cograph_undefined_measure warning.
On a directed network the Laplacian is built from the asymmetric weight
matrix, and directed = FALSE gives the undirected reading. Edge
weights are conductances, and weighted = FALSE gives every edge
conductance one.
A named numeric vector with one score per node, in input node order.
Stephenson, K., & Zelen, M. (1989). Rethinking centrality: Methods and examples. Social Networks, 11(1), 1-37. doi:10.1016/0378-8733(89)90016-6.
Brandes, U., & Fleischer, D. (2005). Centrality measures based on current flow. In STACS 2005, Lecture Notes in Computer Science, 3404 (pp. 533-544). Springer. doi:10.1007/978-3-540-31856-9_44.
centrality_current_flow_betweenness,
centrality_information, centrality.
centrality_current_flow_closeness(regulation_net, directed = FALSE)centrality_current_flow_closeness(regulation_net, directed = FALSE)
Dangalchev closeness, the residual closeness of Dangalchev (2006), sums an exponentially decaying function of the distance to every node:
The sum includes the node itself, which adds one to every score, as in the centiserve package. Unreachable nodes contribute 0.
centrality_dangalchev(x, mode = "all", ...)centrality_dangalchev(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths. The values equal
those of centrality_residual_closeness and of
centrality_decay with decay_parameter = 0.5.
A named numeric vector with one score per node, in input node order.
Dangalchev, C. (2006). Residual closeness in networks. Physica A, 365(2), 556-564. doi:10.1016/j.physa.2005.12.020.
centrality_residual_closeness,
centrality_decay, centrality.
centrality_dangalchev(regulation_net)centrality_dangalchev(regulation_net)
Decay centrality sums a decay factor raised to the
distance from the node to every node:
The sum includes the node itself, which adds one to every score, and
unreachable nodes contribute 0. Values of between 0
and 1 discount distant nodes.
centrality_decay(x, mode = "all", decay_parameter = 0.5, ...)centrality_decay(x, mode = "all", decay_parameter = 0.5, ...)
x |
Network input accepted by |
mode |
For directed networks: |
decay_parameter |
Decay factor |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, and weighted = FALSE
counts hops. mode sets the direction of the paths.
decay_parameter must lie strictly between 0 and 1, and other values
raise a cograph_bad_parameter error. centrality_generalized_closeness computes
the same quantity, and decay_parameter = 0.5 gives
centrality_dangalchev.
A named numeric vector with one score per node, in input node order.
centrality_generalized_closeness,
centrality_dangalchev, centrality.
centrality_decay(regulation_net)centrality_decay(regulation_net)
Degree centrality counts the edges incident to each node. With
mode = "in" it counts incoming edges and with mode = "out"
outgoing edges. On an undirected network the three modes agree.
centrality_degree(x, mode = "all", ...) centrality_indegree(x, ...) centrality_outdegree(x, ...)centrality_degree(x, mode = "all", ...) centrality_indegree(x, ...) centrality_outdegree(x, ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored; centrality_strength sums them
instead. normalized = TRUE divides the scores by their maximum.
centrality_indegree() and centrality_outdegree() are the
mode = "in" and mode = "out" forms.
A named numeric vector with one score per node, in input node order.
Freeman, L. C. (1978). Centrality in social networks conceptual clarification. Social Networks, 1(3), 215-239. doi:10.1016/0378-8733(78)90021-7.
centrality_strength, centrality.
centrality_degree(regulation_net)centrality_degree(regulation_net)
DegreeDiscountIC and SingleDiscount (Chen, Wang and Yang 2009) select
spreaders for the independent-cascade model one at a time by the largest
discounted degree. After each selection every unselected neighbor
of the new seed gains one selected neighbor , and
its DegreeDiscountIC degree becomes
with propagation probability . SingleDiscount uses
.
centrality_degree_discount(x, discount_p = 0.01, ...) centrality_single_discount(x, ...)centrality_degree_discount(x, discount_p = 0.01, ...) centrality_single_discount(x, ...)
x |
Network input accepted by |
discount_p |
Propagation probability |
... |
Further arguments to |
Every node is placed, and the selection order is returned as a score.
The first node selected scores 1 and the last , so scores
lie in . Ties are broken by node order, which the
source leaves open. Direction, edge weights and self-loops are ignored.
A named numeric vector with one score per node, in input node order.
Chen, W., Wang, Y., & Yang, S. (2009). Efficient influence maximization in social networks. Proceedings of the 15th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 199-208.
centrality_voterank,
centrality_ncvoterank, centrality.
centrality_degree_discount(regulation_net) centrality_single_discount(regulation_net)centrality_degree_discount(regulation_net) centrality_single_discount(regulation_net)
Diffusion centrality has two forms, chosen by diffusion_method. The
"kandhway_kuri" form (Kandhway and Kuri 2014) adds the degrees of a
node's neighbors to its own degree, both scaled by :
. The "power_series" form sums the
rows of the first powers of the weight matrix:
centrality_diffusion(x, mode = "all", lambda = 1, ...)centrality_diffusion(x, mode = "all", lambda = 1, ...)
x |
Network input accepted by |
mode |
For directed networks: |
lambda |
Scale factor |
... |
Further arguments to |
The default is "kandhway_kuri", and "power_series" for tna
input. The "kandhway_kuri" form uses binary degrees, so edge
weights are ignored, and mode sets both the degrees and the
neighbor set. On a directed network mode = "all" uses total degrees
and the undirected neighbor set. lambda multiplies every score. The
"power_series" form uses the edge weights, or ones with
weighted = FALSE, and ignores mode and lambda. With
loops = FALSE the diagonal
of is set to zero. The "power_series" values match
tna::centralities(measures = "Diffusion").
A named numeric vector with one score per node, in input node order.
centrality_expected,
centrality_diffusion_centrality, centrality.
centrality_diffusion(regulation_net)centrality_diffusion(regulation_net)
Diffusion centrality (Banerjee et al. 2013) counts the walks of length
1 to that start at a node, each discounted by per step:
Walks may revisit nodes and return to the source, so the score counts repeated hearings of a message.
centrality_diffusion_centrality(x, diffusion_q = 1, diffusion_steps = 3, ...)centrality_diffusion_centrality(x, diffusion_q = 1, diffusion_steps = 3, ...)
x |
Network input accepted by |
diffusion_q |
Discount |
diffusion_steps |
Horizon |
... |
Further arguments to |
holds the edge weights, or ones with weighted = FALSE.
Directed edges carry information from source to target, so the score
uses row sums and mode has no effect. Transposing the input
gives incoming walks. Self-loops follow loops. Negative or non-finite
weights raise an error. gives 0 and gives
times the out-strength. When every entry of lies
between 0 and 1 the score is the expected number of times the
information is heard (Banerjee et al. 2013), and it can exceed the
number of nodes. The defaults and are package
choices. This measure differs from centrality_diffusion.
A named numeric vector with one score per node, in input node order.
Banerjee, A., Chandrasekhar, A. G., Duflo, E., & Jackson, M. O. (2013). The Diffusion of Microfinance. Science, 341, 1236498. doi:10.1126/science.1236498.
Banerjee, A., Chandrasekhar, A. G., Duflo, E., & Jackson, M. O. (2019). Using Gossips to Spread Information: Theory and Evidence from Two Randomized Controlled Trials. Review of Economic Studies, 86, 2453-2490. doi:10.1093/restud/rdz008.
centrality_dynamics_sensitive,
centrality_diffusion, centrality.
centrality_diffusion_centrality(regulation_net)centrality_diffusion_centrality(regulation_net)
The degree and importance of lines (DIL; Liu et al. 2016) adds to the
degree of a node a share of the importance of every line incident to it.
A line that lies on triangles has importance
with , and this importance is
split between the endpoints in proportion to their degrees minus one:
centrality_dil(x, ...)centrality_dil(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights, loops and parallel edges are ignored.
Every score is at least the degree of the node, and isolated nodes score
0. The share is undefined only on an isolated edge, whose importance is
zero. That share is set to zero, so both endpoints score 1. The text
layer of the published article reads as
. The printed page and the worked example of the article give
, which is the value used here. normalized = TRUE
divides the scores by their maximum.
A named numeric vector with one score per node, in input node order.
Liu, J., Xiong, Q., Shi, W., Shi, X. and Wang, K. (2016). Evaluating the importance of nodes in complex networks. Physica A: Statistical Mechanics and its Applications, 452, 209-219. doi:10.1016/j.physa.2016.02.049.
centrality_lhc, centrality_hcc,
centrality.
centrality_dil(regulation_net)centrality_dil(regulation_net)
Distance entropy (Stella and De Domenico 2018) is the Shannon entropy of
the distribution of hop distances from a node to the nodes it reaches,
scaled by the logarithm of the number of distance values in its range.
With the share of reachable nodes at distance , and
and the smallest and largest distance,
centrality_distance_entropy(x, mode = "all", ...)centrality_distance_entropy(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. On a directed
network mode sets the direction of the paths. Scores lie between 0
and 1. A node whose reachable nodes all lie at one distance scores 0, and
a node that reaches no other node returns NaN. The source divides
by , which is zero when the range
holds two distances. The implementation divides by
, so a uniform distribution
scores 1.
A named numeric vector with one score per node, in input node order.
Stella, M., & De Domenico, M. (2018). Distance entropy cartography characterises centrality in complex networks. Entropy, 20(4), 268.
centrality_local_dimension,
centrality_closeness, centrality.
centrality_distance_entropy(regulation_net)centrality_distance_entropy(regulation_net)
Diversity centrality (Eagle, Macy and Claxton 2010) is the Shannon entropy
of the weights on the edges incident to a node, divided by its maximum
:
The score lies between 0 and 1 and reaches 1 when the weights are equal.
centrality_diversity(x, ...)centrality_diversity(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
On a directed network incoming and outgoing edges are separate entries,
and counts both. With weighted = FALSE, or on an
unweighted input, every node with two or more edges scores 1. A node with fewer than two edges, or
with edge weights summing to zero, scores 0.
A named numeric vector with one score per node, in input node order.
Eagle, N., Macy, M., & Claxton, R. (2010). Network diversity and economic development. Science, 328(5981), 1029-1031. doi:10.1126/science.1186605.
centrality_entropy,
centrality_strength, centrality.
centrality_diversity(regulation_net)centrality_diversity(regulation_net)
The DK-based gravity model (Li and Huang 2021) sums, over the partners
within a hop-distance radius , the product of the two nodes'
masses divided by their squared distance. The mass
adds the degree to an
improved k-shell index
,
where is the peeling stage at which the node leaves its shell
and the number of stages shell needs.
centrality_dkgm(x, dkgm_radius = 2, ...)centrality_dkgm(x, dkgm_radius = 2, ...)
x |
Network input accepted by |
dkgm_radius |
Hop-distance radius |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. The k-shell
peeling removes nodes of degree at most , which is the reading that
terminates and reproduces the source's Tables 2 to 5, so an isolate falls
in the one-shell. Unreachable partners contribute nothing, and isolates
and a single-node graph score zero. The stage denominator
is a global maximum, so adding a
disconnected component can change every score. A dkgm_radius below
one gives zero at every node.
A named numeric vector with one score per node, in input node order.
Li, Z. and Huang, X. (2021). Identifying influential spreaders in complex networks by an improved gravity model. Scientific Reports, 11, 22194. doi:10.1038/s41598-021-01218-1.
centrality_mcgm,
centrality_mixed_gravity, centrality.
centrality_dkgm(regulation_net)centrality_dkgm(regulation_net)
The density of maximum neighborhood component (Lin et al. 2008) looks at
the subnetwork induced by the neighbors of a node, the node itself left
out, and takes its largest connected component with edges and
nodes:
A node without neighbors scores 0.
centrality_dmnc(x, mode = "all", dmnc_epsilon = 1.7, ...)centrality_dmnc(x, mode = "all", dmnc_epsilon = 1.7, ...)
x |
Network input accepted by |
mode |
For directed networks: |
dmnc_epsilon |
Exponent |
... |
Further arguments to |
Edge weights are ignored, and mode sets the neighbor set. On an
undirected network the result follows this definition. On a directed
network the component is a strongly connected component of the induced
subnetwork, counts its directed edges, and a reciprocated
neighbor enters the subnetwork once. When several components share the
largest size, counts the edges among all of their nodes. A
dmnc_epsilon that is not a single positive finite number raises a
cograph_bad_parameter error.
A named numeric vector with one score per node, in input node order.
Lin, C.-Y., Chin, C.-H., Wu, H.-H., Chen, S.-H., Ho, C.-W., & Ko, M.-T. (2008). Hubba: Hub objects analyzer, a framework of interactome hubs identification for network biology. Nucleic Acids Research, 36(suppl 2), W438-W443. doi:10.1093/nar/gkn257.
centrality_mnc, centrality_mcc,
centrality.
centrality_dmnc(regulation_net, directed = FALSE)centrality_dmnc(regulation_net, directed = FALSE)
Dynamical importance (Restrepo et al. 2006) is the relative drop in the
spectral radius of the adjacency matrix when the node is
removed:
The spectral radius is recomputed after each deletion, in place of the eigenvector approximation of the paper (eq. 5).
centrality_dynamical_importance(x, ...)centrality_dynamical_importance(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
holds the edge weights, or ones with weighted = FALSE, and
self-loops are removed. Negative or non-finite weights raise an error.
The scores lie between 0 and 1 and are unchanged when every arc is
reversed, so mode has no effect. A network with spectral radius
0, such as any directed acyclic network, gives NaN for every
node with a cograph_undefined_measure warning. An isolated node in a network with positive
spectral radius scores 0.
A named numeric vector with one score per node, in input node order.
Restrepo, J. G., Ott, E., & Hunt, B. R. (2006). Characterizing the Dynamical Importance of Network Nodes and Links. Physical Review Letters, 97, 094102. doi:10.1103/PhysRevLett.97.094102.
centrality_eigenvector,
centrality_resistance_curvature, centrality.
centrality_dynamical_importance(regulation_net)centrality_dynamical_importance(regulation_net)
Dynamics-sensitive centrality (Liu et al. 2016) is a linearized
cumulative spreading score with spreading rate and
recovery rate over steps:
With it reduces to
,
the form listed in the Centrality Zoo, and gives the
susceptible-infected case.
centrality_dynamics_sensitive(x, ds_beta = 0.1, ds_mu = 1, ds_steps = 5, ...)centrality_dynamics_sensitive(x, ds_beta = 0.1, ds_mu = 1, ds_steps = 5, ...)
x |
Network input accepted by |
ds_beta |
Spreading rate |
ds_mu |
Recovery rate |
ds_steps |
Horizon |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored. Isolated nodes score 0.
or gives 0, and gives
times the degree. The score counts repeated walks and
can exceed the number of nodes, so it is not an infection probability.
The defaults , and
are one setting studied by Liu et al. (2016). Parameters
outside their ranges raise an error.
A named numeric vector with one score per node, in input node order.
Liu, J. G., Lin, J. H., Guo, Q., & Zhou, T. (2016). Locating influential nodes via dynamics-sensitive centrality. Scientific Reports, 6, 21380. doi:10.1038/srep21380.
centrality_diffusion_centrality,
centrality.
centrality_dynamics_sensitive(regulation_net)centrality_dynamics_sensitive(regulation_net)
The eccentricity of a node (Hage and Harary 1995) is its largest shortest-path distance to a node it reaches:
Lower values mark more central nodes.
centrality_eccentricity(x, mode = "all", ...) centrality_ineccentricity(x, ...) centrality_outeccentricity(x, ...)centrality_eccentricity(x, mode = "all", ...) centrality_ineccentricity(x, ...) centrality_outeccentricity(x, ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are read as path lengths, and invert_weights has no
effect. weighted = FALSE, or an unweighted input, gives hop
counts. mode = "out" follows
paths leaving the node and mode = "in" paths arriving at it.
centrality_outeccentricity() and centrality_ineccentricity()
are these two forms. A node that reaches no other node scores 0.
A named numeric vector with one score per node, in input node order.
Hage, P., & Harary, F. (1995). Eccentricity and centrality in networks. Social Networks, 17(1), 57-63. doi:10.1016/0378-8733(94)00248-9.
centrality_closeness,
centrality_radiality, centrality.
centrality_eccentricity(regulation_net)centrality_eccentricity(regulation_net)
Burt's effective size is the number of a node's contacts minus their redundancy, the average number of ties each contact has to the other contacts:
On an undirected network this is ,
with the number of ties among the contacts.
centrality_effective_size(x, ...)centrality_effective_size(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are ignored. On a directed network each reciprocated neighbor
enters the neighbor list twice, so counts it twice and the
result differs from that of the undirected skeleton. An isolated node
scores 0.
A named numeric vector with one score per node, in input node order.
centrality_constraint,
centrality_redundancy, centrality.
centrality_effective_size(regulation_net)centrality_effective_size(regulation_net)
Extended hybrid characteristic centrality (Liu and Zheng 2023) adds to a
node's centrality_hcc score the scores of its neighbors.
centrality_ehcc(x, ...)centrality_ehcc(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure inherits the conventions of centrality_hcc. It
is computed on the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and a hcc_delta outside
raises a cograph_bad_parameter error. Scores lie in
, and an isolate scores its
own HCC.
A named numeric vector with one score per node, in input node order.
Liu, J. and Zheng, J. (2023). Identifying important nodes in complex networks based on extended degree and E-shell hierarchy decomposition. Scientific Reports, 13, 3197. doi:10.1038/s41598-023-30308-5.
centrality_ehcc(regulation_net)centrality_ehcc(regulation_net)
Eigenvector centrality (Bonacich 1972) scores a node by the scores of the nodes that point to it. The scores form the dominant eigenvector of the transposed weight matrix:
The vector is scaled to a maximum of one.
centrality_eigenvector(x, ...)centrality_eigenvector(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
holds the edge weights, or ones with weighted = FALSE.
On a directed network a node gains
standing from its incoming edges. The scores lie between 0 and 1. A
network without edges gives every node a score of one.
A named numeric vector with one score per node, in input node order.
Bonacich, P. (1972). Factoring and weighting approaches to status scores and clique identification. Journal of Mathematical Sociology, 2(1), 113-120. doi:10.1080/0022250X.1972.9989806.
centrality_pagerank, centrality_alpha,
centrality_authority, centrality.
centrality_eigenvector(regulation_net)centrality_eigenvector(regulation_net)
Entropy centrality, in the form of the centiserve package, removes the node
and measures how evenly reachability is spread over the remaining network.
With the number of nodes that node reaches in
and half the total of the ,
Terms with are dropped.
centrality_entropy(x, mode = "all", ...)centrality_entropy(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored, and mode sets the direction of
reachability. When the network stays strongly connected after the removal
of any one node, every node scores ,
as on regulation_net.
A named numeric vector with one score per node, in input node order.
centrality_distance_entropy,
centrality_diversity, centrality.
centrality_entropy(regulation_net)centrality_entropy(regulation_net)
Entropy variation (Ai 2017) is the change in the Shannon entropy of a
node-level distribution when a node and its links are removed:
The distribution is the degree or the betweenness. Higher values
mark more important nodes.
centrality_entropy_variation( x, of = c("degree", "betweenness"), mode = "all", ... )centrality_entropy_variation( x, of = c("degree", "betweenness"), mode = "all", ... )
x |
Network input accepted by |
of |
Distribution: |
mode |
For the degree variant on directed networks: |
... |
Further arguments to |
The entropy uses the natural logarithm, as in the code of the author, so
scores are in nats. The difference is signed, and a negative value means
that removing the node evens out the distribution. Edge weights are
ignored in both variants. For the degree variant mode selects the
in-, out- or total degree on a directed network, and self-loops count
toward the degree, and loops = FALSE drops them. The betweenness
variant ignores mode and self-loops. A deletion that leaves every
value of at zero, such as betweenness on a clique, has entropy 0.
A named numeric vector with one score per node, in input node order.
Ai, X. (2017). Node importance ranking of complex networks with entropy variation. Entropy, 19(7), 303.
centrality_betweenness,
centrality_distance_entropy, centrality.
centrality_entropy_variation(regulation_net)centrality_entropy_variation(regulation_net)
Exogenous centrality (Everett and Borgatti 2010) is the total change in a base centrality of the other nodes when the node is deleted:
The default base is reverse closeness,
, with the number of nodes of
the original network. The other bases are raw betweenness and degree.
centrality_exogenous( x, mode = "all", exogenous_base = "reverse_closeness", ... )centrality_exogenous( x, mode = "all", exogenous_base = "reverse_closeness", ... )
x |
Network input accepted by |
mode |
Direction of the base measure: |
exogenous_base |
Base centrality: |
... |
Further arguments to |
The measure uses the simple binary network, so weights, loops and
parallel edges are ignored. mode = "all" uses the undirected
skeleton, and "out" and "in" use directed paths and
degrees. On an undirected network the three modes agree and the degree
base returns the degree. On a directed network the out-degree base
returns the in-degree and the in-degree base the out-degree. Exogenous
betweenness can be negative when a deletion raises the betweenness of
the remaining nodes. An isolated node scores 0. normalized = TRUE
divides by the largest score.
A named numeric vector with one score per node, in input node order.
Everett, M. G., & Borgatti, S. P. (2010). Induced, endogenous and exogenous centrality. Social Networks, 32(4), 339-344. doi:10.1016/j.socnet.2010.06.004.
centrality_closeness_vitality,
centrality_betweenness, centrality.
centrality_exogenous(regulation_net)centrality_exogenous(regulation_net)
Expected centrality is the sum of the degrees of a node's neighbors:
centrality_expected(x, mode = "all", ...)centrality_expected(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode sets both the degrees and the
neighbor set. On a directed network mode = "all" uses total degrees
and the undirected neighbor set. Adding the node's own degree gives the
"kandhway_kuri" form of centrality_diffusion.
A named numeric vector with one score per node, in input node order.
centrality_diffusion,
centrality_neighborhood_connectivity,
centrality.
centrality_expected(regulation_net)centrality_expected(regulation_net)
The Expected Force (Lawyer 2015, equation 1) is the entropy of the
onward spreading potential after two transmission events from a seed
node. Each ordered sequence of two transmissions gives an infected
cluster of three nodes with edges to susceptible nodes,
and with natural logarithms
centrality_expected_force(x, ...)centrality_expected_force(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple unweighted network with direction
kept, so weights, loops and parallel edges are ignored. In a directed
network only outgoing arcs transmit and count toward .
Different orders of the same two infections count as distinct
sequences. A node that cannot start two transmissions scores zero, so
isolated nodes and nodes of components with at most three nodes score
zero. When every cluster has no edge to a susceptible node the entropy
is undefined, and the score is set to zero.
A named numeric vector with one score per node, in input node order.
Lawyer, G. (2015). Understanding the influence of all nodes in a network. Scientific Reports, 5, 8665. doi:10.1038/srep08665.
centrality_modified_expected_force,
centrality_expected, centrality.
centrality_expected_force(regulation_net)centrality_expected_force(regulation_net)
One-step expected influence (Robinaugh, Millner and McNally 2016) sums the signed weights of a node's edges:
Negative edges lower the score, which makes the measure suited to partial-correlation and other signed networks.
centrality_expected_influence_1(x, mode = "out", ...)centrality_expected_influence_1(x, mode = "out", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
mode = "out" (the default here) sums the outgoing weights,
mode = "in" the incoming weights and mode = "all" both, with
a self-loop counted once. On an undirected network the three modes
agree and each edge is counted once. With weighted = FALSE, or on
an unweighted input, the score is the degree in the chosen mode. When the
network has a negative edge, normalized = TRUE divides by the
largest absolute score and keeps the sign.
A named numeric vector with one score per node, in input node order.
Robinaugh, D. J., Millner, A. J., & McNally, R. J. (2016). Identifying highly influential nodes in the complicated grief network. Journal of Abnormal Psychology, 125(6), 747-757. doi:10.1037/abn0000181.
centrality_expected_influence_2,
centrality_strength, centrality.
centrality_expected_influence_1(regulation_net)centrality_expected_influence_1(regulation_net)
Two-step expected influence (Robinaugh, Millner and McNally 2016) adds to the one-step expected influence of a node the one-step expected influence of its neighbors, each weighted by the signed edge between them:
centrality_expected_influence_2(x, mode = "out", ...)centrality_expected_influence_2(x, mode = "out", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
mode = "out" (the default here) follows outgoing edges at both
steps, mode = "in" incoming edges and mode = "all" both, with
a self-loop counted once. On an undirected network the three modes
agree and each edge is counted once. weighted = FALSE gives every
edge weight one. When the
network has a negative edge, normalized = TRUE divides by the
largest absolute score and keeps the sign.
A named numeric vector with one score per node, in input node order.
Robinaugh, D. J., Millner, A. J., & McNally, R. J. (2016). Identifying highly influential nodes in the complicated grief network. Journal of Abnormal Psychology, 125(6), 747-757. doi:10.1037/abn0000181.
centrality_expected_influence_1,
centrality_strength, centrality.
centrality_expected_influence_2(regulation_net)centrality_expected_influence_2(regulation_net)
Extended neighborhood coreness (Bae and Kim 2014) sums the neighborhood coreness of every neighbor of a node:
where is the core number in the whole network. The score
equals .
centrality_extended_coreness(x, ...)centrality_extended_coreness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored. Every walk of length two adds the
core number of its endpoint, including walks that return to the focal
node. Isolated nodes score 0. On a tree the score equals the sum of the
neighbors' degrees, and on a -regular network it equals
.
A named numeric vector with one score per node, in input node order.
Bae, J., & Kim, S. (2014). Identifying and ranking influential spreaders in complex networks by neighborhood coreness. Physica A, 395, 549-559. doi:10.1016/j.physa.2013.10.047.
centrality_coreness,
centrality_extended_gravity, centrality.
centrality_extended_coreness(regulation_net)centrality_extended_coreness(regulation_net)
Extended gravity centrality (Ma et al. 2016) is the sum of the gravity scores of a node's neighbors,
where is the k-shell index and the hop distance.
centrality_extended_gravity(x, gravity_radius = 3, ...)centrality_extended_gravity(x, gravity_radius = 3, ...)
x |
Network input accepted by |
gravity_radius |
Hop radius |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and the masses are always k-shell
indices. The radius applies around each neighbor , so a
contribution can come from hops away from , including
paths back to . Radius 0 and isolated nodes give 0. The
"auto" radius is half the mean finite positive hop distance,
rounded to the nearest integer with a minimum of 1. This rule is a
package choice. A negative radius raises an error.
A named numeric vector with one score per node, in input node order.
Ma, L. L., Ma, C., Zhang, H. F., & Wang, B. H. (2016). Identifying influential spreaders in complex networks based on gravity formula. Physica A, 451, 205-212. doi:10.1016/j.physa.2015.12.162.
centrality_gravity,
centrality_extended_coreness, centrality.
centrality_extended_gravity(regulation_net)centrality_extended_gravity(regulation_net)
Extended local bridging centrality (Macker 2016) multiplies a node's betweenness in its two-hop ego network by its bridging coefficient, the reciprocal of its degree divided by the sum of the reciprocal degrees of its neighbors. The two-hop ego network contains every node within two hops and every edge among them, so its shortest paths can have up to four edges.
centrality_extended_local_bridging(x, ...)centrality_extended_local_bridging(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network, so direction, weights, loops and parallel edges are ignored. Degrees are taken from the whole network. Ego betweenness counts unordered pairs, excludes endpoints and is not normalized. Isolated nodes, leaves and every node of a complete graph score zero. The weighted model of Macker (2016), with link quality and path costs, is not implemented.
A named numeric vector with one score per node, in input node order.
Macker, J. P. (2016). An improved local bridging centrality model for distributed network analytics. MILCOM, pp. 600-605. doi:10.1109/MILCOM.2016.7795393.
centrality_localized_bridging,
centrality_bridging, centrality.
centrality_extended_local_bridging(regulation_net)centrality_extended_local_bridging(regulation_net)
Extended mixed gravitational centrality (Wang, Li and Xia 2018), also called IGC+, sums the mixed gravitational scores of the immediate neighbors of a node:
centrality_extended_mixed_gravity(x, gravity_radius = 3, ...)centrality_extended_mixed_gravity(x, gravity_radius = 3, ...)
x |
Network input accepted by |
gravity_radius |
Hop-distance cutoff of the inner scores. Default
3. |
... |
Further arguments to |
Each inner score uses the radius around ,
so a contribution can come from up to gravity_radius + 1 hops
from the focal node. The implementation follows the reproduction in Li
and Huang (2022), equation 8. The input handling and radius options of
centrality_mixed_gravity apply, so direction, weights,
loops and parallel edges are ignored. Isolated nodes score zero.
A named numeric vector with one score per node, in input node order.
Wang, J., Li, C. and Xia, C. (2018). Improved centrality indicators to characterize the nodal spreading capability in complex networks. Applied Mathematics and Computation, 334, 388-400. doi:10.1016/j.amc.2018.04.028.
Li, Z. and Huang, X. (2022). Identifying influential spreaders by gravity model considering multi-characteristics of nodes. Scientific Reports, 12, 9879. doi:10.1038/s41598-022-14005-3.
centrality_mixed_gravity,
centrality_gravity, centrality.
centrality_extended_mixed_gravity(regulation_net)centrality_extended_mixed_gravity(regulation_net)
Flow betweenness (Freeman, Borgatti and White 1991) sums, over pairs of
other nodes and , the flow that passes through the node
when a maximum flow is sent from to with the edge weights
as capacities.
centrality_flow_betweenness(x, ...)centrality_flow_betweenness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure requires the igraph package and raises an error of class
cograph_needs_igraph without it. The flow through a node is read
from the maximum flow that igraph::max_flow() returns. On a
directed network the sum runs over ordered pairs along the edge direction,
and on an undirected network over unordered pairs. weighted = FALSE
gives every edge capacity one, and invert_weights = TRUE uses
as the capacity.
A named numeric vector with one score per node, in input node order.
Freeman, L. C., Borgatti, S. P., & White, D. R. (1991). Centrality in valued graphs: A measure of betweenness based on network flow. Social Networks, 13(2), 141-154. doi:10.1016/0378-8733(91)90017-N.
centrality_betweenness,
centrality_current_flow_betweenness,
centrality.
centrality_flow_betweenness(regulation_net)centrality_flow_betweenness(regulation_net)
The gateway coefficient (Ruiz Vargas and Wahl 2014) refines the
participation coefficient by weighting the links of node into each
module by how much of the connection between the two modules they
carry and by the degree of the neighbors they reach:
where is the number of links of into module
and lies between 0 and 1.
centrality_gateway(x, membership = NULL, mode = "all", ...)centrality_gateway(x, membership = NULL, mode = "all", ...)
x |
Network input accepted by |
membership |
Module labels, one per node: integer codes, character labels or a factor. |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored, and the score lies between 0 and 1. On a
directed network mode chooses the ties: "out" uses outgoing
links, "in" incoming links and "all" (default) both, with a
reciprocated tie counted twice. The degree , the module
links and the neighbors whose degrees enter
all use the same ties. On an undirected network the
three modes agree and equal brainGraph::gateway_coeff(centr =
"degree"). membership can hold integer, character or factor
labels. Without membership the function returns NA with a
warning of classes cograph_bad_membership and
cograph_undefined_measure, and a membership of the wrong
length raises a cograph_bad_membership error. With a single module
every node scores 0, and so does a node without links in the chosen mode.
A named numeric vector with one score per node, in input node order.
Ruiz Vargas, E., & Wahl, L. M. (2014). The gateway coefficient: A novel metric for identifying critical connections in modular networks. The European Physical Journal B, 87(7), 161. doi:10.1140/epjb/e2014-40800-7.
centrality_participation,
centrality_within_module_z, centrality.
centrality_gateway(regulation_net, membership = rep(1:2, each = 5))centrality_gateway(regulation_net, membership = rep(1:2, each = 5))
Generalized closeness, as in the tidygraph package, sums a decay factor
raised to the distance from the node to every node:
The sum includes the node itself, which adds one to every score, and unreachable nodes contribute 0.
centrality_generalized_closeness(x, mode = "all", decay_parameter = 0.5, ...)centrality_generalized_closeness(x, mode = "all", decay_parameter = 0.5, ...)
x |
Network input accepted by |
mode |
For directed networks: |
decay_parameter |
Decay factor |
... |
Further arguments to |
Edge weights are read as path lengths. invert_weights = TRUE uses
as the length, with the inversion exponent
alpha of centrality, and weighted = FALSE
counts hops. mode sets the direction of the paths. The values equal
those of centrality_decay with the same
decay_parameter, which must lie strictly between 0 and 1; other
values raise a cograph_bad_parameter error.
A named numeric vector with one score per node, in input node order.
centrality_decay,
centrality_harmonic, centrality.
centrality_generalized_closeness(regulation_net)centrality_generalized_closeness(regulation_net)
The Gil-Schmidt power index sums the reciprocal hop distances from a node
to the nodes it reaches and divides by :
Unreachable nodes contribute 0, so the score lies between 0 and 1, and a node adjacent to every other node scores 1.
centrality_gilschmidt(x, mode = "all", ...)centrality_gilschmidt(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored and
invert_weights has no effect. mode sets the direction of the
paths. With mode = "out" the values match
sna::gilschmidt() with its default settings.
A named numeric vector with one score per node, in input node order.
centrality_harmonic,
centrality_closeness, centrality.
centrality_gilschmidt(regulation_net)centrality_gilschmidt(regulation_net)
The global structure model (GSM; Ullah et al. 2021) multiplies a coreness factor of the node by the coreness of all other nodes, each discounted by its hop distance:
Here is the core number and the number of nodes,
isolated nodes included.
centrality_global_structure(x, ...)centrality_global_structure(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and mode has no effect.
Only reachable nodes contribute to the sum, which extends the measure to
disconnected networks. Other components still affect the scores through
. An isolated node scores 0.
A named numeric vector with one score per node, in input node order.
Ullah, A., Wang, B., Sheng, J., Long, J., Khan, N., & Sun, Z. (2021). Identification of nodes influence based on global structure model in complex networks. Scientific Reports, 11, 6173. doi:10.1038/s41598-021-84684-x.
centrality_hybrid_global_structure,
centrality_improved_global_structure,
centrality.
centrality_global_structure(regulation_net)centrality_global_structure(regulation_net)
Graph regularization centrality (Dal Col and Petronetto 2023) is the
reciprocal of the diagonal of the inverse regularized Laplacian, where
is the weighted Laplacian of the undirected network and
is grc_gamma:
A larger score means that Laplacian smoothing retains less of a unit impulse placed at the node.
centrality_graph_regularization(x, grc_gamma = 1, ...)centrality_graph_regularization(x, grc_gamma = 1, ...)
x |
Network input accepted by |
grc_gamma |
Regularization strength, a finite nonnegative number. Default 1. |
... |
Further arguments to |
The measure is computed on the undirected network with loops removed.
For a directed network the weights of opposite arcs are added, and with
weighted = FALSE the simple undirected skeleton is used. Edge
weights must be finite and nonnegative, and a zero weight is an absent
edge. At grc_gamma = 0 every score is one, an isolated node
always scores one, and within a component of nodes the scores
lie between one and . A negative or nonfinite
grc_gamma, or a weight range beyond double precision, raises an
error. The author software (Dal Col 2023) approximates the same filter
with ten Chebyshev terms, so its values can differ from the exact
inverse computed here.
A named numeric vector with one score per node, in input node order.
Dal Col, A., & Petronetto, F. (2023). Graph regularization centrality. Physica A, 628, 129188. doi:10.1016/j.physa.2023.129188.
Dal Col, A. (2023). GRC. Mendeley Data, version 1. doi:10.17632/ns63f5dj86.1.
centrality_laplacian,
centrality_information, centrality.
centrality_graph_regularization(regulation_net)centrality_graph_regularization(regulation_net)
Gravity centrality (Ma et al. 2016) treats node masses as attracting
each other with a force that falls with the squared hop distance, summed
over the nodes within a radius :
The default uses the k-shell index as mass and (Ma et al.
2016). Degree mass without truncation is the gravity model of Li et al.
(2019, eq. 1), and degree mass with gravity_radius = "auto" is
their local gravity model (eq. 2).
centrality_gravity( x, mode = "all", gravity_mass = "kshell", gravity_radius = 3, ... )centrality_gravity( x, mode = "all", gravity_mass = "kshell", gravity_radius = 3, ... )
x |
Network input accepted by |
mode |
Direction for directed networks: |
gravity_mass |
Node mass: |
gravity_radius |
Largest hop distance included: a number (default
3), |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. mode sets
the direction of both the distances and the degree or k-shell masses,
and mode = "all" treats edges as undirected. The "auto"
radius is half the mean finite positive distance, rounded to the nearest
integer with a minimum of 1 (Li et al. 2019, eq. 5). A radius below 1
gives a score of 0 for every node. gravity_mass = "legacy" with
gravity_radius = NULL computes
, with
the degree, the k-shell index and no mass on the focal node.
This form differs from the formula of Li et al. (2019).
A named numeric vector with one score per node, in input node order.
Ma, L.-L., Ma, C., Zhang, H.-F., & Wang, B.-H. (2016). Identifying influential spreaders in complex networks based on gravity formula. Physica A, 451, 205-212.
Li, Z., Ren, T., Ma, X., Liu, S., Zhang, Y., & Zhou, T. (2019). Identifying influential spreaders by gravity model. Scientific Reports, 9, 8387.
centrality_extended_gravity,
centrality_coreness, centrality.
centrality_gravity(regulation_net)centrality_gravity(regulation_net)
Harary centrality sums the inverse squared shortest-path distances from a node to the other nodes:
with , so an unreachable node contributes
nothing and the score is defined on disconnected networks.
centrality_harary(x, mode = "all", ...)centrality_harary(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are read as distances. On regulation_net, whose
weights lie below one, the scores are therefore large.
weighted = FALSE uses hop counts, and invert_weights = TRUE
converts a weight to the distance .
mode = "all" treats edges as undirected, "out" uses
distances from the node and "in" distances to it. The Harary index
of Plavsic et al. (1993) sums the inverse distances ;
its node-level form is centrality_harmonic.
A named numeric vector with one score per node, in input node order.
Plavsic, D., Nikolic, S., Trinajstic, N., & Mihalic, Z. (1993). On the Harary index for the characterization of chemical graphs. Journal of Mathematical Chemistry, 12(1), 235-250. doi:10.1007/BF01164638.
centrality_harmonic,
centrality_closeness, centrality.
centrality_harary(regulation_net)centrality_harary(regulation_net)
Harmonic centrality (Marchiori and Latora 2000) sums the inverse shortest-path distances from a node to the other nodes:
with , so the score is defined on
disconnected networks (Boldi and Vigna 2014).
centrality_inharmonic() and centrality_outharmonic() are the
mode = "in" and mode = "out" forms.
centrality_harmonic(x, mode = "all", ...) centrality_inharmonic(x, ...) centrality_outharmonic(x, ...)centrality_harmonic(x, mode = "all", ...) centrality_inharmonic(x, ...) centrality_outharmonic(x, ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are read as distances, and invert_weights = TRUE
converts a weight to the distance .
weighted = FALSE uses hop counts. mode = "all" treats edges
as undirected, "out" uses distances from the node and "in"
distances to it. The scores equal igraph::harmonic_centrality() on
the weighted graph. normalized = TRUE divides the scores by
, as igraph::harmonic_centrality(normalized = TRUE)
does.
A named numeric vector with one score per node, in input node order.
Marchiori, M., & Latora, V. (2000). Harmony in the small-world. Physica A, 285(3-4), 539-546. doi:10.1016/S0378-4371(00)00311-3.
Boldi, P., & Vigna, S. (2014). Axioms for centrality. Internet Mathematics, 10(3-4), 222-262. doi:10.1080/15427951.2013.865686.
centrality_closeness,
centrality_reaching_local, centrality.
centrality_harmonic(regulation_net)centrality_harmonic(regulation_net)
Hybrid characteristic centrality (Liu and Zheng 2023) adds the extended
degree
to the E-shell position index , each divided by its maximum.
The E-shell decomposition removes, round by round, the remaining nodes of
minimum extended degree, recomputed on the residual graph, and
is the round in which leaves.
centrality_hcc(x, ...)centrality_hcc(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. Scores lie in
. Equation (4) uses the extended degrees of the original
graph, as the source's worked example requires. The normalizers are
global, so adding a disconnected component can change every score. An
isolate leaves in the first round, and every node of an edgeless graph
scores one. A hcc_delta outside raises a
cograph_bad_parameter error. Step 3 of the source's E-shell
procedure prints where its text and Table 2
require , and the minimum is implemented. The
Centrality Zoo describes the E-shell decomposition as a k-shell variant,
which gives different positions on the source's Figure 1.
A named numeric vector with one score per node, in input node order.
Liu, J. and Zheng, J. (2023). Identifying important nodes in complex networks based on extended degree and E-shell hierarchy decomposition. Scientific Reports, 13, 3197. doi:10.1038/s41598-023-30308-5.
centrality_ehcc, centrality_dkgm,
centrality.
centrality_hcc(regulation_net)centrality_hcc(regulation_net)
Five local measures. Heatmap centrality (Duron 2020) is the farness of a
node minus the mean farness of its neighbors,
,
with the sum of hop distances to the reachable nodes. The flow
coefficient (Honey et al. 2007) is the fraction of ordered pairs of
distinct neighbors joined by a two-step path through the node and by no
direct link, as in the Brain Connectivity Toolbox. Local entropy (Nie et
al. 2016) is
. The
weighted h-index (Gao et al. 2019) is the h-index of the multiset in
which each neighbor contributes the value repeated
times. Redundancy (Burt 1992; Borgatti 1997) is the mean degree
of the neighbors of a node within its ego network.
centrality_heatmap(x, mode = "all", ...) centrality_flow_coefficient(x, ...) centrality_local_entropy(x, mode = "all", ...) centrality_weighted_h_index(x, mode = "all", ...) centrality_redundancy(x, ...)centrality_heatmap(x, mode = "all", ...) centrality_flow_coefficient(x, ...) centrality_local_entropy(x, mode = "all", ...) centrality_weighted_h_index(x, mode = "all", ...) centrality_redundancy(x, ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored by all five. Heatmap, local entropy and the
weighted h-index follow mode. Redundancy ignores direction, and
the flow coefficient uses the direction of the links. On an undirected
network the flow coefficient of a node with at least two neighbors equals
one minus its clustering coefficient, and redundancy equals degree minus
effective size. Lower values mark more
central nodes for heatmap and local entropy. Isolated nodes return
NaN for heatmap and 0 for local entropy, and nodes with fewer than
two neighbors score 0 on the flow coefficient. The formula for local
entropy follows the Centrality Zoo and the survey of Omar and Plapper
(2021), which agree.
A named numeric vector with one score per node, in input node order. The weighted h-index is an integer vector.
Duron, C. (2020). Heatmap centrality: A new measure to identify super- spreader nodes in scale-free networks. PLOS ONE, 15(7), e0235690.
Honey, C. J., Kotter, R., Breakspear, M., & Sporns, O. (2007). Network structure of cerebral cortex shapes functional connectivity on multiple time scales. PNAS, 104(24), 10240-10245.
Nie, T., Guo, Z., Zhao, K., & Lu, Z.-M. (2016). Using mapping entropy to identify node centrality in complex networks. Physica A, 453, 290-297.
Gao, L., Yu, S., Li, M., Shen, Z., & Gao, Z. (2019). Weighted h-index for identifying influential spreaders. Symmetry, 11(10), 1263.
Borgatti, S. P. (1997). Structural holes: Unpacking Burt's redundancy measures. Connections, 20(1), 35-38.
centrality_effective_size,
centrality_transitivity, centrality.
centrality_heatmap(regulation_net) centrality_flow_coefficient(regulation_net) centrality_local_entropy(regulation_net) centrality_weighted_h_index(regulation_net) centrality_redundancy(regulation_net)centrality_heatmap(regulation_net) centrality_flow_coefficient(regulation_net) centrality_local_entropy(regulation_net) centrality_weighted_h_index(regulation_net) centrality_redundancy(regulation_net)
Hubbell (1965) centrality solves an input-output system in which the score of a node is one plus the attenuated scores of the nodes it sends ties to:
where is the weighted adjacency matrix and is
hubbell_weight.
centrality_hubbell(x, hubbell_weight = 0.5, ...)centrality_hubbell(x, hubbell_weight = 0.5, ...)
x |
Network input accepted by |
hubbell_weight |
Attenuation factor |
... |
Further arguments to |
The system is solvable when the spectral radius of is below one.
Otherwise every score is NA with a cograph_undefined_measure
warning. A hubbell_weight of zero or below raises a
cograph_bad_parameter error. weighted = FALSE gives every
edge weight one.
The rows of are outgoing ties, so on a directed network the score
sums attenuated walks that leave the node. centiserve::hubbell()
with weights = NULL sets every weight to 1, so it reproduces these
values only when the weights are passed explicitly.
A named numeric vector with one score per node, in input node order.
Hubbell, C. H. (1965). An input-output approach to clique identification. Sociometry, 28(4), 377-399.
centrality_katz, centrality_power,
centrality.
centrality_hubbell(regulation_net)centrality_hubbell(regulation_net)
The hybrid global structure model (H-GSM; Mukhtar et al. 2023) combines
a self-influence
with a distance exponent computed from the mean self-influence:
Here is the core number, the degree and
the number of nodes, isolated nodes included.
centrality_hybrid_global_structure(x, ...)centrality_hybrid_global_structure(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and mode has no effect.
Only reachable nodes contribute to the sum. Other components affect the
scores through and the mean self-influence, to which each
isolated node adds 1. An isolated node scores 0. Raw scores beyond
double precision raise an error. With normalized = TRUE the
scores are computed on the log scale and remain available in that case.
A named numeric vector with one score per node, in input node order.
Mukhtar, M. F., et al. (2023). Integrating local and global information to identify influential nodes in complex networks. Scientific Reports, 13, 11411. doi:10.1038/s41598-023-37570-7.
centrality_global_structure,
centrality_improved_global_structure,
centrality.
centrality_hybrid_global_structure(regulation_net)centrality_hybrid_global_structure(regulation_net)
Immediate effects centrality (Friedkin 1991) is the reciprocal of the mean
length of the influence sequences that end at a node. The influence matrix
is the adjacency matrix with a unit diagonal, divided by its row
sums. With its stationary vector,
and the mean
first passage times
:
centrality_iec(x, ...)centrality_iec(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Direction is used, and weights, loops and parallel edges are ignored, so
the unit diagonal is calibrated against unit edges. mode has no
effect. The measure needs an irreducible chain, that is a connected
undirected or a strongly connected directed network. Otherwise, and on a
single node, every score is NA with a
cograph_undefined_measure warning. The measure differs from
centrality_markov, which omits the unit diagonal and divides
by , and the two can rank nodes differently. The measure is costly
and is computed only when requested by name or through include.
A named numeric vector with one score per node, in input node
order, or NA at every node when the influence chain is reducible
or the network has one node.
Friedkin, N. E. (1991). Theoretical foundations for centrality measures. American Journal of Sociology, 96(6), 1478-1504. doi:10.1086/229694.
centrality_markov,
centrality_random_walk, centrality.
centrality_iec(regulation_net)centrality_iec(regulation_net)
Improved iterative resource allocation (Zhong, Liu and Shang 2015) is
centrality_ira with the receiver's share scaled by its
spreading capacity , where
is the degree and the spreading rate. The
recursion runs a fixed number of
steps from .
centrality_iira( x, ira_mass = "coreness", iira_beta = 0.2, iira_steps = 50, ... )centrality_iira( x, ira_mass = "coreness", iira_beta = 0.2, iira_steps = 50, ... )
x |
Network input accepted by |
ira_mass |
Node centrality |
iira_beta |
Spreading rate |
iira_steps |
Number of iterations, a nonnegative whole number (default 50). |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. Every column
of sums to less than one, so the scores decay geometrically and
only their order carries meaning. normalized = TRUE divides them by
their maximum. Each connected component decays at its own rate, so raw
scores are comparable only within a component, and a large
iira_steps underflows to zero. An isolate scores zero, and
iira_steps = 0 returns a vector of ones. The Centrality Zoo
(section 2.185) states a different matrix, which is stochastic in neither
direction and does not reproduce the source's worked example. The
implementation follows the source.
A named numeric vector with one score per node, in input node order.
Zhong, L.-F., Liu, J.-G. and Shang, M.-S. (2015). Iterative resource allocation based on propagation feature of node for identifying the influential nodes. Physics Letters A, 379(38), 2272-2276. doi:10.1016/j.physleta.2015.05.021.
centrality_iira(regulation_net, normalized = TRUE)centrality_iira(regulation_net, normalized = TRUE)
Improved closeness (Luan et al. 2021) divides each hop distance by a power of the number of shortest paths, so that a partner reached along many shortest paths counts as closer:
Here is the hop distance and
the number of shortest paths between and .
centrality_improved_closeness(x, icc_alpha = 0.2, ...)centrality_improved_closeness(x, icc_alpha = 0.2, ...)
x |
Network input accepted by |
icc_alpha |
Exponent |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and mode has no effect.
With the score on a connected network is the
normalized closeness,
and on a tree it does not depend on . Scores can
exceed 1. On a disconnected network every node scores 0, because each
node has an unreachable partner at infinite distance. An isolated node
also scores 0. A value of icc_alpha outside 0 to 1 raises an
error.
A named numeric vector with one score per node, in input node order.
Luan, Y., Bao, Z., & Zhang, H. (2021). Identifying Influential Spreaders in Complex Networks by Considering the Impact of the Number of Shortest Paths. Journal of Systems Science and Complexity, 34, 2168-2181. doi:10.1007/s11424-021-0111-7.
centrality_closeness,
centrality_harmonic, centrality.
centrality_improved_closeness(regulation_net)centrality_improved_closeness(regulation_net)
The improved global structure model (IGSM; Zhu and Wang 2022) replaces
the core numbers of centrality_global_structure with
degrees and raises each distance to an exponent set by the mean degree
:
The formula follows equation 5 of Mukhtar et al. (2023).
centrality_improved_global_structure(x, ...)centrality_improved_global_structure(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored, and mode has no effect.
Only reachable nodes contribute to the sum, and and the mean
degree include every node of the network. When the mean degree is at
most 1 the exponent is zero or negative, and with a negative exponent
distant nodes contribute more than near ones. An isolated node scores
0, and so does every node of a network without edges.
A named numeric vector with one score per node, in input node order.
Zhu, J.-C., & Wang, L.-W. (2022). An extended improved global structure model for influential node identification in complex networks. Chinese Physics B, 31, 068904. doi:10.1088/1674-1056/ac380d.
Mukhtar, M. F., et al. (2023). Integrating local and global information to identify influential nodes in complex networks. Scientific Reports, 13, 11411. doi:10.1038/s41598-023-37570-7.
centrality_global_structure,
centrality_hybrid_global_structure,
centrality.
centrality_improved_global_structure(regulation_net)centrality_improved_global_structure(regulation_net)
Information centrality (Stephenson and Zelen 1989) measures the
information carried by all paths between a node and the others, each path
weighted by its length. With , where
has diagonal ( the strength) and
off-diagonal entries ,
where is the trace of and the sum of row
.
centrality_information(x, ...)centrality_information(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The network is symmetrized with ,
so direction is ignored. Edge weights enter as tie strengths, and
weighted = FALSE uses the binary matrix. Isolated nodes score 0 and
are left out of . When the other nodes do not form one connected
component, or is singular, every score is NA with a
cograph_undefined_measure warning. On unweighted
undirected networks the values equal sna::infocent().
A named numeric vector with one score per node, in input node order.
Stephenson, K., & Zelen, M. (1989). Rethinking centrality: Methods and examples. Social Networks, 11(1), 1-37.
centrality_current_flow_closeness,
centrality_closeness, centrality.
centrality_information(regulation_net)centrality_information(regulation_net)
Integration centrality (Valente and Foreman 1998) scores each distance
against the diameter , the largest finite hop distance, and sums:
where an unreachable node contributes 0.
centrality_integration(x, mode = "all", ...)centrality_integration(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. The sum includes
the node itself, which contributes , and is not divided by
; the values equal tidygraph::centrality_integration().
mode = "all" treats edges as undirected, "out" uses
distances from the node and "in" distances to it. On a network
without edges every node scores .
A named numeric vector with one score per node, in input node order.
Valente, T. W., & Foreman, R. K. (1998). Integration and radiality: Measuring the extent of an individual's connectedness and reachability in a network. Social Networks, 20(1), 89-105. doi:10.1016/S0378-8733(97)00007-5.
centrality_radiality,
centrality_closeness, centrality.
centrality_integration(regulation_net)centrality_integration(regulation_net)
Iterative resource allocation (Ren et al. 2014) starts every node with one
unit of resource and repeatedly passes it to the neighbors in proportion to
the receiver's centrality . The steady state ranks the
spreaders.
centrality_ira( x, ira_mass = "coreness", ira_alpha = 1, ira_tol = 1e-06, ira_max_iter = 1000, ... )centrality_ira( x, ira_mass = "coreness", ira_alpha = 1, ira_tol = 1e-06, ira_max_iter = 1000, ... )
x |
Network input accepted by |
ira_mass |
Node centrality |
ira_alpha |
Exponent |
ira_tol |
Positive stopping tolerance on the largest absolute change
between iterates (default |
ira_max_iter |
Maximum number of iterations, a whole number of at least one (default 1000). |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. The total
resource is conserved, so on a graph without isolates the scores sum to
the number of nodes. An isolate receives nothing and scores zero. The
iteration stops when the largest absolute change falls below
ira_tol. On a bipartite component whose two vertex classes differ
in size, such as a star, the iteration has a period-two cycle. It then
reaches ira_max_iter, raises a cograph_no_converge warning
and returns the last iterate. The Centrality Zoo states the measure as the
left eigenvector of the transposed matrix, which agrees up to scale where
the limit exists. The implementation follows the source's iteration.
A named numeric vector with one score per node, in input node order.
Ren, Z.-M., Zeng, A., Chen, D.-B., Liao, H. and Liu, J.-G. (2014). Iterative resource allocation for ranking spreaders in complex networks. EPL (Europhysics Letters), 106(4), 48005. doi:10.1209/0295-5075/106/48005.
centrality_ira(regulation_net)centrality_ira(regulation_net)
Katz (1953) status sums the walks of every length that end at a node,
each step attenuated by :
where is the weighted adjacency matrix and is
katz_alpha.
centrality_katz(x, katz_alpha = 0.1, ...)centrality_katz(x, katz_alpha = 0.1, ...)
x |
Network input accepted by |
katz_alpha |
Attenuation factor |
... |
Further arguments to |
The series converges for , where
is the spectral radius. A divergent series is
detected from scores below one and raises a cograph_katz_diverged
warning that names the bound; the returned values are then not Katz
scores. weighted = FALSE gives every edge weight one. On a
directed network the score counts walks that arrive at the node. A
network of one node without a self-loop scores 1. The values equal igraph::alpha_centrality(exo = 1) with the
same alpha.
A named numeric vector with one score per node, in input node order.
Katz, L. (1953). A new status index derived from sociometric analysis. Psychometrika, 18(1), 39-43.
centrality_alpha,
centrality_eigenvector, centrality_hubbell,
centrality.
centrality_katz(regulation_net)centrality_katz(regulation_net)
The KED method (Chen et al. 2014) combines a node's degree with
the number and the diversity of the local paths that leave it. The local
path number
is the neighbors' degree sum, and the path diversity is the
entropy of the shares divided by
.
centrality_ked(x, ...)centrality_ked(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. The source's
directed variant is not implemented. lies in , and
it is set to zero for a node with one neighbor, where it is
. Isolates score zero. is the number of nodes in the
whole network, so adding a disconnected component changes every score and
can change the ranking. The source's stated range
holds only when
, and an overflow of the exponential raises an
error. The Centrality Zoo (section 2.215) adds exponents, drops the
term and divides by the largest . That form does not
reproduce the scores printed in the source.
A named numeric vector with one score per node, in input node order.
Chen, D.-B., Xiao, R., Zeng, A. and Zhang, Y.-C. (2014). Path diversity improves the identification of influential spreaders. Europhysics Letters, 104(6), 68006. doi:10.1209/0295-5075/104/68006.
centrality_lnc, centrality_entropy,
centrality.
centrality_ked(regulation_net)centrality_ked(regulation_net)
Geodesic k-reach centrality (Borgatti and Everett 2006) counts the nodes
that lie within shortest-path distance of a node.
centrality_kreach(x, mode = "all", k = 3, ...)centrality_kreach(x, mode = "all", k = 3, ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
k |
Largest distance counted, a positive number (default 3). |
... |
Further arguments to |
Edge weights are read as distances, so on a weighted network is
compared with the summed weights along a path; on regulation_net,
whose weights lie below one, every node reaches all others within
. invert_weights = TRUE converts a weight to the
distance . weighted = FALSE uses hop
counts. mode = "all" treats edges as undirected, "out" counts nodes
reached from the node and "in" nodes that reach it. A k of
zero or below raises a cograph_bad_parameter error.
A named integer vector with one count per node, in input node order.
Borgatti, S. P., & Everett, M. G. (2006). A graph-theoretic perspective on centrality. Social Networks, 28(4), 466-484. doi:10.1016/j.socnet.2005.11.005.
centrality_geodesic_kpath,
centrality_harmonic, centrality.
centrality_kreach(regulation_net, k = 0.2)centrality_kreach(regulation_net, k = 0.2)
Local average connectivity (Li et al. 2011) is the mean degree of the
neighbors of a node within the subgraph induced by those
neighbors:
where is the degree of inside
. High values mark nodes whose neighbors are tied to each other.
centrality_lac(x, mode = "all", ...)centrality_lac(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects the neighbors and the degree
counted inside . With mode = "all" on a directed network
in-ties and out-ties are both counted, so a reciprocated tie counts twice.
An isolated node scores 0.
A named numeric vector with one score per node, in input node order.
Li, M., Wang, J., Chen, X., Wang, H., & Pan, Y. (2011). A local average connectivity-based method for identifying essential proteins from the network level. Computational Biology and Chemistry, 35(3), 143-150.
centrality_dmnc, centrality_mnc,
centrality.
centrality_lac(regulation_net)centrality_lac(regulation_net)
Laplacian centrality (Qi et al. 2012) is the drop in the Laplacian energy of a network when a node is removed. Without edge weights the drop is
centrality_laplacian(x, ...)centrality_laplacian(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are ignored, so the score is the unweighted case of the
weighted measure of Qi et al. (2012). On a directed network is the
total degree, in plus out, and the neighbor sum runs over out-neighbors.
A self-loop adds 2 to the degree. On undirected networks the values equal
centiserve::laplacian(). normalized = TRUE divides the
scores by their maximum.
A named numeric vector with one score per node, in input node order.
Qi, X., Fuller, E., Wu, Q., Wu, Y., & Zhang, C.-Q. (2012). Laplacian centrality: A new centrality measure for weighted networks. Information Sciences, 194, 240-253. doi:10.1016/j.ins.2011.12.027.
centrality_degree,
centrality_semilocal, centrality.
centrality_laplacian(regulation_net)centrality_laplacian(regulation_net)
LeaderRank (Lu et al. 2011) adds a ground node joined in both directions to every node and runs a random walk without damping on the extended network. The final score of the ground node is shared equally among the other nodes.
centrality_leaderrank(x, ...)centrality_leaderrank(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure needs a directed network. On undirected input every score is
NA with a cograph_undefined_measure warning. Edge weights are
ignored; centrality_weighted_leaderrank uses them. The walk
starts with one unit at every node and none at the ground node, so the
scores sum to . The values equal centiserve::leaderrank().
A named numeric vector with one score per node, in input node order.
Lu, L., Zhang, Y.-C., Yeung, C. H., & Zhou, T. (2011). Leaders in social networks, the Delicious case. PLoS ONE, 6(6), e21202. doi:10.1371/journal.pone.0021202.
centrality_weighted_leaderrank,
centrality_pagerank, centrality.
centrality_leaderrank(regulation_net)centrality_leaderrank(regulation_net)
Length-scaled betweenness (Borgatti and Everett 2006; Brandes 2008)
weights each pair in the betweenness sum by .
Delta betweenness (Agneessens et al. 2017) uses the pair weight
, where is
the number of edges on a shortest path, so
gives ordinary betweenness. Ego betweenness (Everett and Borgatti 2005)
is the betweenness of a node inside its own ego network. Delta closeness
(Agneessens et al. 2017, eq. 2) is
centrality_length_scaled_betweenness(x, ...) centrality_delta_betweenness(x, betweenness_delta = 1, ...) centrality_ego_betweenness(x, ...) centrality_delta_closeness(x, mode = "all", closeness_delta = 1, ...)centrality_length_scaled_betweenness(x, ...) centrality_delta_betweenness(x, betweenness_delta = 1, ...) centrality_ego_betweenness(x, ...) centrality_delta_closeness(x, mode = "all", closeness_delta = 1, ...)
x |
Network input accepted by |
... |
Further arguments to |
betweenness_delta |
Decay exponent |
mode |
Direction for delta closeness: |
closeness_delta |
Distance exponent |
On a directed network the three betweenness measures count directed
paths. Length-scaled and delta betweenness and delta closeness read edge
weights as distances, and invert_weights = TRUE converts weights
to distances . In delta betweenness the
weighted distances decide which paths are shortest, and the pair weight
uses the number of edges
on a shortest path (the fewest when several tie), so
is the number of intermediaries. On a binary network
. A pair joined by a one-edge shortest path
contributes nothing. weighted = FALSE uses hop counts. Ego betweenness ignores weights, and a node with fewer
than two neighbors scores 0. Delta closeness follows mode and
cutoff. On hop distances gives harmonic
closeness divided by and gives the share of
nodes reached. Bounded-distance betweenness, listed in the Centrality
Zoo as k-betweenness, is centrality_betweenness(x, cutoff = k).
A named numeric vector with one score per node, in input node order.
Borgatti, S. P., & Everett, M. G. (2006). A graph-theoretic perspective on centrality. Social Networks, 28(4), 466-484. doi:10.1016/j.socnet.2005.11.005.
Agneessens, F., Borgatti, S. P., & Everett, M. G. (2017). Geodesic based centrality: Unifying the local and the global. Social Networks, 49, 12-26.
Brandes, U. (2008). On variants of shortest-path betweenness centrality and their generic computation. Social Networks, 30(2), 136-145.
Everett, M., & Borgatti, S. P. (2005). Ego network betweenness. Social Networks, 27(1), 31-38.
centrality_betweenness,
centrality_harmonic, centrality.
centrality_length_scaled_betweenness(regulation_net) centrality_delta_betweenness(regulation_net, weighted = FALSE) centrality_ego_betweenness(regulation_net) centrality_delta_closeness(regulation_net, closeness_delta = 2)centrality_length_scaled_betweenness(regulation_net) centrality_delta_betweenness(regulation_net, weighted = FALSE) centrality_ego_betweenness(regulation_net) centrality_delta_closeness(regulation_net, closeness_delta = 2)
Leverage centrality (Joyce et al. 2010) compares the degree of a node with the degrees of its neighbors:
Positive values mark nodes with more ties than their typical neighbor.
centrality_leverage(x, mode = "all", ...)centrality_leverage(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects both the degree and the
neighbor set, and with mode = "all" on a directed network the
degree is in plus out. The score lies between -1 and 1. An isolated node
is NaN. On undirected networks the values equal
centiserve::leverage().
A named numeric vector with one score per node, in input node order.
Joyce, K. E., Laurienti, P. J., Burdette, J. H., & Hayasaka, S. (2010). A new measure of centrality for brain networks. PLoS ONE, 5(8), e12200. doi:10.1371/journal.pone.0012200.
centrality_degree,
centrality_neighborhood_connectivity,
centrality.
centrality_leverage(regulation_net)centrality_leverage(regulation_net)
The Lhc index (Wang et al. 2021) sums over a node's neighbors an
influence , the degree of every node within distance
of , inflated by its triangle share and divided by the
squared distance. The triangle share is
, where
counts the triangles on and
.
centrality_lhc(x, ...)centrality_lhc(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. On a
triangle-free graph is set to zero. is a global sum,
so adding a component that carries a triangle changes every score.
Isolates score zero. A lhc_radius that is not a whole number of at
least one raises a cograph_bad_parameter error. The Centrality Zoo
(section 2.221) names the denominator the number of triangles, which is
one third of . The implementation follows the source.
A named numeric vector with one score per node, in input node order.
Wang, X., Yang, Q., Liu, M. and Ma, X. (2021). Comprehensive influence of topological location and neighbor information on identifying influential nodes in complex networks. PLoS ONE, 16(5), e0251208. doi:10.1371/journal.pone.0251208.
centrality_hcc, centrality_ked,
centrality.
centrality_lhc(regulation_net)centrality_lhc(regulation_net)
Lin centrality divides the squared number of nodes a node reaches by the sum of its distances to them:
where is the set of nodes reachable from . The
score is defined on disconnected networks.
centrality_lin(x, mode = "all", ...)centrality_lin(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are read as distances. weighted = FALSE uses hop
counts, and invert_weights = TRUE converts a weight to the
distance . mode = "all" treats edges as
undirected, "out" uses distances from the node and "in"
distances to it. A node that reaches no other node scores 0, and a
single-node network gives NA. On undirected networks the values
equal centiserve::lincent().
A named numeric vector with one score per node, in input node order.
centrality_closeness,
centrality_harmonic, centrality.
centrality_lin(regulation_net)centrality_lin(regulation_net)
LineRank (Kang et al. 2011) computes PageRank on the line graph, whose
nodes are the edges of the network, and gives each node the sum of the
stationary probabilities of its incident edges. In a directed network
edge leads to edge when the target of
is the source of . In an undirected network two edges are
adjacent when they share an endpoint (Kosa et al. 2015).
centrality_linerank( x, damping = 0.85, linerank_aggregation = "probability", ... )centrality_linerank( x, damping = 0.85, linerank_aggregation = "probability", ... )
x |
Network input accepted by |
damping |
Probability of continuing the walk on the line graph, in
|
linerank_aggregation |
|
... |
Further arguments to |
The walk on the line graph moves to an adjacent edge with probability
proportional to that edge's weight and jumps to a uniformly chosen edge
with probability 1 - damping. An edge without successors also
jumps uniformly. With linerank_aggregation = "probability" the
scores sum to two on a network with edges. With "weight" each
stationary probability is multiplied by its edge weight before
aggregation, following the weighted incidence matrix of Algorithm 2 in
Kang et al. (2011). A loop contributes twice to its node, and an
isolated node scores zero. Edge weights must be finite and nonnegative,
and weighted = FALSE gives every edge weight one. A
damping outside raises an error.
A named numeric vector with one score per node, in input node order.
Kang, U., Papadimitriou, S., Sun, J., & Tong, H. (2011). Centralities in Large Networks: Algorithms and Observations. Proceedings of the 2011 SIAM International Conference on Data Mining, 119-130. doi:10.1137/1.9781611972818.11.
Kosa, B., Balassi, M., Englert, P., & Kiss, A. (2015). Betweenness versus Linerank. Computer Science and Information Systems, 12(1), 33-48. doi:10.2298/CSIS141101092K.
centrality_pagerank,
centrality_betweenness, centrality.
centrality_linerank(regulation_net)centrality_linerank(regulation_net)
Local neighbor contribution (Dai et al. 2019) multiplies a node's own
contribution by
its neighbor contribution, the squared degree times the neighbors' degree
sum divided by .
centrality_lnc(x, ...)centrality_lnc(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored, and it takes
no parameters. The count is the number of nodes in the whole
network, so adding a disconnected component rescales every score and
leaves the ranking unchanged. Isolates and the node of a single-node graph
score zero. The factorization above is the one that reproduces the
source's printed intermediates and Table 1. The Centrality Zoo (section
2.238) replaces the degree by the two-hop neighborhood size and does not
reproduce the source's values.
A named numeric vector with one score per node, in input node order.
Dai, J., Wang, B., Sheng, J., Sun, Z., Khawaja, F. R., Ullah, A., Dejene, D. A. and Duan, G. (2019). Identifying influential nodes in complex networks based on local neighbor contribution. IEEE Access, 7, 131719-131731. doi:10.1109/ACCESS.2019.2939804.
centrality_semilocal,
centrality_ked, centrality.
centrality_lnc(regulation_net)centrality_lnc(regulation_net)
Load centrality (Goh et al. 2001) sends one unit of load from every node to every other node along shortest paths. At each branching the load is split equally among the shortest-path predecessors, and the score of a node is the total load that passes through it.
centrality_load(x, ...)centrality_load(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are read as distances. weighted = FALSE uses hop
counts, and invert_weights = TRUE converts a weight to the
distance . Paths follow edge direction on a
directed network. The values equal sna::loadcent(), which credits
the endpoints of each path as well as the intermediate nodes, so the
scores are larger than betweenness.
A named numeric vector with one score per node, in input node order.
Goh, K.-I., Kahng, B., & Kim, D. (2001). Universal behavior of load distribution in scale-free networks. Physical Review Letters, 87(27), 278701. doi:10.1103/PhysRevLett.87.278701.
centrality_betweenness,
centrality_stress, centrality.
centrality_load(regulation_net)centrality_load(regulation_net)
The lobby index (Korn et al. 2009) is the h-index of the degrees in the
closed neighborhood of a node. It is the largest such that the
node and its neighbors include at least nodes of degree
or more.
centrality_lobby(x, mode = "all", ...)centrality_lobby(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects both the degree and the
neighbors, and with mode = "all" on a directed network the degree
is in plus out. An isolated node scores 0. On undirected networks the
values equal centiserve::lobby().
A named integer vector with one index per node, in input node order.
Korn, A., Schubert, A., & Telcs, A. (2009). Lobby index in networks. Physica A, 388(11), 2221-2226. doi:10.1016/j.physa.2009.02.013.
centrality_degree,
centrality_coreness, centrality.
centrality_lobby(regulation_net)centrality_lobby(regulation_net)
Local bridging centrality multiplies the bridging coefficient of a node by its inverse degree:
A node of low degree whose neighbors have high degree scores high.
centrality_local_bridging(x, ...)centrality_local_bridging(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are ignored. On a directed network is the total
degree, in plus out, and a reciprocated tie counts twice. An isolated node
scores 0. The local bridging centrality of Nanda and Kotz, the product of
ego betweenness and the bridging coefficient, is
centrality_localized_bridging.
A named numeric vector with one score per node, in input node order.
centrality_bridging,
centrality_localized_bridging, centrality.
centrality_local_bridging(regulation_net)centrality_local_bridging(regulation_net)
The local dimension (Silva and Costa 2013; Pu et al. 2014) is the growth
exponent of the ball around a node. With the number
of nodes within hops of , the node itself included, it is
the least-squares slope of on
over
:
centrality_local_dimension(x, mode = "all", ...)centrality_local_dimension(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. On a directed
network mode sets the direction of the paths. A node that reaches
most of the network in a few hops has a small exponent, so lower values
mark more influential nodes. A node with a single radius returns the
discretized derivative
at , where
counts the nodes at distance exactly . A node
that reaches no other node returns NaN.
A named numeric vector with one score per node, in input node order.
Silva, F. N., & Costa, L. da F. (2013). Local dimension of complex networks. arXiv:1209.2476.
Pu, J., Chen, X., Wei, D., Liu, Q., & Deng, Y. (2014). Identifying influential nodes based on local dimension. EPL, 107(1), 10010.
Wen, T., & Jiang, W. (2019). Identifying influential nodes based on fuzzy local dimension in complex networks. Chaos, Solitons & Fractals, 119, 332-342.
centrality_local_information_dimension,
centrality_local_dimension_fixed,
centrality.
centrality_local_dimension(regulation_net)centrality_local_dimension(regulation_net)
Three members of the local-dimension family, with the center node counted
in its own ball. The fixed-radius local dimension (Silva and Costa 2013)
is
at one
radius , where counts the nodes at distance
and those within it. The fuzzy local
dimension (Wen and Jiang 2019) is the slope of
on for the fuzzy ball
The local volume dimension (Li and Deng 2021) is the slope of
on for the volume
.
centrality_local_dimension_fixed(x, mode = "all", ld_radius = 2, ...) centrality_fuzzy_local_dimension(x, mode = "all", ...) centrality_local_volume_dimension(x, mode = "all", ...)centrality_local_dimension_fixed(x, mode = "all", ld_radius = 2, ...) centrality_fuzzy_local_dimension(x, mode = "all", ...) centrality_local_volume_dimension(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
ld_radius |
Radius |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. On a directed
network mode sets the direction of the paths. The fixed-radius
form is a structural descriptor, and nodes whose eccentricity is below
the radius score 0. Larger fuzzy dimensions and smaller volume dimensions
mark more influential nodes. The two regression forms return NaN
for a node with fewer than two radii. The volume dimension follows a
later preprint of the authors and the Centrality Zoo entry. A
ld_radius that is not a single number of at least 1 raises an
error of class cograph_bad_parameter.
A named numeric vector with one score per node, in input node order.
Silva, F. N., & Costa, L. da F. (2013). Local dimension of complex networks. arXiv:1209.2476.
Wen, T., & Jiang, W. (2019). Identifying influential nodes based on fuzzy local dimension in complex networks. Chaos, Solitons & Fractals, 119, 332-342.
Li, H., & Deng, Y. (2021). Local volume dimension: A novel approach for important nodes identification in complex networks. International Journal of Modern Physics B, 35(5), 2150069.
centrality_local_dimension,
centrality_local_information_dimension,
centrality.
centrality_local_dimension_fixed(regulation_net) centrality_fuzzy_local_dimension(regulation_net) centrality_local_volume_dimension(regulation_net)centrality_local_dimension_fixed(regulation_net) centrality_fuzzy_local_dimension(regulation_net) centrality_local_volume_dimension(regulation_net)
Local efficiency (Latora and Marchiori 2001) is the mean of
over ordered pairs of a node's neighbors, with
distances measured inside the subgraph induced on those neighbors. The
s-core index (Eidsaa and Almaas 2013) is the largest strength threshold
whose s-core contains the node. Fragmentation (Borgatti 2006) is
the distance-weighted fragmentation of the network after the node is
deleted,
The k-path count (Sade 1989) is the number of simple paths of length at
most kpath_len that pass through or end at the node. The edge
percolated component (EPC; Lin et al. 2008) is the mean size of the
node's component, as a share of all nodes, when each edge is kept with
probability 1 - epc_threshold.
centrality_local_efficiency(x, mode = "all", ...) centrality_s_core(x, ...) centrality_fragmentation(x, mode = "all", ...) centrality_kpath(x, mode = "all", kpath_len = 3, ...) centrality_epc(x, epc_threshold = 0.5, epc_runs = 1000, epc_seed = NULL, ...)centrality_local_efficiency(x, mode = "all", ...) centrality_s_core(x, ...) centrality_fragmentation(x, mode = "all", ...) centrality_kpath(x, mode = "all", kpath_len = 3, ...) centrality_epc(x, epc_threshold = 0.5, epc_runs = 1000, epc_seed = NULL, ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
kpath_len |
Maximum path length for the k-path count. Default 3. Length 1 gives the degree in the undirected skeleton. |
epc_threshold |
Probability that an edge is removed in one realization. Default 0.5. |
epc_runs |
Number of percolation realizations. Default 1000. |
epc_seed |
Random seed. The default |
Local efficiency, fragmentation and the k-path count follow mode,
and mode = "all" treats edges as undirected. Local efficiency and
fragmentation read edge weights as distances, so with weights below one
local efficiency exceeds one and fragmentation is negative;
invert_weights = TRUE converts weights to distances
. On unweighted input both lie between 0 and
1, and a node with fewer than two neighbors has local efficiency 0.
Fragmentation is NaN on a network with fewer than three nodes.
The s-core index symmetrizes the network by the stronger of the two
directions and equals the k-core number when all weights are one. The
k-path count and EPC ignore weights, and EPC uses the undirected
skeleton. EPC is a Monte Carlo estimate, and cytoHubba and
centiserve::epc() report the same quantity multiplied by the
number of runs.
A named numeric vector with one score per node, in input node order.
Latora, V., & Marchiori, M. (2001). Efficient behavior of small-world networks. Physical Review Letters, 87(19), 198701.
Eidsaa, M., & Almaas, E. (2013). s-core network decomposition: A generalization of k-core analysis to weighted networks. Physical Review E, 88(6), 062819. doi:10.1103/PhysRevE.88.062819.
Borgatti, S. P. (2006). Identifying sets of key players in a social network. Computational and Mathematical Organization Theory, 12(1), 21-34.
Sade, D. S. (1989). Sociometrics of Macaca mulatta III: n-path centrality in grooming networks. Social Networks, 11(3), 273-292.
Lin, C.-Y., Chin, C.-H., Wu, H.-H., Chen, S.-H., Ho, C.-W., & Ko, M.-T. (2008). Hubba: hub objects analyzer, a framework of interactome hubs identification for network biology. Nucleic Acids Research, 36, W438-W443. doi:10.1093/nar/gkn257.
centrality_coreness,
centrality_geodesic_kpath,
network_local_efficiency, centrality.
centrality_local_efficiency(regulation_net) centrality_s_core(regulation_net) centrality_fragmentation(regulation_net, weighted = FALSE) centrality_kpath(regulation_net, kpath_len = 2) centrality_epc(regulation_net, epc_runs = 100, epc_seed = 1)centrality_local_efficiency(regulation_net) centrality_s_core(regulation_net) centrality_fragmentation(regulation_net, weighted = FALSE) centrality_kpath(regulation_net, kpath_len = 2) centrality_epc(regulation_net, epc_runs = 100, epc_seed = 1)
Local information dimensionality (Wen and Deng 2020) weights the local
dimension by information. With
the share of the network within hops of , the node
included, and box information
, the measure
is minus the least-squares slope of on
for
:
centrality_local_information_dimension(x, mode = "all", ...)centrality_local_information_dimension(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Distances are hop counts, so edge weights are ignored. On a directed
network mode sets the direction of the paths. Higher values mark
more influential nodes. A node with a single box size returns the
discretized derivative of the source,
. A
node that reaches no other node returns NaN.
A named numeric vector with one score per node, in input node order.
Wen, T., & Deng, Y. (2020). Identification of influencers in complex networks by local information dimensionality. Information Sciences, 512, 549-562.
centrality_local_dimension,
centrality_local_dimension_fixed,
centrality.
centrality_local_information_dimension(regulation_net)centrality_local_information_dimension(regulation_net)
Localized bridging centrality (Nanda and Kotz 2012) is the product of a
node's betweenness in its one-hop ego network
and its bridging coefficient, the reciprocal of its degree divided by
the sum of the reciprocal degrees of its neighbors:
centrality_localized_bridging(x, ...)centrality_localized_bridging(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network, so direction, weights, loops and parallel edges are ignored. Degrees are taken from the whole network. Ego betweenness counts unordered pairs of the other ego-network nodes, excludes endpoints and is not normalized. Isolated nodes, leaves and every node of a complete graph score zero.
A named numeric vector with one score per node, in input node order.
Nanda, S. and Kotz, D. (2012). Localized Bridging Centrality. In Handbook of Optimization in Complex Networks, pp. 197-224. doi:10.1007/978-1-4614-0857-4_7.
centrality_extended_local_bridging,
centrality_local_bridging,
centrality_ego_betweenness, centrality.
centrality_localized_bridging(regulation_net)centrality_localized_bridging(regulation_net)
The Malatya centrality of a node (Karci et al. 2022) is the sum of its
degree divided by the degree of each neighbor,
.
High scores mark nodes with many neighbors of low degree.
centrality_malatya(x, ...)centrality_malatya(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights,
loops and parallel edges are ignored. Isolated nodes score 0. On a
regular network the score equals the degree. On every node with at least
one neighbor it is the reciprocal of
centrality_bridging_coefficient.
A named numeric vector with one score per node, in input node order.
Karci, A., Yakut, S., & Oztemiz, F. (2022). A New Approach Based on Centrality Value in Solving the Minimum Vertex Cover Problem: Malatya Centrality Algorithm. Journal of Computer Science, 7(2), 81-88. doi:10.53070/bbd.1195501.
centrality_bridging_coefficient,
centrality_degree, centrality.
centrality_malatya(regulation_net)centrality_malatya(regulation_net)
Map equation centrality (Blocker et al. 2022) is the reduction in
codelength, in bits, when a node's codeword is removed from its module
codebook and the codebook is redesigned. With the visit rate
of the node and the use rate of its module codebook,
centrality_map_equation( x, membership = NULL, map_flow = "unrecorded", map_convention = "paper", ... )centrality_map_equation( x, membership = NULL, map_flow = "unrecorded", map_convention = "paper", ... )
x |
Network input accepted by |
membership |
One module label per node. |
map_flow |
|
map_convention |
|
... |
Further arguments to |
The partition is held fixed and is given by membership, and
NULL places every node in one module. With
map_convention = "paper" the rate includes module
exits (equations 2 and 9-11), and with "infomap" it includes node
visits only, which reproduces Infomap 2.15.1 and Table 1 of the paper.
With map_flow = "unrecorded" (Lambiotte and Rosvall 2012) the
walk teleports in proportion to out-strength and only link steps are
recorded, so on an undirected network the visit rates are proportional
to strength for every damping. With "recorded" the walk
teleports uniformly and teleportation steps are recorded. Direction is
kept, loops are removed and edge weights must be finite and
nonnegative. Under unrecorded flow an isolated node scores zero. An
invalid membership, map_flow or map_convention, or
a damping outside , raises an error.
A named numeric vector with one score per node, in input node order.
Blocker, C., Nieves, J. C. and Rosvall, M. (2022). Map equation centrality: community-aware centrality based on the map equation. Applied Network Science, 7, 56. doi:10.1007/s41109-022-00477-9.
Lambiotte, R. and Rosvall, M. (2012). Ranking and clustering of nodes in networks with smart teleportation. Physical Review E, 85, 056107. doi:10.1103/PhysRevE.85.056107.
centrality_community_based,
centrality_participation, centrality.
centrality_map_equation(regulation_net, membership = rep(1:2, each = 5))centrality_map_equation(regulation_net, membership = rep(1:2, each = 5))
Markov centrality (White and Smyth 2003) is the inverse of the mean first passage time of a random walk into a node:
where is the expected number of steps from to
the first visit of and .
centrality_markov(x, ...)centrality_markov(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The walk moves from a node to each of its out-neighbors with equal
probability, so edge weights are ignored. A disconnected network, or a
directed network with a node that has no outgoing edge, gives NA
for every node with a cograph_undefined_measure warning. On a
directed network that is not strongly connected, a node that some other
node cannot reach has an infinite mean passage time, and its score is
NA with the same warning. On connected undirected and strongly
connected directed networks the values equal
centiserve::markovcent().
A named numeric vector with one score per node, in input node order.
White, S., & Smyth, P. (2003). Algorithms for estimating relative importance in networks. In Proceedings of the Ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 266-275). doi:10.1145/956750.956782.
centrality_random_walk,
centrality_pagerank, centrality.
centrality_markov(regulation_net)centrality_markov(regulation_net)
Maximal clique centrality (MCC; Chin et al. 2014) sums
over the maximal cliques that contain the node.
A clique contained in a larger clique does not count.
centrality_mcc(x, ...)centrality_mcc(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights, loops and parallel edges are ignored. Single-node cliques are excluded, so an isolated node scores 0. A node whose neighbors share no edge scores its degree. Maximal clique enumeration has exponential worst-case cost. A score beyond double precision, which includes any clique with more than 171 nodes, raises an error.
A named numeric vector with one score per node, in input node order.
Chin, C. H., et al. (2014). cytoHubba: identifying hub objects and sub-networks from complex interactome. BMC Systems Biology, 8(Suppl 4), S11. doi:10.1186/1752-0509-8-S4-S11.
centrality_cross_clique,
centrality_epc, centrality.
centrality_mcc(regulation_net)centrality_mcc(regulation_net)
MCGM (Li and Huang 2022) is a gravity model whose node mass combines
degree , core number and eigenvector centrality
, each divided by its maximum over the network:
By default is the larger of the medians of
and divided by the median of
(equation 17).
centrality_mcgm(x, mcgm_radius = 2, mcgm_alpha = NULL, ...)centrality_mcgm(x, mcgm_radius = 2, mcgm_alpha = NULL, ...)
x |
Network input accepted by |
mcgm_radius |
Hop-distance cutoff |
mcgm_alpha |
|
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights, loops and parallel edges are ignored,
and gravity_mass and gravity_radius have no effect. On a
disconnected network the eigenvector feature is the projection of the
all-ones vector onto the dominant eigenspace, so a component with a
smaller spectral radius has . When the median core
number is zero the automatic is undefined, and an
error asks for mcgm_alpha. mcgm_alpha = 1 gives equation
16 of the paper. Isolated nodes score zero, and an edgeless network or
a radius below one gives zero scores.
A named numeric vector with one score per node, in input node order.
Li, Z. and Huang, X. (2022). Identifying influential spreaders by gravity model considering multi-characteristics of nodes. Scientific Reports, 12, 9879. doi:10.1038/s41598-022-14005-3.
centrality_gravity,
centrality_mixed_gravity, centrality.
centrality_mcgm(regulation_net)centrality_mcgm(regulation_net)
Mixed gravitational centrality (Wang, Li and Xia 2018), also called
improved gravitational centrality, uses the core number
of the focal node and the degree of
each partner node as masses:
centrality_mixed_gravity(x, gravity_radius = 3, ...)centrality_mixed_gravity(x, gravity_radius = 3, ...)
x |
Network input accepted by |
gravity_radius |
Hop-distance cutoff |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights, loops and parallel edges are ignored,
and gravity_mass has no effect. The implementation follows the
reproduction of the method in Li and Huang (2022), equations 5-8. The
Centrality Zoo writes the inner sum over immediate neighbors, which
corresponds to gravity_radius = 1. Isolated nodes score zero, and
unreachable nodes contribute nothing. gravity_radius = "auto" is
a cograph heuristic that rounds half the mean finite distance to the
nearest integer, with a minimum of one. A negative radius raises an
error.
A named numeric vector with one score per node, in input node order.
Wang, J., Li, C. and Xia, C. (2018). Improved centrality indicators to characterize the nodal spreading capability in complex networks. Applied Mathematics and Computation, 334, 388-400. doi:10.1016/j.amc.2018.04.028.
Li, Z. and Huang, X. (2022). Identifying influential spreaders by gravity model considering multi-characteristics of nodes. Scientific Reports, 12, 9879. doi:10.1038/s41598-022-14005-3.
centrality_extended_mixed_gravity,
centrality_gravity, centrality.
centrality_mixed_gravity(regulation_net)centrality_mixed_gravity(regulation_net)
The maximum neighborhood component (Lin et al. 2008) is the number of nodes in the largest connected component of the subgraph induced by the neighbors of a node.
centrality_mnc(x, mode = "all", ...)centrality_mnc(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored and the neighbor subgraph is read as undirected.
mode selects the neighbors. An isolated node scores 0. On
undirected networks the values equal centiserve::mnc().
A named integer vector with one size per node, in input node order.
Lin, C.-Y., Chin, C.-H., Wu, H.-H., Chen, S.-H., Ho, C.-W., & Ko, M.-T. (2008). Hubba: hub objects analyzer, a framework of interactome hubs identification for network biology. Nucleic Acids Research, 36, W438-W443. doi:10.1093/nar/gkn257.
centrality_dmnc, centrality_lac,
centrality.
centrality_mnc(regulation_net)centrality_mnc(regulation_net)
The modified Expected Force (Lawyer 2015, equation 2) multiplies the
Expected Force of a node by the logarithm of its scaled degree
:
centrality_modified_expected_force(x, exf_alpha = 2, ...)centrality_modified_expected_force(x, exf_alpha = 2, ...)
x |
Network input accepted by |
exf_alpha |
Degree scaling factor |
... |
Further arguments to |
On a directed network is the out-degree, in line with the
outgoing transmission process. An isolated node scores zero. The input
handling and zero conventions of centrality_expected_force
apply. An exf_alpha that is not a finite number greater than one
raises an error.
A named numeric vector with one score per node, in input node order.
Lawyer, G. (2015). Understanding the influence of all nodes in a network. Scientific Reports, 5, 8665. doi:10.1038/srep08665.
centrality_expected_force,
centrality.
centrality_modified_expected_force(regulation_net)centrality_modified_expected_force(regulation_net)
Modularity vitality (Magelinski, Bartulovic and Carley 2021) is the drop
in Newman modularity of a fixed partition when a node is deleted
and the remaining nodes keep their communities:
Positive values mark community hubs and negative values mark bridges between communities.
centrality_modularity_vitality(x, membership = NULL, ...)centrality_modularity_vitality(x, membership = NULL, ...)
x |
Network input accepted by |
membership |
Community labels, one per node (integer, factor or
character), for example from |
... |
Further arguments to |
Edge weights are used. A directed network uses the Leicht-Newman
directed modularity, and the values equal those obtained by deleting
each node and recomputing igraph::modularity(). Self-loops enter
the modularity, and loops = FALSE drops them. A node whose deletion
leaves a graph with no edges returns NaN. Without
membership the function raises a warning of classes cograph_bad_membership and
cograph_undefined_measure and returns
NA for every node. A membership that is not one
non-missing label per node raises an error of class
cograph_bad_membership.
A named numeric vector with one score per node, in input node order.
Magelinski, T., Bartulovic, M., & Carley, K. M. (2021). Measuring node contribution to community structure with modularity vitality. IEEE Transactions on Network Science and Engineering, 8(1), 707-723.
centrality_participation,
centrality_within_module_z, centrality.
centrality_modularity_vitality(regulation_net, membership = rep(1:2, each = 5))centrality_modularity_vitality(regulation_net, membership = rep(1:2, each = 5))
NCVoteRank (Kumar and Panda 2020) is VoteRank (Zhang et al. 2016) with the voting ability of each voter weighted by its neighborhood coreness. A node collects the score
with the k-shell index. The top scorer is elected, its ability
drops to 0, its neighbors lose and the
nodes two steps away lose .
centrality_ncvoterank(x, ncvote_theta = 0.5, ...)centrality_ncvoterank(x, ncvote_theta = 0.5, ...)
x |
Network input accepted by |
ncvote_theta |
Weight |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights and loops are ignored. Elections continue
until every node is placed. The first elected scores 1 and the last
, so scores lie in . The definition
follows the Centrality Zoo and three independent restatements of the
article, and the scaling of the coreness by its maximum follows Yu et
al. (2020). With and no two-step weakening the
procedure is VoteRank.
A named numeric vector with one score per node, in input node order.
Kumar, S., & Panda, B. S. (2020). Identifying influential nodes in social networks: Neighborhood coreness based voting approach. Physica A, 553, 124215.
Zhang, J.-X., Chen, D.-B., Dong, Q., & Zhao, Z.-D. (2016). Identifying a set of influential spreaders in complex networks. Scientific Reports, 6, 27823.
centrality_voterank,
centrality_wvoterank, centrality.
centrality_ncvoterank(regulation_net)centrality_ncvoterank(regulation_net)
Neighborhood centrality (Liu et al. 2016) adds to a node's benchmark
centrality the benchmark centrality of the endpoints
of its non-backtracking walks of length 1 to , discounted by
at step . With the defaults (degree benchmark, two
steps, ) it is the neighbor distance centrality.
centrality_neighbor_distance( x, nd_order = 2, nd_decay = 0.2, nd_mass = "degree", ... )centrality_neighbor_distance( x, nd_order = 2, nd_decay = 0.2, nd_mass = "degree", ... )
x |
Network input accepted by |
nd_order |
Number of steps |
nd_decay |
Per-step decay |
nd_mass |
Benchmark centrality |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights, loops and parallel edges are ignored. Each level
excludes only the node the walk came from, so a walk may revisit a node.
Isolates score , which is zero for both
benchmarks, and nd_order = 0 returns the benchmark itself. The
source takes in , and the function accepts any finite
value. The Centrality Zoo paraphrases the measure with sums over distance
shells, which agree with the source's walk sums on trees and differ on
graphs with short cycles. The implementation follows the source.
A named numeric vector with one score per node, in input node order.
Liu, Y., Tang, M., Zhou, T. and Do, Y. (2016). Identify influential spreaders in complex networks, the role of neighborhood. Physica A: Statistical Mechanics and its Applications, 452, 289-298. doi:10.1016/j.physa.2016.02.028.
centrality_semilocal,
centrality_extended_coreness, centrality.
centrality_neighbor_distance(regulation_net)centrality_neighbor_distance(regulation_net)
Neighborhood connectivity (Maslov and Sneppen 2002) is the mean degree of the neighbors of a node, the average neighbor degree reported by Cytoscape:
centrality_neighborhood_connectivity(x, mode = "all", ...)centrality_neighborhood_connectivity(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
Edge weights are ignored. Under mode = "out" the out-degrees of the
out-neighbors are averaged, and under mode = "in" the in-degrees of
the in-neighbors. Self-loops change the degrees, and loops = FALSE
drops them. Isolated nodes score 0. High values mark nodes attached to
hubs.
A named numeric vector with one score per node, in input node order.
Maslov, S., & Sneppen, K. (2002). Specificity and stability in topology of protein networks. Science, 296(5569), 910-913.
centrality_degree, centrality.
centrality_neighborhood_connectivity(regulation_net)centrality_neighborhood_connectivity(regulation_net)
NINL (Zhu and Wang 2021) starts each node with the sum of the degrees
in its closed neighborhood of radius and then,
for iterations, replaces every score by the sum of the
previous scores of its neighbors:
centrality_ninl(x, ninl_order = 3, ninl_radius = NULL, ...)centrality_ninl(x, ninl_order = 3, ninl_radius = NULL, ...)
x |
Network input accepted by |
ninl_order |
Number of iterations |
ninl_radius |
Radius |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights, loops and parallel edges are ignored.
The default radius is the ceiling of the average shortest-path length,
as in the paper. On a disconnected network that average is infinite, so
the default radius covers the whole component of each node. Isolated
nodes score zero, and ninl_order = 0 returns the initial degree
sums. With normalized = TRUE the scores are rescaled at every
iteration, and on a bipartite network they can alternate between
iterations. An invalid ninl_order or ninl_radius, and raw
scores that overflow, raise an error.
A named numeric vector with one score per node, in input node order.
Zhu, J. and Wang, L. (2021). Identifying Influential Nodes in Complex Networks Based on Node Itself and Neighbor Layer Information. Symmetry, 13, 1570. doi:10.3390/sym13091570.
centrality_semilocal,
centrality_eigenvector, centrality.
centrality_ninl(regulation_net)centrality_ninl(regulation_net)
Node contraction importance (Tan, Wu and Deng 2006, as restated by Wang
et al. 2011) compares the agglomeration
of a network,
with the mean shortest-path length, before and after the
node is merged with all its neighbors into one node:
The improved form adds the same score of the edges of the node computed
on the line graph,
,
with .
centrality_node_contraction(x, ...) centrality_node_contraction_improved(x, contraction_rho = 5, ...)centrality_node_contraction(x, ...) centrality_node_contraction_improved(x, contraction_rho = 5, ...)
x |
Network input accepted by |
... |
Further arguments to |
contraction_rho |
Ratio |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights and loops are ignored. Higher values mark
more important nodes. The sources assume a connected network. On a
disconnected network the mean path length is taken over the mutually
reachable ordered pairs. An isolated node scores 0, and a node whose
contraction leaves no pair of mutually reachable nodes returns
NaN. The Centrality Zoo describes the contracted graph as the
graph with the node removed. The sources define it by contraction, which
is implemented here.
A named numeric vector with one score per node, in input node order.
Tan, Y.-J., Wu, J., & Deng, H.-Z. (2006). Evaluation method for node importance based on node contraction in complex networks. Systems Engineering: Theory & Practice, 26(11), 79-83.
centrality_closeness_vitality,
centrality.
centrality_node_contraction(regulation_net) centrality_node_contraction_improved(regulation_net)centrality_node_contraction(regulation_net) centrality_node_contraction_improved(regulation_net)
PageRank (Brin and Page 1998) is the stationary distribution of a random
walk that follows an out-edge with probability , choosing edges in
proportion to their weights, and otherwise jumps to a node drawn from the
reset distribution :
where is the row-normalized weight matrix and is
damping.
centrality_pagerank(x, damping = 0.85, personalized = NULL, ...)centrality_pagerank(x, damping = 0.85, personalized = NULL, ...)
x |
Network input accepted by |
damping |
Probability |
personalized |
Reset distribution |
... |
Further arguments to |
weighted = FALSE gives every edge weight one. A node without
out-edges passes its score to the reset distribution. The scores sum to
one and equal igraph::page_rank(). The vector personalized
is rescaled to sum to one. A named vector is matched to the node names,
and its names must be the node names, each used once; an unnamed vector
is matched by position. A negative weight raises a
cograph_negative_weights error, an invalid personalized a
cograph_bad_input error, and a damping outside
a cograph_bad_parameter error.
A named numeric vector with one score per node, in input node order.
Brin, S., & Page, L. (1998). The anatomy of a large-scale hypertextual Web search engine. Computer Networks and ISDN Systems, 30(1-7), 107-117. doi:10.1016/S0169-7552(98)00110-X.
centrality_eigenvector,
centrality_leaderrank, centrality.
centrality_pagerank(regulation_net)centrality_pagerank(regulation_net)
Pairwise disconnectivity (Potapov et al. 2008) is the share of ordered reachable pairs that become unreachable when a node is removed:
where is the number of ordered pairs ,
, with a directed path from to .
centrality_pairwisedis(x, ...)centrality_pairwisedis(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure needs a directed network. On undirected input every score is
NA with a cograph_undefined_measure warning. Reachability
uses hop counts, so edge weights are ignored. The score lies between 0
and 1, and a network without reachable pairs scores 0 everywhere. The
values equal centiserve::pairwisedis().
A named numeric vector with one score per node, in input node order.
Potapov, A. P., Goemann, B., & Wingender, E. (2008). The pairwise disconnectivity index as a new metric for the topological analysis of regulatory networks. BMC Bioinformatics, 9, 227. doi:10.1186/1471-2105-9-227.
centrality_prestige_domain, robustness,
centrality.
centrality_pairwisedis(regulation_net)centrality_pairwisedis(regulation_net)
The participation coefficient (Guimera and Nunes Amaral 2005) measures how evenly the ties of a node spread over communities:
where counts the ties of node to community
and is its degree.
centrality_participation(x, membership = NULL, mode = "all", ...)centrality_participation(x, membership = NULL, mode = "all", ...)
x |
Network input accepted by |
membership |
Community of each node, a vector with one entry per
node in input node order (default |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects the ties counted, and with
mode = "all" on a directed network a reciprocated tie counts twice.
A node whose ties all stay in one community scores 0, as does an isolated
node, and the score is below 1. Without membership every score is
NA with a warning of classes cograph_bad_membership and
cograph_undefined_measure, and a membership of the wrong
length raises a cograph_bad_membership error. On undirected
networks the values equal brainGraph::part_coeff().
A named numeric vector with one score per node, in input node order.
Guimera, R., & Nunes Amaral, L. A. (2005). Functional cartography of complex metabolic networks. Nature, 433(7028), 895-900. doi:10.1038/nature03288.
centrality_within_module_z,
centrality_gateway, centrality.
centrality_participation(regulation_net, membership = rep(1:2, each = 5))centrality_participation(regulation_net, membership = rep(1:2, each = 5))
Percolation centrality (Piraveenan et al. 2013) weights each shortest path
through a node by the percolation state of its source:
where is the number of shortest paths from
to and the number through
. With equal states the score is the normalized betweenness.
centrality_percolation(x, states = NULL, ...)centrality_percolation(x, states = NULL, ...)
x |
Network input accepted by |
states |
Percolation state of each node, between 0 and 1. The
default |
... |
Further arguments to |
Edge weights are read as distances, weighted = FALSE uses hop
counts, and invert_weights = TRUE uses the distance
, so tna input is inverted by default. Paths
follow edge direction on a directed network. states is matched to
nodes by name when it has names and by position otherwise. Its values are
clipped to and missing values are set to 1, and a vector of
the wrong length raises an error. A network with fewer than three nodes
scores 0.
A named numeric vector with one score per node, in input node order.
Piraveenan, M., Prokopenko, M., & Hossain, L. (2013). Percolation centrality: Quantifying graph-theoretic impact of nodes during percolation in networks. PLoS ONE, 8(1), e53095. doi:10.1371/journal.pone.0053095.
centrality_betweenness,
centrality_load, centrality.
centrality_percolation(regulation_net)centrality_percolation(regulation_net)
Bonacich (1987) power centrality with exponent
sums the walks leaving a node, each further step weighted by :
where is the binary adjacency matrix and scales
the scores so that their squares sum to .
centrality_power(x, mode = "all", ...)centrality_power(x, mode = "all", ...)
x |
Network input accepted by |
mode |
For directed networks: |
... |
Further arguments to |
The exponent is fixed at 1. Edge weights and self-loops are ignored. On a
directed network mode = "out" sums over out-ties and equals
igraph::power_centrality(exponent = 1), mode = "in" sums
over in-ties, and mode = "all" (default) uses the undirected
skeleton, the binary matrix with a tie wherever either direction has one.
On an undirected network the three modes agree. Where is
singular, as on a
network that contains an isolated edge, a cograph_singular_system
error is raised, and a network without edges gives NaN. The scores
can be negative, as on regulation_net, and normalized = TRUE
leaves scores that are all negative unchanged.
A named numeric vector with one score per node, in input node order.
Bonacich, P. (1987). Power and centrality: A family of measures. American Journal of Sociology, 92(5), 1170-1182. doi:10.1086/228631.
centrality_eigenvector,
centrality_katz, centrality.
centrality_power(regulation_net)centrality_power(regulation_net)
Domain prestige (Wasserman and Faust 1994) counts the other nodes that reach a node through a directed path:
centrality_prestige_domain(x, ...)centrality_prestige_domain(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure needs a directed network. On undirected input every score is
NA with a cograph_undefined_measure warning. Edge weights are
ignored. The score is a whole number between 0 and . The values
equal sna::prestige(cmode = "domain").
A named numeric vector with one score per node, in input node order.
Wasserman, S., & Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press.
centrality_prestige_domain_proximity,
centrality_reaching_local, centrality.
centrality_prestige_domain(regulation_net)centrality_prestige_domain(regulation_net)
Domain proximity prestige (Wasserman and Faust 1994) combines the number of nodes that reach a node with their distance to it:
where is the number of other nodes with a directed path to
and the sum of their hop distances to .
centrality_prestige_domain_proximity(x, ...)centrality_prestige_domain_proximity(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure needs a directed network. On undirected input every score is
NA with a cograph_undefined_measure warning. Edge weights are
ignored. A node that no other node reaches scores 0, and the score lies
between 0 and 1. On strongly connected networks the values equal
sna::prestige(cmode = "domain.proximity"). On other networks sna
sets some scores to 0, because its sum multiplies an infinite distance by
zero; cograph sums the finite distances only.
A named numeric vector with one score per node, in input node order.
Wasserman, S., & Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press.
centrality_prestige_domain,
centrality_reaching_local, centrality.
centrality_prestige_domain_proximity(regulation_net)centrality_prestige_domain_proximity(regulation_net)
Proximal betweenness (Brandes 2008, section 3.2) is the fraction of shortest paths on which a node is the last intermediate node before the destination (proximal source) or the first intermediate node after the source (proximal target). Each reachable ordered pair of nodes contributes one unit, divided equally among its shortest paths.
centrality_proximal_betweenness(x, proximal_variant = "source", ...)centrality_proximal_betweenness(x, proximal_variant = "source", ...)
x |
Network input accepted by |
proximal_variant |
|
... |
Further arguments to |
Shortest paths are counted with unit edge lengths on the simple network,
so direction is kept and weights, loops and parallel edges are ignored.
Ordered pairs are counted on undirected networks as well, so the scores
are not halved. Endpoints are excluded, and paths with fewer than two
edges contribute nothing. On an undirected network the source and
target variants agree, and "sum" is twice either of them. The
"union" variant counts a node once when a two-edge path makes it
both proximal source and proximal target. Isolated nodes and every node
of a complete graph score zero.
A named numeric vector with one score per node, in input node order.
Brandes, U. (2008). On variants of shortest-path betweenness centrality and their generic computation. Social Networks, 30, 136-145. doi:10.1016/j.socnet.2007.11.001.
centrality_betweenness,
centrality_stress, centrality.
centrality_proximal_betweenness(regulation_net)centrality_proximal_betweenness(regulation_net)
Radiality (Valente and Foreman 1998) reverses each distance against the
diameter and averages over the network:
Nodes close to the others score high.
centrality_radiality(x, mode = "all", ...)centrality_radiality(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
The sum includes the node itself, which contributes , and the
values equal centiserve::radiality() on undirected networks.
Unreachable nodes contribute 0. Edge weights are read as distances;
weighted = FALSE uses hop counts, and invert_weights = TRUE
converts a weight to the distance .
mode = "all" treats edges as undirected, "out" uses
distances from the node and "in" distances to it. The diameter is
taken on the stored edge weights in the direction of the network,
whatever mode and invert_weights are. A single-node network
gives NA.
A named numeric vector with one score per node, in input node order.
Valente, T. W., & Foreman, R. K. (1998). Integration and radiality: Measuring the extent of an individual's connectedness and reachability in a network. Social Networks, 20(1), 89-105. doi:10.1016/S0378-8733(97)00007-5.
centrality_integration,
centrality_closeness, centrality.
centrality_radiality(regulation_net)centrality_radiality(regulation_net)
Random walk centrality is the inverse of the summed random-walk distances from a node to the others:
where is the mean first passage time from to
of a walk that moves to each out-neighbor with equal probability.
centrality_random_walk(x, ...)centrality_random_walk(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are ignored. The measure is defined for connected undirected
and strongly connected directed networks. On any other network every
score is NA, with a cograph_undefined_measure warning,
because some passage times are infinite. The passage times are
symmetrized before
the sum, so the values differ from
tidygraph::centrality_random_walk(), which sums them unsymmetrized.
A named numeric vector with one score per node, in input node order.
centrality_markov,
centrality_current_flow_closeness,
centrality.
centrality_random_walk(regulation_net)centrality_random_walk(regulation_net)
Random walk decay centrality (Was, Rahwan and Skibski 2019) sums, over
all starting nodes , the starting weight times
the expected discounted first arrival of a random walk from
at node . With the first arrival time and
the decay factor rwd_decay,
centrality_random_walk_decay(x, rwd_decay = 0.5, rwd_node_weights = NULL, ...)centrality_random_walk_decay(x, rwd_decay = 0.5, rwd_node_weights = NULL, ...)
x |
Network input accepted by |
rwd_decay |
Decay factor |
rwd_node_weights |
Nonnegative starting weights |
... |
Further arguments to |
The walk follows outgoing edges with probability proportional to their
weights, and an undirected edge is traversed in both directions. A walk
that reaches a node without outgoing edges stops. Loops are kept as
transitions that stay at the node unless loops = FALSE. The start
counts as an arrival at time zero, so an isolated node scores its own
starting weight and rwd_decay = 0 returns the starting weights.
Edge weights must be finite and nonnegative, and weighted = FALSE
ignores edge weights while keeping rwd_node_weights. Invalid
rwd_decay or rwd_node_weights, and raw scores that
overflow, raise an error. Example 3 of the paper contains inconsistent
numerical values, and the implementation follows Definition 1, equation
6.
A named numeric vector with one score per node, in input node order.
Was, T., Rahwan, T., & Skibski, O. (2019). Random Walk Decay Centrality. Proceedings of the AAAI Conference on Artificial Intelligence, 33(01), 2197-2204. doi:10.1609/aaai.v33i01.33012197.
centrality_pagerank,
centrality_random_walk, centrality.
centrality_random_walk_decay(regulation_net)centrality_random_walk_decay(regulation_net)
Local reaching centrality (Mones et al. 2012) measures how much of the
network a node reaches. On an unweighted directed network it is the share
of the other nodes reachable from the node. On an unweighted undirected
network it is the mean inverse distance to the other nodes, harmonic
centrality divided by .
centrality_reaching_local(x, mode = "all", ...)centrality_reaching_local(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
A network counts as weighted unless every weight is 1, and
weighted = FALSE gives the unweighted form. In the weighted form
a shortest path uses the edge lengths , with the total
edge weight, and each reached node contributes the mean edge weight along
its path; the sum is divided by . With mode = "out" the
weighted values equal networkx.local_reaching_centrality() with
normalized = False. mode = "all" treats edges as undirected,
and "in" counts the nodes that reach the node. A negative weight
raises an error. reaching_global is the network-level
hierarchy measure built from these scores.
A named numeric vector with one score per node, in input node order.
Mones, E., Vicsek, L., & Vicsek, T. (2012). Hierarchy measure for complex networks. PLoS ONE, 7(3), e33799.
reaching_global, centrality_harmonic,
centrality.
centrality_reaching_local(regulation_net)centrality_reaching_local(regulation_net)
The relative-entropy integrated evaluation (Chen, Wang and Luo 2016) combines several centrality indexes into one score. Each index is turned into a distribution over the nodes, and the score is the distribution with the smallest total relative entropy to all of them, which is their normalized geometric mean:
A positive index (larger is more important) maps to
, and a negative index
(smaller is more important) maps to the normalized complement
.
centrality_relative_entropy( x, re_indexes = c("degree", "closeness", "betweenness", "constraint"), re_negative = NULL, ... )centrality_relative_entropy( x, re_indexes = c("degree", "closeness", "betweenness", "constraint"), re_negative = NULL, ... )
x |
Network input accepted by |
re_indexes |
Character vector of constituent indexes, without
repeats. The default |
re_negative |
Character vector naming the members of
|
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network,
so direction, weights and loops are ignored. The available indexes are
"degree", "closeness" (the reciprocal of the distance sum
over reachable partners), "betweenness" (summed over ordered
pairs), "constraint" (the source's equation 6, whose outer sum runs
over every other node), "n_components" and
"largest_component" (the components left after deleting the node).
The scores sum to one, and a node that scores zero on any index scores
zero overall. An index that is zero at every node, such as betweenness on
a complete graph, raises a cograph_undefined_index error when the
measure is requested by name. Inside type = "all" the same case
gives a cograph_undefined_measure warning and an NA column.
The source's equation 6 differs from Burt's constraint as computed by
igraph::constraint().
A named numeric vector with one score per node, in input node
order, summing to one. With normalized = TRUE the scores are
divided by their maximum and no longer sum to one.
Chen, B., Wang, Z. and Luo, C. (2016). Integrated evaluation approach for node importance of complex networks based on relative entropy. Journal of Systems Engineering and Electronics, 27(6), 1219-1226. doi:10.21629/JSEE.2016.06.10.
centrality_bridging,
list_centralities, centrality.
centrality_relative_entropy(regulation_net)centrality_relative_entropy(regulation_net)
Residual closeness (Dangalchev 2006) sums distances that decay by half with every step:
with , so the score is defined on
disconnected networks.
centrality_residual_closeness(x, mode = "all", ...)centrality_residual_closeness(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
The sum includes the node itself, which adds 1, and the values equal
centiserve::closeness.residual() on undirected networks. Edge
weights are read as distances; weighted = FALSE uses hop counts,
and invert_weights = TRUE converts a weight to the distance
. mode = "all" treats edges as
undirected, "out" uses distances from the node and "in"
distances to it. centrality_dangalchev returns the same
values.
A named numeric vector with one score per node, in input node order.
Dangalchev, C. (2006). Residual closeness in networks. Physica A, 365(2), 556-564. doi:10.1016/j.physa.2005.12.020.
centrality_dangalchev,
centrality_decay, centrality.
centrality_residual_closeness(regulation_net)centrality_residual_closeness(regulation_net)
The node resistance curvature of Devriendt and Lambiotte (2022) is
where the weights are conductances and
is the effective resistance. It equals one minus half
the expected degree of the node in a random spanning tree of its
component.
centrality_resistance_curvature(x, ...)centrality_resistance_curvature(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are conductances, and weighted = FALSE uses the
simple undirected skeleton. On a weighted directed network the two arcs
between a pair are added. Self-loops are removed, mode has no
effect, and negative or non-finite weights raise an error. Scores can be
negative at tree-like junctions. On a tree the score is one minus half
the degree, on an unweighted cycle or complete graph of nodes it
is , and an isolated node scores 1. The raw scores sum to the
number of components.
A named numeric vector with one score per node, in input node order.
Devriendt, K., & Lambiotte, R. (2022). Discrete curvature on graphs from the effective resistance. Journal of Physics: Complexity, 3, 025008. doi:10.1088/2632-072X/ac730d.
centrality_current_flow_closeness,
centrality_dynamical_importance, centrality.
centrality_resistance_curvature(regulation_net)centrality_resistance_curvature(regulation_net)
Randomized shortest paths betweenness (Kivimaki et al. 2016) scores a node
by the expected number of visits it receives from absorbing walks between
every ordered source-target pair, under a Boltzmann distribution that
favors low-cost walks with inverse temperature . Large
approaches shortest-path betweenness, and
approaches a random-walk quantity that is
proportional to degree on an undirected graph. With
and
:
centrality_rsp_betweenness(x, ...)centrality_rsp_betweenness(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Direction and edge weights are used and loops are dropped.
mode, cutoff and invert_weights have no effect. The
cost is with rsp_cost = "inverse" and
with "weight", and with weighted = FALSE every arc costs
one.
Following the source, a pair with no connecting path contributes zero, so
scores are component-local, and nodes with no out-edges score zero. A
rsp_beta at or below zero raises a cograph_bad_parameter
error, and negative or non-finite weights raise a
cograph_bad_input error. The measure needs one dense matrix
inverse, so it is costly and is computed only when requested by name or
through include.
A named numeric vector with one score per node, in input node order.
Kivimaki, I., Lebichot, B., Saramaki, J. and Saerens, M. (2016). Two betweenness centrality measures based on Randomized Shortest Paths. Scientific Reports, 6, 19668. doi:10.1038/srep19668.
centrality_betweenness,
centrality_current_flow_betweenness,
centrality.
centrality_rsp_betweenness(regulation_net)centrality_rsp_betweenness(regulation_net)
Rumor centrality (Shah and Zaman 2010, 2011) is the maximum-likelihood
score for the source of a rumor that has spread to every node under the
susceptible-infected model. On a tree rooted at it counts the
spreading orders that start at ,
where is the size of the subtree rooted at . On
a general graph is evaluated on the breadth-first tree rooted at
each node.
centrality_rumor(x, ...)centrality_rumor(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The value is returned as with the natural
logarithm, because overflows beyond 170 nodes. is the
size of the component of the node, so a disconnected network is scored
component by component and an isolated node scores 0. The breadth-first
tree attaches each node to the earliest discovered node of the previous
layer, scanning neighbors in node order. Direction, edge weights and
self-loops are ignored. Higher values mark more plausible origins.
A named numeric vector with one score per node, in input node
order, holding .
Shah, D., & Zaman, T. (2010). Detecting sources of computer viruses in networks: theory and experiment. ACM SIGMETRICS, 203-214.
Shah, D., & Zaman, T. (2011). Rumors in a network: Who's the culprit? IEEE Transactions on Information Theory, 57(8), 5163-5181.
centrality_closeness, centrality.
centrality_rumor(regulation_net)centrality_rumor(regulation_net)
The s-shell index (Liu, Tang, Do and Hui 2017) peels the network like the k-shell decomposition but by a strength computed from the topology. Each link gets the asymmetric weight
where counts the neighbors of outside
the closed neighborhood of , and the strength of is
. At each
step the nodes at the minimum remaining strength are removed, the
removals cascade, and the removed nodes receive the next shell index.
centrality_s_shell(x, s_shell_a = 0.5, ...)centrality_s_shell(x, s_shell_a = 0.5, ...)
x |
Network input accepted by |
s_shell_a |
Exponent |
... |
Further arguments to |
Direction, edge weights and self-loops are ignored. The index is an
ordinal counter starting at 1 for the outermost shell, so values are
comparable within a network only. Higher indices mark more central
nodes. Isolated nodes form shell 1 on their own and shift every other
shell up by one. With the shells are the dense ranks of the
k-core numbers. A s_shell_a that is not a single non-negative
number raises an error of class cograph_bad_parameter.
A named integer vector with one shell index per node, in input node order.
Liu, Y., Tang, M., Do, Y., & Hui, P. M. (2017). Accurate ranking of influential spreaders in networks based on dynamically asymmetric link weights. Physical Review E, 96(2), 022323.
centrality_coreness,
centrality_weighted_kshell, centrality.
centrality_s_shell(regulation_net)centrality_s_shell(regulation_net)
SALSA (Lempel and Moran 2000) ranks authorities by a random walk that alternates between following an edge backward and forward. The authority score of a node is its entry in the stationary distribution of the chain
where and are the row-normalized and column-normalized
adjacency matrices.
centrality_salsa(x, ...)centrality_salsa(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure needs a directed network. On undirected input every score is
NA with a cograph_undefined_measure warning. Edge weights are
ignored. The scores are scaled so that the largest is 1, and a node
without incoming edges scores 0.
A named numeric vector with one score per node, in input node order.
Lempel, R., & Moran, S. (2000). The stochastic approach for link-structure analysis (SALSA) and the TKC effect. Computer Networks, 33(1-6), 387-401. doi:10.1016/S1389-1286(00)00034-7.
centrality_authority,
centrality_pagerank, centrality.
centrality_salsa(regulation_net)centrality_salsa(regulation_net)
Semi-local centrality (Chen et al. 2012) sums, over the neighbors
of a node and the neighbors of each , the number
of nodes within two steps of :
centrality_semilocal(x, mode = "all", ...)centrality_semilocal(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects the neighbors, and with
mode = "all" on a directed network a reciprocated tie counts twice.
An isolated node scores 0. On undirected networks the values equal
centiserve::semilocal().
A named numeric vector with one score per node, in input node order.
Chen, D., Lu, L., Shang, M.-S., Zhang, Y.-C., & Zhou, T. (2012). Identifying influential nodes in complex networks. Physica A, 391(4), 1777-1787. doi:10.1016/j.physa.2011.09.017.
centrality_laplacian,
centrality_degree, centrality.
centrality_semilocal(regulation_net)centrality_semilocal(regulation_net)
Shapley value centrality (Michalak et al. 2013) is the Shapley value of
each node in a coalition game whose worth counts the nodes a
coalition covers. Each game has an exact closed form. In game 1 a
coalition covers its members and their neighbors, and
In game 2 a coalition covers its members and the nodes with at least
neighbors in it. In game 3 it covers the nodes within
shapley_cutoff hops of it, and is replaced by the set
of nodes within that distance.
centrality_shapley_game1(x, ...) centrality_shapley_game2(x, shapley_k = 2, ...) centrality_shapley_game3(x, shapley_cutoff = 2, ...)centrality_shapley_game1(x, ...) centrality_shapley_game2(x, shapley_k = 2, ...) centrality_shapley_game3(x, shapley_cutoff = 2, ...)
x |
Network input accepted by |
... |
Further arguments to |
shapley_k |
Neighbor threshold |
shapley_cutoff |
Hop cutoff for game 3 (default 2). |
The values of every game sum to the number of nodes. Game 2 with
and game 3 with cutoff 1 equal game 1. Degrees exclude
self-loops, and edge weights are ignored. On a directed network coverage
runs along out-edges and the denominators use in-degrees, the extension
the source states. Distances in game 3 are hop counts.
A named numeric vector with one Shapley value per node, in input node order.
Michalak, T. P., Aadithya, K. V., Szczepanski, P. L., Ravindran, B., & Jennings, N. R. (2013). Efficient computation of the Shapley value for game-theoretic network centrality. Journal of Artificial Intelligence Research, 46, 607-650.
centrality_degree, centrality.
centrality_shapley_game1(regulation_net) centrality_shapley_game2(regulation_net) centrality_shapley_game3(regulation_net)centrality_shapley_game1(regulation_net) centrality_shapley_game2(regulation_net) centrality_shapley_game3(regulation_net)
SpectralRank (Xu et al. 2019) is the positive eigenvector of the largest eigenvalue of the adjacency matrix augmented by a ground node, which is linked in both directions to every node with unit weight:
The diagonal prior is zero for ordinary SpectralRank, and a
nonnegative prior gives the weighted SpectralRank family of the paper.
centrality_spectralrank(x, sr_prior = 0, ...)centrality_spectralrank(x, sr_prior = 0, ...)
x |
Network input accepted by |
sr_prior |
Diagonal prior |
... |
Further arguments to |
The eigenvector is divided by its maximum over all nodes including the
ground node, which is then dropped, so the largest returned score can be
below one. normalized = TRUE further divides by the maximum over
the original nodes. An arc from to contributes the
score of to . Edge weights must be finite and
nonnegative, weighted = FALSE gives every edge weight one, and
loops are removed. Every node, isolated nodes included, scores
positive, and without edges or priors each of nodes scores
. The update line of Algorithm 1 in the paper
omits , and the implementation follows section III-A2 with
. An invalid sr_prior or an
unresolved eigenvector raises an error.
A named numeric vector with one score per node, in input node order.
Xu, S., Wang, P., Zhang, C.-X. and Lu, J. (2019). Spectral Learning Algorithm Reveals Propagation Capability of Complex Networks. IEEE Transactions on Cybernetics, 49(12), 4253-4261. doi:10.1109/TCYB.2018.2861568.
centrality_eigenvector,
centrality_leaderrank, centrality.
centrality_spectralrank(regulation_net)centrality_spectralrank(regulation_net)
Strength (Barrat et al. 2004) is the sum of the weights of the edges
incident to a node, the weighted counterpart of degree. With
mode = "in" it sums incoming weights and with mode = "out"
outgoing weights. centrality_instrength() and
centrality_outstrength() are these two forms.
centrality_strength(x, mode = "all", ...) centrality_instrength(x, ...) centrality_outstrength(x, ...)centrality_strength(x, mode = "all", ...) centrality_instrength(x, ...) centrality_outstrength(x, ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
The stored weights are summed, and weighted = FALSE gives every
edge weight one, so the scores equal centrality_degree. A
self-loop
counts twice on an undirected network and under mode = "all", and
once under "in" or "out"; loops = FALSE drops it.
Negative weights are summed with their sign. normalized = TRUE
divides the scores by their maximum.
A named numeric vector with one score per node, in input node order.
Barrat, A., Barthelemy, M., Pastor-Satorras, R., & Vespignani, A. (2004). The architecture of complex weighted networks. Proceedings of the National Academy of Sciences, 101(11), 3747-3752. doi:10.1073/pnas.0400087101.
centrality_degree, centrality.
centrality_strength(regulation_net)centrality_strength(regulation_net)
Stress centrality (Shimbel 1953) counts the shortest paths between other pairs of nodes that pass through a node:
where is the number of shortest paths
from to through . Betweenness divides each count by
the number of shortest paths between the pair; stress keeps the counts.
centrality_stress(x, ...)centrality_stress(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are read as distances. weighted = FALSE uses hop
counts, and invert_weights = TRUE converts a weight to the
distance . On a directed network the paths
follow edge direction, and on an undirected network each pair is counted
once. The values equal sna::stresscent().
A named numeric vector with one score per node, in input node order.
Shimbel, A. (1953). Structural parameters of communication networks. The Bulletin of Mathematical Biophysics, 15(4), 501-507. doi:10.1007/BF02476438.
centrality_betweenness,
centrality_load, centrality.
centrality_stress(regulation_net)centrality_stress(regulation_net)
Subgraph centrality (Estrada and Rodriguez-Velazquez 2005) counts the
closed walks that start and end at a node, weighting a walk of length
by :
centrality_subgraph(x, ...)centrality_subgraph(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
is the binary adjacency matrix without self-loops, so edge weights
are ignored. On a directed network is replaced by
, so a reciprocated pair has entry 2; the values
then equal igraph::subgraph_centrality(). An empty network raises
an error.
A named numeric vector with one score per node, in input node order.
Estrada, E., & Rodriguez-Velazquez, J. A. (2005). Subgraph centrality in complex networks. Physical Review E, 71(5), 056103. doi:10.1103/PhysRevE.71.056103.
centrality_communicability,
centrality_eigenvector, centrality.
centrality_subgraph(regulation_net)centrality_subgraph(regulation_net)
The topological coefficient (Stelzl et al. 2005) measures how far a node shares neighbors with the nodes it is linked to through a common neighbor:
where is the set of nodes that share at least one neighbor with
, is the number of shared neighbors plus one when
and are linked, and is the degree.
centrality_topological_coefficient(x, ...)centrality_topological_coefficient(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights and direction are ignored. A node that shares no neighbor
with any other node scores 0, as does an isolated node. On undirected
networks the values equal centiserve::topocoefficient().
A named numeric vector with one score per node, in input node order.
Stelzl, U., Worm, U., Lalowski, M., Haenig, C., Brembeck, F. H., Goehler, H., et al. (2005). A human protein-protein interaction network: A resource for annotating the proteome. Cell, 122(6), 957-968. doi:10.1016/j.cell.2005.08.029.
centrality_transitivity,
centrality_lac, centrality.
centrality_topological_coefficient(regulation_net)centrality_topological_coefficient(regulation_net)
Local transitivity, the clustering coefficient of Watts and Strogatz (1998), is the share of pairs of a node's neighbors that are themselves linked:
where is the number of triangles through node and
its degree.
centrality_transitivity(x, transitivity_type = "local", isolates = "nan", ...)centrality_transitivity(x, transitivity_type = "local", isolates = "nan", ...)
x |
Network input accepted by |
transitivity_type |
One of |
isolates |
Value for nodes with fewer than two ties: |
... |
Further arguments to |
Triangles and degrees are counted on the undirected skeleton, so a
reciprocated tie counts once, and edge weights are ignored. The values
equal igraph::transitivity(type = "local") on directed and
undirected networks. "localundirected" gives the same values as
"local", as in igraph. "global" and "undirected"
return the network-level ratio of closed to connected triples for every
node. "barrat" and "weighted" compute the weighted
coefficient of Barrat et al. (2004) and raise a
cograph_directed_unsupported error on directed input.
"onnela" computes the weighted clustering coefficient of Zhang and
Horvath (2005),
on with strengths . This is the
value tna::centralities() reports as Clustering, and it is the
default for tna input. The option keeps the name "onnela" used by
tna, but the formula multiplies the raw weights of a triangle and differs
from the geometric-mean form of Onnela et al. (2005). Under the local and
Barrat types a node with fewer than two neighbors is NaN, or 0
with isolates = "zero".
A named numeric vector with one score per node, in input node order.
Watts, D. J., & Strogatz, S. H. (1998). Collective dynamics of 'small-world' networks. Nature, 393(6684), 440-442. doi:10.1038/30918.
Barrat, A., Barthelemy, M., Pastor-Satorras, R., & Vespignani, A. (2004). The architecture of complex weighted networks. Proceedings of the National Academy of Sciences, 101(11), 3747-3752. doi:10.1073/pnas.0400087101.
Zhang, B., & Horvath, S. (2005). A general framework for weighted gene co-expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1), Article 17. doi:10.2202/1544-6115.1128.
Onnela, J.-P., Saramaki, J., Kertesz, J., & Kaski, K. (2005). Intensity and coherence of motifs in weighted complex networks. Physical Review E, 71(6), 065103. doi:10.1103/PhysRevE.71.065103.
centrality_clusterrank,
centrality_topological_coefficient,
centrality.
centrality_transitivity(regulation_net)centrality_transitivity(regulation_net)
The truss number of a node (Malliaros et al. 2016) is the largest truss
number of an incident edge, where a k-truss requires every edge to lie
in at least triangles of the subgraph. Mixed-degree
decomposition (Zeng and Zhang 2013) peels nodes by residual degree plus
mdd_lambda times exhausted degree. The bridging coefficient
(Hwang et al. 2008) is
.
The Godfather index (Jackson 2020) counts the unordered pairs of
neighbors with no edge between them, and the support (Jackson 2020)
counts the neighbors that share at least one common neighbor with the
node.
centrality_truss(x, ...) centrality_mdd(x, mdd_lambda = 0.7, ...) centrality_bridging_coefficient(x, ...) centrality_godfather(x, ...) centrality_support(x, ...)centrality_truss(x, ...) centrality_mdd(x, mdd_lambda = 0.7, ...) centrality_bridging_coefficient(x, ...) centrality_godfather(x, ...) centrality_support(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
mdd_lambda |
Weight of the exhausted degree, between 0 and 1. Default 0.7, the value of the worked example of Zeng and Zhang (2013). A value outside that range raises an error. |
All five measures use the simple undirected skeleton, so direction,
weights, loops and parallel edges are ignored. Isolated nodes score 0.
An edge outside every triangle has truss number 2, and a node of a
complete graph on nodes has truss number , as in
NetworkX. Sources that label trusses by the triangle threshold report
values two smaller. mdd_lambda = 0 gives the k-core number and
mdd_lambda = 1 gives the degree. The bridging coefficient is the
factor that bridging centrality multiplies with betweenness. LocalRank
(Chen et al. 2012), listed in the Centrality Zoo, is
centrality_semilocal.
A named numeric vector with one score per node, in input node order.
Malliaros, F. D., Rossi, M. E. G., & Vazirgiannis, M. (2016). Locating influential nodes in complex networks. Scientific Reports, 6, 19307. doi:10.1038/srep19307.
Zeng, A., & Zhang, C. J. (2013). Ranking spreaders by decomposing complex networks. Physics Letters A, 377, 1031-1035. doi:10.1016/j.physleta.2013.02.039.
Hwang, W., Kim, T., Ramanathan, M., & Zhang, A. (2008). Bridging centrality: graph mining from element level to group level. KDD '08, 336-344. doi:10.1145/1401890.1401934.
Jackson, M. O. (2020). A typology of social capital and associated network measures. Social Choice and Welfare, 54, 311-336. doi:10.1007/s00355-019-01189-3.
Chen, D., Lu, L., Shang, M. S., Zhang, Y. C., & Zhou, T. (2012). Identifying influential nodes in complex networks. Physica A, 391, 1777-1787. doi:10.1016/j.physa.2011.09.017.
centrality_coreness,
centrality_bridging, centrality.
centrality_truss(regulation_net) centrality_mdd(regulation_net) centrality_bridging_coefficient(regulation_net) centrality_godfather(regulation_net) centrality_support(regulation_net)centrality_truss(regulation_net) centrality_mdd(regulation_net) centrality_bridging_coefficient(regulation_net) centrality_godfather(regulation_net) centrality_support(regulation_net)
Trust-PageRank (Sheng et al. 2020) is a damped PageRank in which a node
passes its score to a neighbor in proportion to a trust value. The trust
value mixes the SimRank similarity of the two nodes with a degree
ratio:
centrality_trust_pagerank(x, ...)centrality_trust_pagerank(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the
network, so direction, weights, loops and parallel edges are ignored. The
similarity recursion runs over adjacent pairs and is anchored by
triangles. Every node of a component that has edges but no triangle is
returned as NA with a cograph_undefined_measure warning, and
an isolated node scores . Both the similarity and the
score iterations stop on a relative tolerance, and an iteration that
reaches tpr_max_iter raises cograph_no_converge. The
Centrality Zoo attributes the measure to Sheng et al., Physica A
541:123262, which defines a different index. The measure is defined in
the Algorithms paper cited below.
A named numeric vector with one score per node, in input node order. The scores sum to one on a network with no isolated node and no undefined component.
Sheng, J., Zhu, J., Wang, Y., Wang, B. and Hou, Z. (2020). Identifying Influential Nodes of Complex Networks Based on Trust-Value. Algorithms, 13(11), 280. doi:10.3390/a13110280.
centrality_pagerank, centrality.
centrality_trust_pagerank(regulation_net)centrality_trust_pagerank(regulation_net)
Two-way random walk betweenness (Curado et al. 2022) counts how often a
node lies on the strongest two-way route between a pair. For every
unordered pair the two-step transfer
is combined into
, the
diagonal is dropped, and the largest entry credits one count to
and one to . The score of a node is its total count over all
pairs.
centrality_two_way_rw(x, ...)centrality_two_way_rw(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are used, and direction and self-loops are ignored. Ties in
the maximum go to the first entry in row-major order. Nodes that never
lie on a winning two-way route score 0. The source divides the transfer
by , where a random-walk probability would divide
by . The formula is implemented as printed.
A named numeric vector with one count per node, in input node order.
Curado, M., Rodriguez, R., Tortosa, L., & Vicent, J. F. (2022). A new centrality measure in dense networks based on two-way random walk betweenness. Applied Mathematics and Computation, 412, 126560.
centrality_current_flow_betweenness,
centrality_betweenness, centrality.
centrality_two_way_rw(regulation_net)centrality_two_way_rw(regulation_net)
Volume centrality (Wehmuth and Ziviani 2011, 2013) is the sum of the
degrees of all nodes within volume_radius hops of a node, the
node itself included. Degrees are those of the whole network, so edges
that leave the neighborhood also count.
centrality_volume(x, volume_radius = 2, ...)centrality_volume(x, volume_radius = 2, ...)
x |
Network input accepted by |
volume_radius |
Hop radius: a nonnegative integer or |
... |
Further arguments to |
The measure uses the simple undirected skeleton, so direction, weights, loops and parallel edges are ignored. Isolated nodes score 0. Radius 0 gives the degree, and an infinite radius gives twice the number of edges in the node's component. A radius that is negative or not a whole number raises an error.
A named numeric vector with one score per node, in input node order.
Wehmuth, K., & Ziviani, A. (2011). Distributed Assessment of Network Centrality. arXiv:1108.1067.
Wehmuth, K., & Ziviani, A. (2013). DACCER: Distributed Assessment of the Closeness CEntrality Ranking in complex networks. Computer Networks, 57, 2536-2548. doi:10.1016/j.comnet.2013.05.001.
centrality_kreach,
centrality_degree, centrality.
centrality_volume(regulation_net, volume_radius = 1)centrality_volume(regulation_net, volume_radius = 1)
VoteRank (Zhang et al. 2016) elects spreaders one at a time. Every node
votes for its neighbors with a voting ability that starts at 1, the node
with the most votes is elected, and each neighbor of the elected node
loses of its ability, where
is the mean degree. A node elected in round
of rounds scores , so
the first node elected scores 1.
centrality_voterank(x, ...)centrality_voterank(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
Edge weights are ignored. On a directed network a node receives the votes
of its in-neighbors, the election reduces the ability of the out-neighbors
of the elected node, and the mean degree counts in-ties and out-ties.
Every node is elected in turn, so on nodes the scores are
. A tie in votes goes to the
node listed first.
A named numeric vector with one score per node, in input node order.
Zhang, J.-X., Chen, D.-B., Dong, Q., & Zhao, Z.-D. (2016). Identifying a set of influential spreaders in complex networks. Scientific Reports, 6, 27823. doi:10.1038/srep27823.
centrality_ncvoterank,
centrality_wvoterank, centrality.
centrality_voterank(regulation_net)centrality_voterank(regulation_net)
Three shell and path counts. The weighted k-shell (Garas, Schweitzer and Havlin 2012) runs the k-shell decomposition on the generalized degree
with strength after the weight normalization of the
source. Renewed coreness (Liu, Tang, Zhou and Do 2015) gives each link
the diffusion importance
,
removes the links below renewed_threshold, and returns the k-core
number of the residual graph. Geodesic k-path centrality (Borgatti and
Everett 2006) counts the shortest paths of length at most kpath_k
that start at the node, with multiplicity.
centrality_weighted_kshell(x, wks_alpha = 1, wks_beta = 1, ...) centrality_renewed_coreness(x, renewed_threshold = 2, ...) centrality_geodesic_kpath(x, mode = "all", kpath_k = 3, ...)centrality_weighted_kshell(x, wks_alpha = 1, wks_beta = 1, ...) centrality_renewed_coreness(x, renewed_threshold = 2, ...) centrality_geodesic_kpath(x, mode = "all", kpath_k = 3, ...)
x |
Network input accepted by |
wks_alpha, wks_beta
|
Exponents of degree and strength in the weighted k-shell (default 1 and 1). |
... |
Further arguments to |
renewed_threshold |
Diffusion-importance threshold for renewed coreness (default 2). |
mode |
For directed networks: |
kpath_k |
Maximum path length for geodesic k-path (default 3). |
The weighted k-shell uses edge weights, and with unit weights it equals
the k-core number. Isolated nodes score 0. Renewed coreness ignores
weights, and a clique with no outside links scores 0. Both ignore
direction. Geodesic k-path ignores weights and follows mode. The
Centrality Zoo transcribes the diffusion importance with open
neighborhoods, which is off by one, and the closed neighborhoods of the
source are used here. centiserve::geokpath counts the nodes within
hops, which is the vertex-disjoint variant of Borgatti and
Everett.
A named numeric vector with one score per node, in input node order. The weighted k-shell and renewed coreness are integer vectors.
Garas, A., Schweitzer, F., & Havlin, S. (2012). A k-shell decomposition method for weighted networks. New Journal of Physics, 14, 083030.
Liu, Y., Tang, M., Zhou, T., & Do, Y. (2015). Improving the accuracy of the k-shell method by removing redundant links: From a perspective of spreading dynamics. Scientific Reports, 5, 13172. doi:10.1038/srep13172.
Borgatti, S. P., & Everett, M. G. (2006). A graph-theoretic perspective on centrality. Social Networks, 28(4), 466-484.
centrality_coreness, centrality_s_shell,
centrality.
centrality_weighted_kshell(regulation_net) centrality_renewed_coreness(regulation_net) centrality_geodesic_kpath(regulation_net)centrality_weighted_kshell(regulation_net) centrality_renewed_coreness(regulation_net) centrality_geodesic_kpath(regulation_net)
Weighted LeaderRank (Li et al. 2014) adds a ground node that is
linked in both directions to every node. Each original arc and each arc
into the ground has weight 1, and the arc from the ground to node
has weight , where
is the in-degree before the ground is added. The
score is the stationary resource of the random walk on the row-normalized
weights, started with one unit on every node and the ground included.
centrality_weighted_leaderrank(x, wlr_alpha = 1, ...)centrality_weighted_leaderrank(x, wlr_alpha = 1, ...)
x |
Network input accepted by |
wlr_alpha |
Exponent |
... |
Further arguments to |
Arcs keep their direction, and an undirected edge counts as two opposite
arcs. Edge weights, loops and parallel arcs are ignored, and mode
has no effect. The returned scores omit the ground, so they sum to less
than . With every ground arc
has weight 1. With a positive a node with in-degree
0 scores 0, and when every in-degree is 0 all scores are NaN
with a cograph_undefined_measure warning. A negative
requires a positive in-degree at every node and
raises a cograph_bad_parameter error otherwise, as does a
wlr_alpha that is not a finite number.
A named numeric vector with one score per node, in input node order.
Li, Q., Zhou, T., Lu, L., & Chen, D. (2014). Identifying influential spreaders by weighted LeaderRank. Physica A, 404, 47-55. doi:10.1016/j.physa.2014.02.041.
centrality_leaderrank,
centrality_adaptive_leaderrank, centrality.
centrality_weighted_leaderrank(regulation_net)centrality_weighted_leaderrank(regulation_net)
The Wiener centrality of a node is the sum of its shortest-path distances to the nodes it reaches:
High values mark peripheral nodes. On a connected undirected network half the sum of the scores is the Wiener index of the network (Wiener 1947).
centrality_wiener(x, mode = "all", ...)centrality_wiener(x, mode = "all", ...)
x |
Network input accepted by |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are read as distances. weighted = FALSE uses hop
counts, and invert_weights = TRUE converts a weight to the
distance . mode = "all" treats edges as
undirected, "out" uses distances from the node and "in"
distances to it. Unreachable nodes add nothing, so on a disconnected
network a node in a small component also scores low.
A named numeric vector with one score per node, in input node order.
Wiener, H. (1947). Structural determination of paraffin boiling points. Journal of the American Chemical Society, 69(1), 17-20. doi:10.1021/ja01193a005.
centrality_closeness,
centrality_average_distance, centrality.
centrality_wiener(regulation_net)centrality_wiener(regulation_net)
The within-module degree z-score (Guimera and Nunes Amaral 2005) standardizes the number of ties a node has inside its own community against the other members of that community:
where counts the ties of to its community
. High values mark hubs within their community.
centrality_within_module_z(x, membership = NULL, mode = "all", ...)centrality_within_module_z(x, membership = NULL, mode = "all", ...)
x |
Network input accepted by |
membership |
Community of each node, a vector with one entry per
node in input node order (default |
mode |
Direction for directed networks: |
... |
Further arguments to |
Edge weights are ignored. mode selects the ties counted, and with
mode = "all" on a directed network a reciprocated tie counts twice.
The standard deviation is the sample value. A community with one member,
or whose members all have the same within-community degree, gives
NaN. Without membership every score is NA with a
warning of classes cograph_bad_membership and
cograph_undefined_measure, and a membership of the wrong
length raises a cograph_bad_membership error. On undirected
networks the values equal
brainGraph::within_module_deg_z_score().
A named numeric vector with one score per node, in input node order.
Guimera, R., & Nunes Amaral, L. A. (2005). Functional cartography of complex metabolic networks. Nature, 433(7028), 895-900. doi:10.1038/nature03288.
centrality_participation,
centrality_gateway, centrality.
centrality_within_module_z(regulation_net, membership = rep(1:2, each = 5))centrality_within_module_z(regulation_net, membership = rep(1:2, each = 5))
Three spreader-selection procedures in the VoteRank family that elect
one node per round. WVoteRank (Sun et al. 2019) scores a node by
and lowers the ability of the neighbors of a winner by
, the inverse of the average strength.
EnRenew (Guo et al. 2020) elects the largest neighbor entropy
,
,
and scales the entropy terms within enrenew_depth steps by
.
VoteRank++ (Liu et al. 2021) starts from ability
, splits votes in
proportion to degree, and multiplies abilities by
one step from a winner and by two
steps away.
centrality_wvoterank(x, ...) centrality_enrenew(x, enrenew_depth = 2, ...) centrality_voterank_plus(x, voterank_lambda = 0.1, ...)centrality_wvoterank(x, ...) centrality_enrenew(x, enrenew_depth = 2, ...) centrality_voterank_plus(x, voterank_lambda = 0.1, ...)
x |
Network input accepted by |
... |
Further arguments to |
enrenew_depth |
Renewal radius |
voterank_lambda |
Suppression factor |
Elections continue until every node is placed. The first elected scores 1
and the last , so scores lie in , and
ties go to the lowest node index. Direction and self-loops are ignored.
WVoteRank uses edge weights, and with unit weights it is VoteRank with a
square-root score. The other two ignore weights. The renewal factor of
EnRenew is negative when . EnRenew
follows the article where the released code of the authors differs from
it. VoteRank++ follows the released code of the authors, including the
exclusion of elected nodes from the vote-share denominator.
A named numeric vector with one score per node, in input node order.
Sun, H.-L., Chen, D.-B., He, J.-L., & Ch'ng, E. (2019). A voting approach to uncover multiple influential spreaders on weighted networks. Physica A, 519, 303-312.
Guo, C., Yang, L., Guo, X., Pan, J., & Chen, X. (2020). Influential nodes identification in complex networks via information entropy. Entropy, 22(2), 242.
Liu, P., Li, L., Fang, S., & Yao, Y. (2021). Identifying influential nodes in social networks: A voting approach. Chaos, Solitons & Fractals, 152, 111309.
centrality_voterank,
centrality_ncvoterank, centrality.
centrality_wvoterank(regulation_net) centrality_enrenew(regulation_net) centrality_voterank_plus(regulation_net)centrality_wvoterank(regulation_net) centrality_enrenew(regulation_net) centrality_voterank_plus(regulation_net)
X-degree (Torres et al. 2021, equation 3.15) counts the oriented
nonbacktracking walks of four edges whose middle node is . It
depends only on the degrees of the neighbors of
:
centrality_x_degree(x, ...)centrality_x_degree(x, ...)
x |
Network input accepted by |
... |
Further arguments to |
The measure is computed on the simple undirected skeleton of the network, so direction, weights, loops and parallel edges are ignored. Isolated nodes and leaves score zero, and every node of a star scores zero. Components are scored independently. The function computes the score on the supplied network. The iterative node-removal immunization procedure of the paper is a separate algorithm.
A named numeric vector with one score per node, in input node order.
Torres, L., Chan, K. S., Tong, H., & Eliassi-Rad, T. (2021). Nonbacktracking Eigenvalues under Node Removal: X-Centrality and Targeted Immunization. SIAM Journal on Mathematics of Data Science, 3(2), 656-675. doi:10.1137/20M1352132.
centrality_degree,
centrality_dynamical_importance, centrality.
centrality_x_degree(regulation_net)centrality_x_degree(regulation_net)
Computes Freeman's centralization for degree, betweenness, closeness, or eigenvector centrality.
centralization( x, measure = c("degree", "betweenness", "closeness", "eigenvector"), directed = NULL, mode = "all", ... )centralization( x, measure = c("degree", "betweenness", "closeness", "eigenvector"), directed = NULL, mode = "all", ... )
x |
Network input (matrix, edge-list data frame, igraph, network, cograph_network, tna object). |
measure |
One of |
directed |
Logical or |
mode |
For directed networks: |
... |
Ignored; accepted for call compatibility with the other centrality verbs. |
A weighted input carries its weights into betweenness, closeness and eigenvector centrality; degree centralization ignores them.
A single number. It is the summed gap between the most central node
and every other node, divided by a theoretical maximum. For degree,
betweenness and closeness the maximum is the value of an unweighted
star, so unweighted input gives 0 for a perfectly even network and 1 for
an undirected star. For eigenvector centrality, whose scores are scaled to
a maximum of 1, the divisor is , and a star gives a value
below 1. Weighted closeness
scales with the inverse of the edge weights, so its centralization can
exceed 1. Nodes whose score is NA or NaN are dropped from
the sum. The value is 0 when the network has two or fewer nodes.
cograph::centralization(regulation_net, measure = "degree")cograph::centralization(regulation_net, measure = "degree")
Computes per-cluster and global quality metrics for network partitioning. Supports both binary and weighted networks.
cluster_quality(x, clusters, weighted = TRUE, directed = TRUE) cqual(x, clusters, weighted = TRUE, directed = TRUE)cluster_quality(x, clusters, weighted = TRUE, directed = TRUE) cqual(x, clusters, weighted = TRUE, directed = TRUE)
x |
Adjacency matrix (numeric) |
clusters |
Cluster specification (named list, data frame, or membership
vector; see |
weighted |
Logical; if TRUE (default), use edge weights; if FALSE, binarize the matrix first |
directed |
Logical; if TRUE (default), treat as directed network |
A cluster_quality object (a list) with:
per_cluster |
Data frame, one row per cluster, with columns
|
global |
List with |
See cluster_quality.
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) cluster_quality(regulation_net, clusters = clusters)clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) cluster_quality(regulation_net, clusters = clusters)
Compares observed modularity against a null model distribution to assess whether the detected community structure is statistically significant.
cluster_significance( x, communities, n_random = 100, method = c("configuration", "gnm"), null = c("detect", "fixed"), seed = NULL ) csig( x, communities, n_random = 100, method = c("configuration", "gnm"), null = c("detect", "fixed"), seed = NULL )cluster_significance( x, communities, n_random = 100, method = c("configuration", "gnm"), null = c("detect", "fixed"), seed = NULL ) csig( x, communities, n_random = 100, method = c("configuration", "gnm"), null = c("detect", "fixed"), seed = NULL )
x |
Network input: adjacency matrix, igraph object, or cograph_network. |
communities |
A communities object (from |
n_random |
Number of random networks to generate for the null distribution. Default 100. |
method |
Null model type:
|
null |
Which null question to answer. Default
|
seed |
Random seed for reproducibility. Default NULL. |
The function generates n_random random networks from the null model.
With null = "detect", community detection (Louvain, or fast greedy
when Louvain fails) is run on each null network and its modularity is
recorded. A low p-value then indicates that the observed partition is
stronger than the partitions detection recovers on random networks. With
null = "fixed", the supplied membership is evaluated on each null
network. A low p-value then indicates that the partition explains more
structure in the observed network than in random networks, independently
of any detection algorithm.
The observed modularity is computed with the edge weights of x.
When x is weighted, each null network receives the observed edge
weights, randomly reassigned to its edges, so the observed and null
modularity are on the same scale.
A cograph_cluster_significance object with:
Modularity of the input communities
Mean modularity of random networks
Standard deviation of null modularity
Standardized score (observed - null_mean) / null_sd,
or NA when null_sd is zero
One-sided upper-tail p-value of z_score under
the standard normal distribution; NA when null_sd is
zero
Vector of modularity values from null distribution
Null model method used
Which null question was asked ("detect" or "fixed")
Number of random networks generated
Printing the result shows the null model, the observed and null modularity,
the z-score and the p-value. plot() on the result plots a histogram
of the null modularity values with the observed value marked.
Reichardt, J., & Bornholdt, S. (2006). Statistical mechanics of community detection. Physical Review E, 74, 016110.
comm <- communities(regulation_net, method = "walktrap") cluster_significance(regulation_net, comm, n_random = 20, seed = 1)comm <- communities(regulation_net, method = "walktrap") cluster_significance(regulation_net, comm, n_random = 20, seed = 1)
The main entry point for cograph. Accepts adjacency matrices, edge lists, igraph, statnet network, qgraph, or tna objects and creates a visualization-ready network object.
cograph( input, layout = NULL, directed = NULL, nodes = NULL, seed = 42, simplify = FALSE, ... )cograph( input, layout = NULL, directed = NULL, nodes = NULL, seed = 42, simplify = FALSE, ... )
input |
Network input. Can be:
|
layout |
Layout algorithm name such as "circle", "oval", "spring",
"groups", "grid", "random", "star", "bipartite" or "gephi" (see
|
directed |
Logical. Force directed interpretation. NULL for auto-detect. |
nodes |
Node metadata. Can be NULL or a data frame with node attributes.
If data frame has a |
seed |
Random seed for deterministic layouts. Default 42. Set NULL for random. |
simplify |
Logical or character. Used for tna input only. If FALSE (default), every transition from tna sequence data is a separate edge. If TRUE or a string ("sum", "mean", "max", "min"), duplicate edges are aggregated, and TRUE uses "sum". |
... |
Additional arguments passed to the layout function. |
A cograph_network object. It is a list with the elements
nodes, edges, directed, weights,
data, meta and node_groups.
splot for base R graphics rendering,
soplot for grid graphics rendering,
sn_nodes for node customization,
sn_edges for edge customization,
sn_layout for changing layouts,
sn_theme for visual themes,
sn_palette for color palettes,
from_qgraph and from_tna for converting external objects
cograph(regulation_net) |> splot(layout = "circle")cograph(regulation_net) |> splot(layout = "circle")
Class for managing layout algorithms and computing node positions.
A CographLayout R6 object.
new()
Create a new CographLayout object.
CographLayout$new(type = "circle", ...)
typeLayout name. One of the names returned by
list_layouts(), or "custom" together with a coords argument.
...Additional parameters stored and passed to the layout function.
A new CographLayout object.
compute()
Compute layout coordinates for a network.
CographLayout$compute(network, ...)
networkA CographNetwork or cograph_network object.
...Additional parameters passed to the layout function. They
override parameters given to $new().
A data frame with columns x and y, one row per node, rescaled
by $normalize_coords().
normalize_coords()
Rescale coordinates into the unit square. Both axes are
scaled by the same factor, so the larger spread spans
[padding, 1 - padding] and the layout is centered at 0.5.
CographLayout$normalize_coords(coords, padding = 0.1)
coordsMatrix or data frame. Columns x and y are used, or the
first two columns when these names are absent.
paddingNumeric. Margin left on each side of the larger spread.
A data frame with rescaled x and y columns.
get_type()
Get layout type.
CographLayout$get_type()
A character string.
get_params()
Get layout parameters.
CographLayout$get_params()
A list of the parameters given to $new().
print()
Print layout summary.
CographLayout$print()
The object itself, invisibly.
clone()
The objects of this class are cloneable with this method.
CographLayout$clone(deep = FALSE)
deepWhether to make a deep clone.
layout <- CographLayout$new("circle") layout$compute(CographNetwork$new(regulation_net))layout <- CographLayout$new("circle") layout$compute(CographNetwork$new(regulation_net))
Core class representing a network for visualization. Stores nodes, edges, layout coordinates, and aesthetic mappings.
A CographNetwork R6 object.
n_nodesNumber of nodes in the network.
n_edgesNumber of edges in the network.
is_directedWhether the network is directed.
has_weightsTRUE when any edge weight differs from 1.
node_labelsVector of node labels, taken from the labels column
of the node table when present and from label otherwise.
new()
Create a new CographNetwork object.
CographNetwork$new( input = NULL, directed = NULL, nodes = NULL, simplify = FALSE )
inputNetwork input, such as a matrix, edge list, igraph,
statnet network, qgraph or tna object. NULL creates an empty object.
directedLogical. Forces a directed or undirected interpretation.
NULL detects it from the input.
nodesNULL or a data frame of node attributes. Its rows are
matched to the node labels by a name, label or id column, tried in
that order, and the remaining columns are added to the node table. When
no column matches and the row count equals the number of nodes, the
columns are added in row order. A labels column supplies the display
labels returned by $node_labels.
simplifyLogical or character. If FALSE (default), every transition from tna sequence data is a separate edge. If TRUE or a string ("sum", "mean", "max", "min"), duplicate transitions are aggregated. Other inputs are not affected.
A new CographNetwork object.
clone_network()
Create a copy with the same nodes, edges, weights, layout, aesthetics, theme, layout information and plot parameters.
CographNetwork$clone_network()
A new CographNetwork object.
set_nodes()
Set nodes data frame.
CographNetwork$set_nodes(nodes)
nodesData frame with node information.
The object itself, invisibly.
set_edges()
Set edges data frame.
CographNetwork$set_edges(edges)
edgesData frame with edge information.
The object itself, invisibly.
set_directed()
Set directed flag.
CographNetwork$set_directed(directed)
directedLogical.
The object itself, invisibly.
set_weights()
Set edge weights.
CographNetwork$set_weights(weights)
weightsNumeric vector of edge weights, one per edge.
The object itself, invisibly.
set_layout_coords()
Set layout coordinates.
CographNetwork$set_layout_coords(coords)
coordsMatrix or data frame with at least two columns and one row
per node. The first two columns are renamed x and y and are also
written to the node table. NULL leaves the layout unchanged.
The object itself, invisibly.
set_node_aes()
Set node aesthetics. The list is merged into the current node aesthetics.
CographNetwork$set_node_aes(aes)
aesNamed list of aesthetic parameters.
The object itself, invisibly.
set_edge_aes()
Set edge aesthetics. The list is merged into the current edge aesthetics.
CographNetwork$set_edge_aes(aes)
aesNamed list of aesthetic parameters.
The object itself, invisibly.
set_theme()
Set theme.
CographNetwork$set_theme(theme)
themeCographTheme object or theme name.
The object itself, invisibly.
get_nodes()
Get nodes data frame.
CographNetwork$get_nodes()
Data frame with node information.
get_edges()
Get edges data frame.
CographNetwork$get_edges()
Data frame with edge information.
get_layout()
Get layout coordinates.
CographNetwork$get_layout()
A data frame with x and y columns, or NULL when no layout
is set.
get_node_aes()
Get node aesthetics.
CographNetwork$get_node_aes()
List of node aesthetic parameters.
get_edge_aes()
Get edge aesthetics.
CographNetwork$get_edge_aes()
List of edge aesthetic parameters.
get_theme()
Get theme.
CographNetwork$get_theme()
The stored theme (a CographTheme object or theme name), or
NULL.
set_layout_info()
Set layout info.
CographNetwork$set_layout_info(info)
infoList with layout information (name, seed, etc.).
The object itself, invisibly.
get_layout_info()
Get layout info.
CographNetwork$get_layout_info()
List with layout information.
set_plot_params()
Set plot parameters.
CographNetwork$set_plot_params(params)
paramsList of all plot parameters used.
The object itself, invisibly.
get_plot_params()
Get plot parameters.
CographNetwork$get_plot_params()
List of plot parameters.
print()
Print network summary.
CographNetwork$print()
The object itself, invisibly.
clone()
The objects of this class are cloneable with this method.
CographNetwork$clone(deep = FALSE)
deepWhether to make a deep clone.
CographNetwork$new(regulation_net)CographNetwork$new(regulation_net)
Class for managing visual themes for network plots.
A CographTheme R6 object.
nameTheme name.
new()
Create a new CographTheme object.
CographTheme$new( name = "custom", background = "white", node_fill = "#4A90D9", node_border = "#2C5AA0", node_border_width = 1, edge_color = "gray50", edge_positive_color = "#2E7D32", edge_negative_color = "#C62828", edge_width = 1, label_color = "black", label_size = 10, title_color = "black", title_size = 14, legend_background = "white" )
nameTheme name (optional).
backgroundBackground color.
node_fillDefault node fill color.
node_borderDefault node border color.
node_border_widthDefault node border width.
edge_colorDefault edge color.
edge_positive_colorColor for positive edge weights.
edge_negative_colorColor for negative edge weights.
edge_widthDefault edge width.
label_colorDefault label color.
label_sizeDefault label size.
title_colorTitle color.
title_sizeTitle size.
legend_backgroundLegend background color.
A new CographTheme object.
get()
Get a theme parameter.
CographTheme$get(name)
nameParameter name.
Parameter value, or NULL if the parameter is not set.
set()
Set a theme parameter.
CographTheme$set(name, value)
nameParameter name.
valueParameter value.
The object itself, invisibly.
get_all()
Get all theme parameters.
CographTheme$get_all()
List of parameters.
merge()
Merge with another theme. Parameters in other
replace the matching parameters of this theme; parameters present in
only one of the two, including ones added with $set(), are
kept.
CographTheme$merge(other)
otherAnother CographTheme or list of parameters.
A new CographTheme named "merged".
clone_theme()
Clone the theme. Parameters added with $set() are
copied as well.
CographTheme$clone_theme()
A new CographTheme.
print()
Print theme summary.
CographTheme$print()
The object itself, invisibly.
clone()
The objects of this class are cloneable with this method.
CographTheme$clone(deep = FALSE)
deepWhether to make a deep clone.
CographTheme$new(background = "white", node_fill = "steelblue")CographTheme$new(background = "white", node_fill = "steelblue")
Generate colors for nodes based on community membership. Designed for
direct use with splot() node_fill parameter.
color_communities(x, method = "louvain", palette = NULL, ...)color_communities(x, method = "louvain", palette = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
method |
Community detection algorithm. See |
palette |
Color palette to use. Can be:
Any other single string is used as one color for every community. |
... |
Additional arguments passed to |
A character vector of colors with one element per node, named by
node, for use as the node_fill argument of splot().
color_communities(regulation_net, method = "walktrap")color_communities(regulation_net, method = "walktrap")
Detects communities in a network with one of the community detection
algorithms of igraph. Each method calls the matching
community_*() function.
communities( x, method = c("louvain", "leiden", "fast_greedy", "walktrap", "infomap", "label_propagation", "edge_betweenness", "leading_eigenvector", "spinglass", "optimal", "fluid"), community = NULL, weights = NULL, resolution = 1, directed = NULL, seed = NULL, ... )communities( x, method = c("louvain", "leiden", "fast_greedy", "walktrap", "infomap", "label_propagation", "edge_betweenness", "leading_eigenvector", "spinglass", "optimal", "fluid"), community = NULL, weights = NULL, resolution = 1, directed = NULL, seed = NULL, ... )
x |
Network input: matrix, igraph, network, CographNetwork, cograph_network, or tna object. |
method |
Community detection algorithm. One of |
community |
Optional integer or character vector. If supplied, the
returned data frame is filtered to rows whose |
weights |
Edge weights. |
resolution |
Resolution parameter of the louvain and leiden methods. For louvain, higher values yield more communities. Default 1. |
directed |
Logical. Whether the edge betweenness method treats the
network as directed. |
seed |
Random seed for reproducibility. It applies to the stochastic methods (louvain, leiden, infomap, label_propagation, spinglass). |
... |
Additional arguments passed to the |
The louvain, leiden, fast_greedy, leading_eigenvector and fluid methods
require an undirected graph. For a directed input this function prints a
message and runs "walktrap" instead. Called directly,
community_louvain() and community_leiden() raise an igraph
error on a directed graph, while community_fast_greedy(),
community_leading_eigenvector() and community_fluid()
collapse it to an undirected graph with summed weights.
Negative edge weights are replaced by their absolute values for all methods except spinglass and optimal, which receive the weights as they are.
| Method | Typical use |
| louvain | Large undirected networks |
| leiden | Large undirected networks, well-connected communities |
| fast_greedy | Medium-sized networks, hierarchical merges |
| walktrap | Directed or undirected networks, hierarchical merges |
| infomap | Directed networks with flow structure |
| label_propagation | Very large networks |
| edge_betweenness | Small networks, hierarchical splits |
| leading_eigenvector | Undirected networks, hierarchical splits |
| spinglass | Small connected networks, negative weights |
| optimal | Networks of at most about 50 nodes |
| fluid | Connected networks with a known number of communities |
A cograph_communities data frame with one row per node and
the columns
Node label (character).
Community number (numeric).
The attributes "algorithm" (method name), "modularity"
(modularity of the partition, NA when igraph does not compute
it), "network" (the input x) and "igraph_result"
(the igraph communities object) hold the metadata. When
community is supplied, only the matching rows are kept.
Printing the result shows the algorithm, the number of nodes and
communities, the modularity, the community sizes and the node table. The
result is itself a data frame.
plot() on the result is documented in plot-results.
community_louvain, community_leiden,
community_fast_greedy, community_walktrap,
community_infomap, community_label_propagation,
community_edge_betweenness, community_leading_eigenvector,
community_spinglass, community_optimal,
community_fluid
communities(regulation_net, method = "walktrap")communities(regulation_net, method = "walktrap")
Runs a stochastic community detection algorithm repeatedly and derives consensus communities by thresholding the co-occurrence matrix of the runs.
community_consensus( x, method = c("louvain", "leiden", "infomap", "label_propagation", "spinglass"), n_runs = 100, threshold = 0.5, seed = NULL, ... ) com_consensus( x, method = c("louvain", "leiden", "infomap", "label_propagation", "spinglass"), n_runs = 100, threshold = 0.5, seed = NULL, ... )community_consensus( x, method = c("louvain", "leiden", "infomap", "label_propagation", "spinglass"), n_runs = 100, threshold = 0.5, seed = NULL, ... ) com_consensus( x, method = c("louvain", "leiden", "infomap", "label_propagation", "spinglass"), n_runs = 100, threshold = 0.5, seed = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. The louvain and leiden methods require an undirected network. |
method |
Community detection algorithm, one of |
n_runs |
Number of runs. Default 100. |
threshold |
Co-occurrence threshold. Default 0.5. Pairs of nodes that share a community in at least this proportion of runs are linked in the consensus graph. |
seed |
Optional seed for reproducibility. If provided, the RNG state is initialized once before repeated runs and restored on exit. |
... |
Ignored. Each run calls the igraph function with its own defaults and without weights or resolution settings. For leiden this is the CPM objective with resolution 1. |
The algorithm is run n_runs times on the current random number
stream. The proportion of runs in which each pair of nodes shares a
community forms the co-occurrence matrix. Pairs with a proportion of at
least threshold are linked in an unweighted consensus graph, and
walktrap on that graph gives the final communities.
A cograph_communities data frame (columns node and
community) holding the consensus membership. Its
"algorithm" attribute is "consensus_<method>" and its
"modularity" attribute is the modularity of the final walktrap
partition computed on the consensus graph.
Lancichinetti, A., & Fortunato, S. (2012). Consensus clustering in complex networks. Scientific Reports, 2, 336.
communities, community_louvain
community_consensus(to_undirected(regulation_net), method = "louvain", n_runs = 10, seed = 1)community_consensus(to_undirected(regulation_net), method = "louvain", n_runs = 10, seed = 1)
The Girvan-Newman algorithm. It repeatedly removes the edge with the highest edge betweenness and keeps the partition with the highest modularity. On a weighted graph igraph warns that the membership is selected by modularity.
community_edge_betweenness( x, weights = NULL, directed = TRUE, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_eb( x, weights = NULL, directed = TRUE, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE, ... )community_edge_betweenness( x, weights = NULL, directed = TRUE, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_eb( x, weights = NULL, directed = TRUE, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE, ... )
x |
Network input. |
weights |
Edge weights. |
directed |
Logical. Whether edge directions are used. Default
|
edge.betweenness |
Logical. Whether igraph stores the edge
betweenness values. Default |
merges |
Logical. Whether igraph stores the merge matrix. Default
|
bridges |
Logical. Whether igraph stores the bridge edges. Default
|
modularity |
Logical. Whether igraph stores the modularity scores.
Default |
membership |
Logical. Whether igraph computes the membership vector.
Default |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Girvan, M., & Newman, M.E.J. (2002). Community structure in social and biological networks. PNAS, 99(12), 7821-7826.
community_edge_betweenness(igraph::make_graph("Zachary"))community_edge_betweenness(igraph::make_graph("Zachary"))
Hierarchical agglomeration by greedy modularity optimization, which produces a dendrogram of community merges. A directed graph is collapsed to an undirected graph with summed edge weights.
community_fast_greedy( x, weights = NULL, merges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_fg( x, weights = NULL, merges = TRUE, modularity = TRUE, membership = TRUE, ... )community_fast_greedy( x, weights = NULL, merges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_fg( x, weights = NULL, merges = TRUE, modularity = TRUE, membership = TRUE, ... )
x |
Network input. |
weights |
Edge weights. |
merges |
Logical. Whether igraph stores the merge matrix. Default
|
modularity |
Logical. Whether igraph stores the modularity scores.
Default |
membership |
Logical. Whether igraph computes the membership vector.
Default |
... |
Passed to |
A cograph_communities data frame with columns
node and community. The igraph communities result,
including the merge dendrogram when merges = TRUE, is kept in the
"igraph_result" attribute.
Clauset, A., Newman, M.E.J., & Moore, C. (2004). Finding community structure in very large networks. Physical Review E, 70, 066111.
community_fast_greedy(regulation_net)community_fast_greedy(regulation_net)
Fluid communities algorithm, in which a fixed number of communities expand and compete for nodes. A directed graph is collapsed to an undirected graph. A disconnected graph raises a warning and only its largest component is partitioned, so the result has one row per node of that component. Edge weights are not used.
community_fluid(x, no.of.communities, ...) com_fl(x, no.of.communities, ...)community_fluid(x, no.of.communities, ...) com_fl(x, no.of.communities, ...)
x |
Network input. |
no.of.communities |
Number of communities to detect. Required; a missing value raises an error. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Pares, F., Gasulla, D.G., Vilalta, A., Moreno, J., Ayguade, E., Labarta, J., Cortes, U., & Suzumura, T. (2018). Fluid communities: A competitive, scalable and diverse community detection algorithm. Studies in Computational Intelligence, 689, 229-240.
community_fluid(regulation_net, no.of.communities = 2)community_fluid(regulation_net, no.of.communities = 2)
Information-theoretic community detection based on random walks. The partition minimizes the map equation, the description length of a random walk on the network.
community_infomap( x, weights = NULL, v.weights = NULL, nb.trials = 10, modularity = TRUE, seed = NULL, ... ) com_im( x, weights = NULL, v.weights = NULL, nb.trials = 10, modularity = TRUE, seed = NULL, ... )community_infomap( x, weights = NULL, v.weights = NULL, nb.trials = 10, modularity = TRUE, seed = NULL, ... ) com_im( x, weights = NULL, v.weights = NULL, nb.trials = 10, modularity = TRUE, seed = NULL, ... )
x |
Network input. |
weights |
Edge weights. |
v.weights |
Vertex weights (teleportation weights). |
nb.trials |
Number of optimization trials. Default 10. |
modularity |
Logical. Whether modularity is computed. Default
|
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Rosvall, M., & Bergstrom, C.T. (2008). Maps of random walks on complex networks reveal community structure. PNAS, 105(4), 1118-1123.
community_infomap(regulation_net, nb.trials = 10, seed = 1)community_infomap(regulation_net, nb.trials = 10, seed = 1)
Label propagation community detection. Each node repeatedly adopts the most frequent label among its neighbors.
community_label_propagation( x, weights = NULL, mode = c("out", "in", "all"), initial = NULL, fixed = NULL, seed = NULL, ... ) com_lp( x, weights = NULL, mode = c("out", "in", "all"), initial = NULL, fixed = NULL, seed = NULL, ... )community_label_propagation( x, weights = NULL, mode = c("out", "in", "all"), initial = NULL, fixed = NULL, seed = NULL, ... ) com_lp( x, weights = NULL, mode = c("out", "in", "all"), initial = NULL, fixed = NULL, seed = NULL, ... )
x |
Network input. |
weights |
Edge weights. |
mode |
Direction of label propagation in directed graphs, one of
|
initial |
Initial labels, an integer vector, or |
fixed |
Logical vector marking the nodes whose labels are fixed. |
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Raghavan, U.N., Albert, R., & Kumara, S. (2007). Near linear time algorithm to detect community structures in large-scale networks. Physical Review E, 76, 036106.
community_label_propagation(regulation_net, seed = 1)community_label_propagation(regulation_net, seed = 1)
Detects communities with the leading eigenvector of the modularity matrix, splitting the network divisively. A directed graph is collapsed to an undirected graph with summed edge weights.
community_leading_eigenvector( x, weights = NULL, steps = -1, start = NULL, options = igraph::arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame(), ... ) com_le( x, weights = NULL, steps = -1, start = NULL, options = igraph::arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame(), ... )community_leading_eigenvector( x, weights = NULL, steps = -1, start = NULL, options = igraph::arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame(), ... ) com_le( x, weights = NULL, steps = -1, start = NULL, options = igraph::arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame(), ... )
x |
Network input. |
weights |
Edge weights. |
steps |
Maximum number of split attempts. Default -1 (no limit). |
start |
Starting community structure (membership vector). |
options |
ARPACK options list. Default
|
callback |
Optional function called after each split. |
extra |
Extra argument passed to |
env |
Environment in which |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Newman, M.E.J. (2006). Finding community structure using the eigenvectors of matrices. Physical Review E, 74, 036104.
community_leading_eigenvector(regulation_net)community_leading_eigenvector(regulation_net)
The Leiden algorithm, a refinement of the Louvain algorithm that guarantees well-connected communities. It optimizes the Constant Potts Model (CPM) or modularity. The graph must be undirected; a directed graph raises an igraph error.
community_leiden( x, weights = NULL, resolution = 1, objective_function = c("CPM", "modularity"), beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL, seed = NULL, ... ) com_ld( x, weights = NULL, resolution = 1, objective_function = c("CPM", "modularity"), beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL, seed = NULL, ... )community_leiden( x, weights = NULL, resolution = 1, objective_function = c("CPM", "modularity"), beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL, seed = NULL, ... ) com_ld( x, weights = NULL, resolution = 1, objective_function = c("CPM", "modularity"), beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL, seed = NULL, ... )
x |
Network input. |
weights |
Edge weights. |
resolution |
Resolution parameter. Default 1. With the default CPM objective and resolution 1, a network with weights below 1 is typically split into single-node communities. |
objective_function |
Optimization objective, |
beta |
Randomness parameter of the refinement step. Default 0.01. |
initial_membership |
Initial community assignments (optional). |
n_iterations |
Number of iterations. Default 2. A negative value iterates until the partition no longer changes. |
vertex_weights |
Vertex weights for the CPM objective. |
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Traag, V.A., Waltman, L., & van Eck, N.J. (2019). From Louvain to Leiden: guaranteeing well-connected communities. Scientific Reports, 9, 5233.
community_leiden(to_undirected(regulation_net), objective_function = "modularity", seed = 1)community_leiden(to_undirected(regulation_net), objective_function = "modularity", seed = 1)
Multi-level modularity optimization with the Louvain algorithm. The graph
must be undirected; a directed graph raises an igraph error, so a directed
network is converted first, for example with to_undirected().
community_louvain(x, weights = NULL, resolution = 1, seed = NULL, ...) com_lv(x, weights = NULL, resolution = 1, seed = NULL, ...)community_louvain(x, weights = NULL, resolution = 1, seed = NULL, ...) com_lv(x, weights = NULL, resolution = 1, seed = NULL, ...)
x |
Network input. |
weights |
Edge weights. |
resolution |
Resolution parameter. Higher values yield more communities. Default 1 (standard modularity). |
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Blondel, V.D., Guillaume, J.L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics, P10008.
community_louvain(to_undirected(regulation_net), seed = 1)community_louvain(to_undirected(regulation_net), seed = 1)
Finds the partition with maximum modularity by exact optimization. Exact modularity maximization is NP-hard, so the computation is feasible only for small networks. A network with more than 50 nodes raises a warning.
community_optimal(x, weights = NULL, ...) com_op(x, weights = NULL, ...)community_optimal(x, weights = NULL, ...) com_op(x, weights = NULL, ...)
x |
Network input. |
weights |
Edge weights. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Brandes, U., Delling, D., Gaertler, M., Gorke, R., Hoefer, M., Nikoloski, Z., & Wagner, D. (2008). On modularity clustering. IEEE Transactions on Knowledge and Data Engineering, 20(2), 172-188.
community_optimal(regulation_net)community_optimal(regulation_net)
Get Community Sizes
community_sizes(x)community_sizes(x)
x |
A |
An unnamed integer vector of community sizes, ordered by community number.
comm <- community_walktrap(regulation_net) community_sizes(comm)comm <- community_walktrap(regulation_net) community_sizes(comm)
Community detection based on the spinglass model of statistical
mechanics, optimized by simulated annealing. Negative edge weights are
supported with implementation = "neg". A disconnected graph raises
a warning and only its largest component is partitioned, so the result
has one row per node of that component.
community_spinglass( x, weights = NULL, vertex = NULL, spins = 25, parupdate = FALSE, start.temp = 1, stop.temp = 0.01, cool.fact = 0.99, update.rule = c("config", "random", "simple"), gamma = 1, implementation = c("orig", "neg"), gamma.minus = 1, seed = NULL, ... ) com_sg( x, weights = NULL, vertex = NULL, spins = 25, parupdate = FALSE, start.temp = 1, stop.temp = 0.01, cool.fact = 0.99, update.rule = c("config", "random", "simple"), gamma = 1, implementation = c("orig", "neg"), gamma.minus = 1, seed = NULL, ... )community_spinglass( x, weights = NULL, vertex = NULL, spins = 25, parupdate = FALSE, start.temp = 1, stop.temp = 0.01, cool.fact = 0.99, update.rule = c("config", "random", "simple"), gamma = 1, implementation = c("orig", "neg"), gamma.minus = 1, seed = NULL, ... ) com_sg( x, weights = NULL, vertex = NULL, spins = 25, parupdate = FALSE, start.temp = 1, stop.temp = 0.01, cool.fact = 0.99, update.rule = c("config", "random", "simple"), gamma = 1, implementation = c("orig", "neg"), gamma.minus = 1, seed = NULL, ... )
x |
Network input. |
weights |
Edge weights. |
vertex |
Vertex whose community is searched (single community mode).
|
spins |
Number of spins, the upper limit on the number of communities. Default 25. |
parupdate |
Logical. Whether spins are updated in parallel. Default
|
start.temp |
Starting temperature. Default 1. |
stop.temp |
Stopping temperature. Default 0.01. |
cool.fact |
Cooling factor. Default 0.99. |
update.rule |
Null model of the update rule, one of |
gamma |
Weight of the null model term. Default 1. |
implementation |
|
gamma.minus |
Weight of the null model term for negative edges in
the |
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Reichardt, J., & Bornholdt, S. (2006). Statistical mechanics of community detection. Physical Review E, 74, 016110.
community_spinglass(regulation_net, seed = 1)community_spinglass(regulation_net, seed = 1)
Detects communities from short random walks. Nodes in the same community have short random walk distances.
community_walktrap( x, weights = NULL, steps = 4, merges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_wt( x, weights = NULL, steps = 4, merges = TRUE, modularity = TRUE, membership = TRUE, ... )community_walktrap( x, weights = NULL, steps = 4, merges = TRUE, modularity = TRUE, membership = TRUE, ... ) com_wt( x, weights = NULL, steps = 4, merges = TRUE, modularity = TRUE, membership = TRUE, ... )
x |
Network input. |
weights |
Edge weights. |
steps |
Length of the random walks. Default 4. |
merges |
Logical. Whether igraph stores the merge matrix. Default
|
modularity |
Logical. Whether igraph stores the modularity scores.
Default |
membership |
Logical. Whether igraph computes the membership vector.
Default |
... |
Passed to |
A cograph_communities data frame with columns
node and community. See communities for its
attributes.
Pons, P., & Latapy, M. (2006). Computing communities in large networks using random walks. Journal of Graph Algorithms and Applications, 10(2), 191-218.
community_walktrap(regulation_net, steps = 4)community_walktrap(regulation_net, steps = 4)
Compares two partitions of the same nodes with igraph's partition comparison measures.
compare_communities( comm1, comm2, method = c("vi", "nmi", "split.join", "rand", "adjusted.rand") )compare_communities( comm1, comm2, method = c("vi", "nmi", "split.join", "rand", "adjusted.rand") )
comm1, comm2
|
Partitions to compare. Each is a
|
method |
Comparison measure, one of |
A single numeric value. "vi" and "split.join" are
distances (0 for identical partitions); "nmi", "rand" and
"adjusted.rand" are similarities (1 for identical partitions).
walktrap <- community_walktrap(regulation_net) fast_greedy <- community_fast_greedy(regulation_net) compare_communities(walktrap, fast_greedy, method = "nmi")walktrap <- community_walktrap(regulation_net) fast_greedy <- community_fast_greedy(regulation_net) compare_communities(walktrap, fast_greedy, method = "nmi")
Every pair of distinct nodes that is not joined in x is joined in the
complement, and every joined pair is absent from it.
complement_network( x, weight = 1, loops = FALSE, keep_format = FALSE, directed = NULL )complement_network( x, weight = 1, loops = FALSE, keep_format = FALSE, directed = NULL )
x |
Network input. |
weight |
Numeric. Weight of every edge in the complement. Default 1. A
weight of zero means no edge, so |
loops |
Logical. Include self-loops in the complement. Default FALSE. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network holding the complement, or the input format
when keep_format = TRUE. Directedness is preserved.
complement_network(threshold_edges(regulation_net, minimum = 0.2))complement_network(threshold_edges(regulation_net, minimum = 0.2))
Replaces each group of nodes with a single node whose edges aggregate the
edges of its members. The operation corresponds to igraph::contract()
and tidygraph's to_contracted(), and it is the network form of the
aggregation computed by summarize_clusters().
contract_nodes( x, groups, weight = c("sum", "mean", "max", "min"), loops = FALSE, keep_format = FALSE, directed = NULL )contract_nodes( x, groups, weight = c("sum", "mean", "max", "min"), loops = FALSE, keep_format = FALSE, directed = NULL )
x |
Network input. |
groups |
Group assignment. Either a vector with one entry per node, in
node order, or a named list mapping each group name to node labels. A list
must assign every node. Malformed input raises a
|
weight |
How to aggregate the weights of the edges that fall between
two groups. One of |
loops |
Logical. Keep the within-group edges as self-loops on the contracted node. Default FALSE. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network with one node per group, labeled by group
name, or the input format when keep_format = TRUE. The groups
follow the factor levels of a vector (sorted for a character vector) or
the order of a list.
summarize_clusters, detect_communities,
split_components
contract_nodes(regulation_net, groups = rep(c("Plan", "Act"), each = 5))contract_nodes(regulation_net, groups = rep(c("Plan", "Act"), each = 5))
Identifies core-periphery structure in a network with a continuous (Borgatti-Everett) or a discrete method. Core nodes are densely interconnected, and periphery nodes connect mainly to the core. Edge weights are ignored; the analysis uses the binary adjacency matrix.
core_periphery( x, method = c("continuous", "discrete"), directed = NULL, iter = 100, digits = NULL, ... )core_periphery( x, method = c("continuous", "discrete"), directed = NULL, iter = 100, digits = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
method |
Character string; either "continuous" (default, Borgatti-Everett model) or "discrete" (binary core/periphery assignment). |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
iter |
Integer; maximum number of power iterations. Must be at least
|
digits |
Integer or NULL. Number of decimal places for the coreness scores, the fitness and the densities. Default NULL (no rounding). |
... |
Passed to |
The Borgatti-Everett model compares the adjacency matrix with the rank-1
pattern matrix outer(c, c) of a coreness vector c. Here
c is estimated from the dominant eigenvector of the adjacency
matrix, refined by power iteration with rescaling to . The
iteration stops when the largest change falls below or after
iter steps. The vector is not optimized for the correlation. The
"fitness" attribute is the correlation between the off-diagonal
entries of the adjacency matrix and those of the pattern matrix (the lower
triangle for a symmetric matrix), and it is 0 when the correlation is
undefined.
The discrete method starts from the continuous solution split at the median
and repeatedly flips the single node assignment that most increases
density(core) - density(periphery). It stops when no flip increases
this quantity. The "fitness" attribute is the correlation between the
adjacency matrix and the ideal block pattern of the final assignment.
A data frame with class "cograph_core_periphery", one row per
node, and columns:
Node label.
Character: "core" or "periphery". For the
continuous method a node is core when its coreness is at or above the
median coreness.
Numeric continuous coreness score, rescaled to
. Reported for both methods.
The attributes "fitness", "core_density" and
"periphery_density" hold the fit and the block densities, and
"network" holds the original input.
Printing the result shows the core and periphery sizes, the fitness and the
two block densities, followed by the node table. The result is a data frame
and serves as the tidy table directly. plot() on the result is
documented in plot-results.
Borgatti, S.P. & Everett, M.G. (2000). Models of core/periphery structures. Social Networks, 21(4), 375-395. doi:10.1016/S0378-8733(99)00019-2
core_periphery(regulation_net)core_periphery(regulation_net)
Aggregates node-level network weights to cluster-level summaries. The result holds the macro (cluster-to-cluster) network and one network of within-cluster connections per cluster.
csum( x, clusters = NULL, method = c("sum", "mean", "median", "max", "min", "density", "geomean"), type = c("tna", "cooccurrence", "semi_markov", "raw"), directed = TRUE, compute_within = TRUE )csum( x, clusters = NULL, method = c("sum", "mean", "median", "max", "min", "density", "geomean"), type = c("tna", "cooccurrence", "semi_markov", "raw"), directed = TRUE, compute_within = TRUE )
x |
Network input. Accepts multiple formats:
|
clusters |
Cluster/group assignments for nodes. Accepts multiple formats:
|
method |
Aggregation method for combining edge weights within/between
clusters. Zero and
|
type |
Post-processing applied to aggregated weights. Determines the interpretation of the resulting matrices:
|
directed |
Logical. Default |
compute_within |
Logical. If |
The function is the matrix-based entry point to Multi-Cluster Multi-Level
(MCML) analysis. as_tna converts the result to tna models.
A typical MCML analysis computes the summary, then plots it with
plot_mcml or converts it to tna models with
as_tna:
cs <- csum(net, clusters = clusters, type = "tna") plot_mcml(cs) as_tna(cs)
The macro weight matrix has clusters as both rows and columns. An
off-diagonal cell (i, j) holds the aggregated weight from cluster i to
cluster j. A diagonal cell (i, i) holds the aggregated weight of the edges
inside cluster i. When type = "tna", rows sum to 1 and the diagonal
is the probability of staying inside the same cluster.
| Input data | Recommended | Reason |
| Edge counts | method="sum", type="tna" | Preserves total flow, normalizes to probabilities |
| Transition matrix | method="mean", type="tna" | Avoids cluster size bias |
| Frequencies | method="sum", type="raw" | Keep raw counts for analysis |
| Correlation matrix | method="mean", type="raw" | Average correlations |
A cluster_summary object (S3 class) containing:
A tna object representing the macro (cluster-level) network:
k x k matrix of cluster-to-cluster weights, where k is
the number of clusters. Row i, column j contains the aggregated
weight from cluster i to cluster j. The diagonal contains the
aggregated within-cluster weight, node self-loops included.
Processing depends on type.
Named numeric vector of length k, the column sums of
the aggregated cluster matrix (before type processing)
divided by their total. It is uniform when all weights are zero.
Cluster names.
Sequence data of a tna input, otherwise NULL.
A group_tna list with one tna object per
cluster, each containing:
n_i x n_i matrix for nodes inside that cluster. Shows internal transitions between nodes in the same cluster.
Column sums of the within-cluster weights divided by their total.
NULL if compute_within = FALSE.
Named list mapping cluster names to their member node labels.
Example: list(A = c("n1", "n2"), B = c("n3", "n4", "n5"))
List of metadata:
The type argument used ("tna", "raw", etc.)
The method argument used ("sum", "mean", etc.)
Logical, effective directedness of the stored
weights (FALSE when type = "cooccurrence", which
symmetrizes them)
Total number of nodes in original network
Number of clusters
Named vector of cluster sizes
as_tna to convert results to tna objects,
plot_mcml for two-layer visualization,
plot_mtna for flat cluster visualization
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) csum(regulation_net, clusters = clusters, type = "tna")clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) csum(regulation_net, clusters = clusters, type = "tna")
Plots a histogram or a complementary cumulative distribution of node degrees. When the degree range is at most 50, the default bins are integer-aligned, with one bar per degree value.
degree_distribution( x, mode = "all", directed = NULL, loops = TRUE, simplify = "sum", cumulative = FALSE, breaks = NULL, bins = NULL, bin_width = NULL, normalize = FALSE, log = "", main = "Degree Distribution", xlab = "Degree", ylab = NULL, col = "steelblue", border = "white", ... )degree_distribution( x, mode = "all", directed = NULL, loops = TRUE, simplify = "sum", cumulative = FALSE, breaks = NULL, bins = NULL, bin_width = NULL, normalize = FALSE, log = "", main = "Degree Distribution", xlab = "Degree", ylab = NULL, col = "steelblue", border = "white", ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
mode |
For directed networks: "all", "in", or "out". Default "all". |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
loops |
Logical. If TRUE (default), keep self-loops. Set FALSE to remove them. |
simplify |
How to combine multiple edges between the same node pair. Options: "sum" (default), "mean", "max", "min", or FALSE/"none" to keep multiple edges. |
cumulative |
Logical. If TRUE, show CCDF (complementary cumulative distribution: P(degree >= k)) instead of frequency. Default FALSE. |
breaks |
Bin specification passed to |
bins |
Integer. Number of equal-width bins spanning the degree range.
Overrides |
bin_width |
Numeric. Width of each bin. Default NULL, which uses a width of 1 when the degree range is at most 50 and the Freedman-Diaconis rule otherwise. |
normalize |
Logical. If TRUE, the y-axis shows proportions (bars sum to 1) instead of counts. Default FALSE. |
log |
Character. Axis log-scaling: "" (none, default), "x", "y", or "xy". Histogram plots apply y-axis log scaling for "y" or "xy"; cumulative plots support x, y, and xy scaling, and "xy" gives a log-log CCDF. |
main |
Character. Plot title. Default "Degree Distribution". |
xlab |
Character. X-axis label. Default "Degree". |
ylab |
Character. Y-axis label. Default auto-chosen based on
|
col |
Character. Bar fill or line color. Default "steelblue". |
border |
Character. Bar border color. Default "white". |
... |
Additional graphical arguments passed to
|
Invisibly returns a list with components:
Named numeric vector of per-node degrees.
Table of degree frequencies.
Breakpoints of the degree histogram.
Bin counts.
Bin proportions (counts / sum(counts)).
The same five components are returned for the histogram and the cumulative plot. The bin components always describe the histogram bins.
cograph::degree_distribution(regulation_net)cograph::degree_distribution(regulation_net)
Detects communities (clusters) in a network using various community detection algorithms. Returns a data frame with node-community assignments.
detect_communities(x, method = "louvain", directed = NULL, weights = TRUE)detect_communities(x, method = "louvain", directed = NULL, weights = TRUE)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
method |
Community detection algorithm to use. One of:
|
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
weights |
Logical. Use edge weights for community detection. Default TRUE. |
A cograph_communities object, which inherits from
data.frame and has one row per node with columns:
node: Node labels/names
community: Numeric community membership
The algorithm name, the igraph community object, the modularity and the
input network are carried as attributes for the print, plot
and modularity methods.
detect_communities(regulation_net, method = "walktrap")detect_communities(regulation_net, method = "walktrap")
Extracts the statistically significant backbone of a weighted network using the disparity filter method (Serrano, Boguna, & Vespignani, 2009).
disparity_filter(x, level = 0.05, ...) ## Default S3 method: disparity_filter(x, level = 0.05, ...) ## S3 method for class 'matrix' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'tna' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'cograph_network' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'igraph' disparity_filter(x, level = 0.05, ...)disparity_filter(x, level = 0.05, ...) ## Default S3 method: disparity_filter(x, level = 0.05, ...) ## S3 method for class 'matrix' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'tna' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'cograph_network' disparity_filter(x, level = 0.05, ...) ## S3 method for class 'igraph' disparity_filter(x, level = 0.05, ...)
x |
A weight matrix, tna object, cograph_network, or igraph object. |
level |
Significance level (default 0.05). Lower values result in a sparser backbone (fewer edges retained). |
... |
Additional arguments (currently unused). |
The disparity filter identifies edges that carry a disproportionate fraction of a node's total weight, based on a null model where weights are distributed uniformly at random.
For each node with degree , and each edge
with normalized weight (where is
the node's strength), the p-value is:
The p-value is computed from the outgoing weights of the source node
(row strength and out-degree) and from the incoming weights of the target
node (column strength and in-degree). An edge is significant if the
smaller of the two p-values is below level. Self-loops are never
retained. For igraph input, unweighted edges get weight 1 and multiple
edges are summed before filtering.
For a matrix, an integer matrix of the same dimensions and
dimnames with 1 for significant edges and 0 otherwise. For tna,
cograph_network and igraph objects, a tna_disparity list with
elements significant (the 0/1 matrix), weights_orig,
weights_filtered (original weights times the 0/1 matrix),
level, n_edges_orig and n_edges_filtered. Any other
input raises an error.
Serrano, M. A., Boguna, M., & Vespignani, A. (2009). Extracting the multiscale backbone of complex weighted networks. Proceedings of the National Academy of Sciences, 106(16), 6483-6488.
bootstrap for bootstrap-based significance testing
disparity_filter(regulation_net, level = 0.3)disparity_filter(regulation_net, level = 0.3)
Computes the dispersion of a tie (Backstrom and Kleinberg 2014), a
per-pair measure of tie strength. Edge weights are ignored, and directed
networks use out-neighbors. For each pair where is a
neighbor of , the computation proceeds as follows.
dispersion(x, u = NULL, v = NULL, normalized = TRUE, alpha = 1, b = 0, c = 0)dispersion(x, u = NULL, v = NULL, normalized = TRUE, alpha = 1, b = 0, c = 0)
x |
Network input (matrix, igraph, network, cograph_network, tna object). |
u |
Optional source node (1-based index or node name). If |
v |
Optional target node. If |
normalized |
Logical. If |
alpha |
Numeric normalization exponent. Default 1. |
b |
Numeric bias added to dispersion before exponentiation. Default 0. |
c |
Numeric bias added to embeddedness in the denominator. Default 0. |
Let be their mutual friends (embeddedness).
Count pairs such that:
and are not directly connected, and
and share no common neighbor inside
other than and .
The raw dispersion is this count. When normalized = TRUE,
the result is (normalization is skipped when
embeddedness + c == 0).
Scalar if both u and v are specified.
Named numeric vector if exactly one of u, v is given,
one element per neighbor of that node; the names are the neighbors'
1-based node indices as character strings.
A data frame with columns from, to, dispersion
when neither u nor v is given, one row per ordered
(node, neighbor) pair, with from and to given as 1-based
integer node indices.
numeric(0) for an empty graph.
Backstrom, L., & Kleinberg, J. (2014). Romantic partnerships and the dispersion of social ties: A network analysis of relationship status on Facebook. In Proceedings of CSCW (pp. 831-841). ACM. https://arxiv.org/pdf/1310.6753v1.pdf
dispersion(regulation_net, u = "Plan")dispersion(regulation_net, u = "Plan")
Classifies every dyad (unordered pair of nodes) in a directed network into
one of three mutually exclusive states: mutual (M, edges in both
directions), asymmetric (A, an edge in exactly one direction), or null
(N, no edge between the pair). The dyad census is the dyad-level
counterpart of triad_census and is the basis of dyad-based
reciprocity.
dyad_census(x, directed = NULL, ...)dyad_census(x, directed = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
... |
Passed to |
In an undirected network every present edge is counted as a mutual dyad
and the asymmetric count is zero. The total number of dyads is
in both cases.
A tidy data.frame of class "cograph_dyad_census" with one row
per dyad type and columns:
Character: "mutual", "asymmetric", or
"null".
Integer: number of dyads of that type.
Numeric: count divided by the total number of dyads
().
The dyad-based reciprocity is attached as the
"reciprocity" attribute (NA for a network without edges).
The attributes "directed" and "n_dyads" record the
directedness and the total number of dyads.
Wasserman, S., & Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press.
triad_census, edge_reciprocity,
network_summary
cograph::dyad_census(regulation_net)cograph::dyad_census(regulation_net)
Computes centrality measures for the edges of a network and returns a tidy data frame with one row per edge.
edge_centrality( x, measures = "all", weighted = TRUE, directed = NULL, cutoff = -1, invert_weights = NULL, alpha = 1, digits = NULL, sort_by = NULL, ... ) edge_betweenness(x, ...)edge_centrality( x, measures = "all", weighted = TRUE, directed = NULL, cutoff = -1, invert_weights = NULL, alpha = 1, digits = NULL, sort_by = NULL, ... ) edge_betweenness(x, ...)
x |
Network input (matrix, edge-list data frame, igraph, network, cograph_network, tna object). |
measures |
Which measures to calculate. Default "all" calculates all available edge measures. Options: "betweenness", "weight", "overlap", "simmelian", "reciprocity". |
weighted |
Logical. Use edge weights if available. Default TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
cutoff |
Maximum path length for betweenness. Default -1 (no limit). |
invert_weights |
Logical or NULL. Whether edge betweenness inverts the
weights, so that higher weights mean shorter paths. The default
|
alpha |
Numeric. Exponent of the inversion, which computes distances
as |
digits |
Integer or NULL. Round numeric columns. Default NULL. |
sort_by |
Character or NULL. Column to sort by (descending). Default NULL. |
... |
For |
Edge measures available, with the column(s) each one adds:
Edge betweenness, the sum over node pairs of the
share of their shortest paths that pass through the edge. Adds
betweenness.
Original edge weight (1 for an unweighted input). Adds
weight.
Jaccard neighborhood overlap of the edge endpoints. Adds
overlap and the raw count shared_neighbors.
Number of triangles the edge participates in. Adds
triangles (there is no column called simmelian).
Whether the reverse edge exists. Directed only: on an
undirected input it warns and adds nothing. Adds
reciprocated, reverse_weight and weight_ratio,
the last two NA where the edge is not reciprocated.
measures = "all" requests every measure, dropping
reciprocity on an undirected input.
edge_centrality() returns a base data.frame with one
row per edge, in the canonical
(row-major) edge order of the input. The first two columns are
from and to (character when the input carried node names,
numeric indices otherwise); the remaining columns are those the requested
measures contribute, as listed in Details. measures = "all" on an
undirected input therefore gives from, to, weight,
betweenness, overlap, shared_neighbors and
triangles, and a directed input adds reciprocated,
reverse_weight and weight_ratio.
edge_betweenness() returns a numeric vector of edge
betweenness values named "from->to", for directed and undirected
inputs alike.
edge_centrality(regulation_net, measures = "betweenness")edge_centrality(regulation_net, measures = "betweenness")
Convenience wrapper around edge_centrality that returns only
reciprocity information for directed networks.
edge_reciprocity(x, top = NULL, directed = NULL, digits = NULL, ...)edge_reciprocity(x, top = NULL, directed = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
top |
Integer or NULL. Return only the top N edges. Default NULL. |
directed |
Logical or NULL. Default NULL (auto-detect). |
digits |
Integer or NULL. Round numeric columns. Default NULL. |
... |
Additional arguments passed to |
A data frame with one row per directed edge and columns
from, to, weight, reciprocated (logical),
reverse_weight (NA when not reciprocated) and weight_ratio
(reverse_weight / weight; NA when not reciprocated). Rows are
ordered with reciprocated edges first, then by |weight_ratio|
descending.
Raises an error when the resolved network is undirected: reciprocity is only defined for directed edges.
cograph::edge_reciprocity(regulation_net, top = 5)cograph::edge_reciprocity(regulation_net, top = 5)
Extracts the ego network of each requested node and computes a table of personal-network metrics with one row per ego. An ego network consists of the node, its neighbors up to a given order and the ties among them. The metrics are the network size, tie counts and densities, and Burt's structural-hole measures.
ego_networks( x, nodes = NULL, order = 1, mode = c("all", "out", "in"), directed = NULL, ... )ego_networks( x, nodes = NULL, order = 1, mode = c("all", "out", "in"), directed = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
nodes |
Character vector of node names or integer vector of node indices selecting which egos to report. NULL (default) uses every node. An unknown name or an index out of range raises an error. |
order |
Integer neighborhood order defining the ego network. 1
(default) is the standard ego network (ego and direct neighbors). Burt's
|
mode |
For directed networks, which ties define the neighborhood:
|
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. |
... |
Passed to |
Self-loops are dropped before ties are counted. In a directed network the
tie counts are counts of directed edges, and the densities divide by
for members.
effective_size and constraint are computed on the full
network from all ties of each node, with the same implementations as
centrality, so the values equal
centrality(x, measures = c("effective_size", "constraint")).
Effective size uses the unweighted ties. Constraint uses the edge weights.
A data frame of class "cograph_ego_networks" with one row
per ego and columns:
Ego node name.
Number of alters (ego-network size, excluding ego).
Number of edges in the ego network (ego and alters).
Edge density of the ego network including ego.
NA for an ego without alters.
Number of edges among the alters only (excluding ego).
Edge density among the alters. NA for an
ego with fewer than two alters. Low values indicate many structural
holes and brokerage opportunities.
Burt's effective size of the ego network
(order = 1 only).
Burt's constraint (order = 1 only).
The arguments order and mode and the directedness of the
network are stored as attributes. Printing the result shows
order and mode above the table.
Burt, R.S. (1992). Structural Holes: The Social Structure of Competition. Harvard University Press.
centrality (for effective_size and
constraint), dispersion,
select_neighbors, neighborhood_overlap
cograph::ego_networks(regulation_net, nodes = "Plan")cograph::ego_networks(regulation_net, nodes = "Plan")
Computes the Estrada index, a graph-level spectral invariant
where are the eigenvalues of the binary adjacency matrix.
Edge weights are ignored. For an undirected network the index equals
, where is the number of closed walks of
length , and it is the sum of the subgraph centralities of all
nodes. For a directed network the eigenvalues may be complex. They come in
conjugate pairs, so the sum of their exponentials is real and again equals
the trace of , the weighted count of closed walks.
estrada_index(x)estrada_index(x)
x |
Network input (matrix, igraph, network, cograph_network, tna object). |
Numeric scalar: the Estrada index of the graph, or 0 for a graph with no nodes.
Estrada, E. (2000). Characterization of 3D molecular structure. Chemical Physics Letters, 319(5-6), 713-718.
centrality_subgraph for the per-node measure. On an
undirected network its values sum to estrada_index(x).
estrada_index(regulation_net)estrada_index(regulation_net)
Extracts the triads of a network, classifies each one into the 16 MAN types of a directed network, and optionally tests each triad against a permutation null model. The analysis is individual-level for tna objects and grouped data, and aggregate for matrices and networks.
extract_motifs( x = NULL, data = NULL, id = NULL, level = NULL, edge_method = c("any", "expected", "percent"), edge_threshold = 1.5, pattern = c("triangle", "network", "closed", "all"), exclude_types = NULL, include_types = NULL, top = NULL, by_type = FALSE, min_transitions = 5, significance = FALSE, n_perm = 100, seed = NULL )extract_motifs( x = NULL, data = NULL, id = NULL, level = NULL, edge_method = c("any", "expected", "percent"), edge_threshold = 1.5, pattern = c("triangle", "network", "closed", "all"), exclude_types = NULL, include_types = NULL, top = NULL, by_type = FALSE, min_transitions = 5, significance = FALSE, n_perm = 100, seed = NULL )
x |
Input data. Can be:
|
data |
Optional data.frame containing transition data with an ID column
for individual-level analysis. Required columns: |
id |
Column name(s) identifying individuals/groups in |
level |
Analysis level: "individual" counts how many individuals show
each triad, and "aggregate" analyzes the network summed over individuals.
The default is "individual" for a tna object or when |
edge_method |
Method for determining edge presence:
Default "any". |
edge_threshold |
Threshold value for "expected" or "percent" methods. For "expected", a ratio (1.5 means 50\ For "percent", a proportion of the total triad weight (for example 0.15). The default 1.5 is intended for "expected", so a value for "percent" should be set explicitly. Ignored when edge_method = "any". Default 1.5. |
pattern |
Pattern filter for which triads to include:
|
exclude_types |
Character vector of MAN types to explicitly exclude. Applied after pattern filter. E.g., c("300") to exclude cliques. |
include_types |
Character vector of MAN types to include. When
supplied, only these types are returned, and |
top |
Number of rows to return, taken after sorting by observed count
(by z-score when |
by_type |
If TRUE, the rows are sorted by MAN type and then by observed count. Default FALSE. |
min_transitions |
At individual level: minimum total transitions for a person to be included in the analysis. At aggregate level: minimum triad weight to count as present. Default 5. |
significance |
Logical. Run permutation significance test? Default FALSE. |
n_perm |
Number of permutations for the significance test. When
|
seed |
Optional random seed. The caller's random number state is restored on exit. |
Self-loops are removed before the activity filter, the counting
and the null model. Significance is assessed against a directed weighted
stub-matching null model. Each weight is rounded to an integer number of
stubs, and a positive weight that rounds to zero keeps one stub. The target
stubs are shuffled, which preserves the in- and out-strengths of every
unit. Loops and multiple edges created by the shuffle are collapsed to a
simple graph before the triads are classified. The aggregate mode of
motifs() uses the simple-graph rewiring null of motif_census()
instead.
The selected edge_method is reapplied to each null replicate. Since
small positive weights are rounded up to one stub, the total weight of a
replicate can differ from the observed total under "percent" and
"expected". Results without significance testing and results with
edge_method = "any" do not depend on this rounding.
A cograph_motif_analysis object (list) containing the elements
below, or NULL with a warning when no triad passes the filters.
Data frame with one row per node-triple and MAN type,
the display label triad, unambiguous node1/node2/
node3 columns, its observed count, and (if
significance = TRUE) expected
count, z-score, empirical p-value, and significance marker. A node
triple that has different types across individuals therefore appears
in more than one row.
A table of triad counts by MAN type,
summed over individuals and sorted in decreasing order.
List of the settings used, with the number of individuals, the number of states and the node labels.
The 16 triad types use MAN (Mutual-Asymmetric-Null) notation where:
First digit: number of mutual (bidirectional) pairs.
Second digit: number of asymmetric (one-way) pairs.
Third digit: number of null (no edge) pairs.
Letter suffix: subtype (C = cycle, T = transitive, D = down, U = up).
030C (cycle), 030T (feed-forward), 120C (regulated cycle), 120D (two out-stars), 120U (two in-stars), 210 (mutual+asymmetric), 300 (clique)
021D (out-star), 021U (in-star), 102 (mutual pair), 111D (out-star+mutual), 111U (in-star+mutual), 201 (two mutual pairs), plus all triangle patterns
012 (single edge), 021C (A->B->C chain)
003 (no edges)
Printing the result shows the analysis settings, the MAN type distribution
and the first 20 triads. plot() on the result is documented in
plot-results.
motifs(), subgraphs(), extract_triads(), motif_census()
Other motifs:
extract_triads(),
get_edge_list(),
motif_census(),
motifs(),
subgraphs(),
triad_census()
extract_motifs(regulation_net, min_transitions = 0)extract_motifs(regulation_net, min_transitions = 0)
Lists the triads of a network that contain at least one edge, with the labels of their nodes, so that the node combinations forming each motif pattern can be identified.
extract_triads( x, type = NULL, involving = NULL, threshold = 0, min_total = 5, directed = NULL )extract_triads( x, type = NULL, involving = NULL, threshold = 0, min_total = 5, directed = NULL )
x |
A matrix, igraph object, tna, or cograph_network. |
type |
Character vector of MAN codes to filter by (e.g., "030T", "030C"). Default NULL returns all types. |
involving |
Character vector of node labels. Only return triads involving at least one of these nodes. Default NULL returns all triads. |
threshold |
Edge weight threshold. An edge counts as present for the
triad type when its weight is greater than |
min_total |
Minimum total weight across all 6 edges. Excludes trivial triads with low overall activity. Default 5. |
directed |
Logical or NULL. Whether the network is treated as directed. NULL (default) detects it from the input. |
The function complements motif_census() by showing the node combinations
that form each motif pattern. The triad type is determined by edge presence
(weight greater than threshold). The weight columns hold the edge
weights themselves, which measure the strength of each triad.
A data frame with one row per triad, in node index order, and the columns:
Labels of the three nodes in the triad.
MAN code (012, ..., 300). Triads of type 003 have no edge and are not returned.
Edge weights of the 6 possible directed edges.
Sum of the 6 edge weights.
A network with fewer than 3 nodes gives a data frame with no rows.
motifs(), subgraphs(), motif_census(), extract_motifs()
Other motifs:
extract_motifs(),
get_edge_list(),
motif_census(),
motifs(),
subgraphs(),
triad_census()
extract_triads(regulation_net, type = "030T", min_total = 0)extract_triads(regulation_net, type = "030T", min_total = 0)
Filter edges using dplyr-style expressions on any edge column. Returns a
cograph_network object by default (universal format), or optionally a
matrix, igraph, statnet network or tna object when keep_format = TRUE
and the input used one of those formats.
filter_edges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL ) subset_edges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL )filter_edges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL ) subset_edges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL )
x |
Network input: cograph_network, matrix, igraph, network, or tna object. |
... |
Filter expressions using any edge column (e.g., |
keep_isolates |
Logical. Keep nodes that end up with no edges?
Default TRUE, matching |
keep_format |
Logical. If TRUE, matrix, igraph, statnet network and tna inputs are returned in that format. Default FALSE returns cograph_network (universal format). |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. Only used for non-cograph_network inputs. |
.keep_isolates |
Deprecated. Use |
A cograph_network object with filtered edges. If keep_format = TRUE,
matrix, igraph, statnet network and tna inputs are converted back to that type.
With keep_isolates = TRUE, a node that loses all its edges stays in
the network and a cograph_isolates_created warning is raised.
filter_nodes, splot, subset_edges
filter_edges(regulation_net, weight > 0.15)filter_edges(regulation_net, weight > 0.15)
Filter nodes using dplyr-style expressions on any node column or centrality
measure. Returns a cograph_network object by default (universal format), or
optionally a matrix, igraph, statnet network or tna object when
keep_format = TRUE and the input used one of those formats.
filter_nodes( x, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL ) subset_nodes( x, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL )filter_nodes( x, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL ) subset_nodes( x, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL )
x |
Network input: cograph_network, matrix, igraph, network, or tna object. |
... |
Filter expressions using any node column or centrality measure. Available variables include:
Examples: On a network with negative edge weights, |
keep_edges |
How to handle edges. One of:
|
keep_format |
Logical. If TRUE, matrix, igraph, statnet network and tna inputs are returned in that format. Default FALSE returns cograph_network (universal format). |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. Only used for non-cograph_network inputs. |
.keep_edges |
Deprecated. Use |
A cograph_network object with filtered nodes. If keep_format = TRUE,
matrix, igraph, statnet network and tna inputs are converted back to that type.
filter_edges, splot, subset_nodes
filter_nodes(regulation_net, degree >= 7)filter_nodes(regulation_net, degree >= 7)
Fits one or more statistical distributions to the degree sequence of a network by maximum likelihood and evaluates goodness of fit with Kolmogorov-Smirnov statistics. The comparison table is sorted by AIC.
fit_degree_distribution( x, distributions = NULL, mode = "all", directed = NULL, xmin = NULL, ... )fit_degree_distribution( x, distributions = NULL, mode = "all", directed = NULL, xmin = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. Without igraph installed, only a numeric matrix is accepted. |
distributions |
Character vector of distributions to fit. Options:
|
mode |
For directed networks: |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
xmin |
Minimum degree to include in fitting. For the power law, NULL
triggers automatic estimation (Clauset et al. 2009 via igraph). For the
other distributions, NULL defaults to 1. Each fit requires at least two
degrees at or above |
... |
Additional arguments (currently unused). |
The power-law model (Pareto type I) is . With
igraph available and xmin = NULL, it is fitted with
igraph::fit_power_law(), which implements the Clauset et al. (2009)
method. Otherwise the simple MLE
is computed, with
equal to the supplied xmin or, without igraph, to the
smallest degree (at least 1).
The exponential model is , with MLE
.
The Poisson model is , with
MLE .
The geometric model is , with MLE
.
ks_p comes from stats::ks.test() for the exponential and
Poisson fits and is NA for the power-law and geometric fits. The
p-values are approximate because the test assumes a continuous
distribution. For the exponential fit stats::ks.test() warns when
degrees are tied. A power-law fit to degrees that all equal xmin
is degenerate and returns NA for alpha, the likelihood and
every statistic.
Each likelihood is computed over the degrees at or above the
xmin of that fit. With xmin = NULL, the power-law fit uses
the estimated xmin and the other fits use 1, so their AIC values
are computed on different subsets of the degrees. AIC and BIC count one free
parameter per distribution, so the power-law xmin is not penalized.
An object of class "cograph_degree_fit", a list containing:
Named list, one entry per distribution, each with
distribution, parameters (named list of fitted
parameters), loglik, aic, bic, ks_stat
and ks_p. The parameters are alpha and xmin
for the power law, lambda for the exponential and Poisson
fits, and p for the geometric fit.
Data frame sorted by AIC with columns
distribution, aic, bic, ks_stat,
ks_p.
Name of the best-fitting distribution (lowest AIC).
The named degree vector used for fitting.
Printing the result shows the best-fitting distribution, the
comparison table and the fitted parameters of each distribution.
plot() on the result is documented in plot-results.
Clauset, A., Shalizi, C. R., & Newman, M. E. J. (2009). Power-law distributions in empirical data. SIAM Review, 51(4), 661–703.
degree_distribution, centrality
fit_degree_distribution(regulation_net, distributions = c("poisson", "geometric"))fit_degree_distribution(regulation_net, distributions = c("poisson", "geometric"))
Extracts the network, the layout and the plotting arguments from a qgraph
object and passes them to a cograph plotting engine. Node, edge and graph
settings are read from the resolved graphAttributes of the object.
The colors posCol, negCol and the theme are read from
its Arguments.
from_qgraph( qgraph_object, engine = c("splot", "soplot"), plot = TRUE, weight_digits = 2, show_zero_edges = FALSE, preserve_node_size = FALSE, ... )from_qgraph( qgraph_object, engine = c("splot", "soplot"), plot = TRUE, weight_digits = 2, show_zero_edges = FALSE, preserve_node_size = FALSE, ... )
qgraph_object |
Return value of |
engine |
Which cograph renderer to use: |
plot |
Logical. If TRUE (default), immediately plot using the chosen engine. |
weight_digits |
Number of decimal places to round edge weights to. Default 2.
Edges whose weight rounds to zero at this precision are dropped unless
|
show_zero_edges |
Logical. A zero weight means that the edge is
absent, so an edge whose weight rounds to zero at |
preserve_node_size |
Logical. If TRUE, use the node sizes extracted from the qgraph object. Default FALSE uses cograph's standard sizing. |
... |
Overrides for any extracted parameter, given by cograph name
(for example |
The following qgraph parameters are extracted and mapped to their cograph equivalents.
Node properties:
labels/names -> labels
color -> node_fill
width -> node_size (scaled by 1.3x) when
preserve_node_size = TRUE
shape -> node_shape (mapped to cograph equivalents)
border.color -> node_border_color
border.width -> node_border_width
label.cex -> label_size
label.color -> label_color
Edge properties:
labels -> edge_labels
label.cex -> edge_label_size (scaled by 0.5x)
lty -> edge_style (numeric to name conversion)
curve -> curvature (only when qgraph resolved a
single curvature for the whole graph)
asize -> arrow_size (scaled by 0.3x)
edge.label.position -> edge_label_position
Graph properties:
minimum -> threshold
maximum -> maximum
groups -> groups
directed -> directed
posCol/negCol -> edge_positive_color/edge_negative_color
theme -> theme
Pie and donut:
pie values -> donut_fill with
donut_inner_ratio = 0.8 and donut_empty = FALSE
pieColor -> donut_color
The edge colors and widths are not extracted, because qgraph stores them
with its cut-based fading applied. cograph styles the edges by weight
instead. The cut value is not extracted either.
The qgraph layout coordinates are kept with rescale = FALSE. When
layout is supplied in ..., rescale is removed and
the new layout is rescaled.
Invisibly, a named list of plotting parameters (the weight matrix
x, weight_digits, the layout and the extracted node, edge
and graph settings, after the overrides in ...). It can be passed
to splot() with do.call(). An input without an
Arguments field that does not inherit from "qgraph" raises
an error.
cograph for creating networks from scratch,
splot and soplot for plotting engines,
from_tna for tna object conversion
q <- qgraph::qgraph(regulation_net, DoNotPlot = TRUE) from_qgraph(q)q <- qgraph::qgraph(regulation_net, DoNotPlot = TRUE) from_qgraph(q)
Extracts the transition matrix, labels, and initial state probabilities
from a tna object and plots the network with a cograph engine.
Initial probabilities are mapped to donut fills.
from_tna( tna_object, engine = c("splot", "soplot"), plot = TRUE, weight_digits = NULL, show_zero_edges = FALSE, ... )from_tna( tna_object, engine = c("splot", "soplot"), plot = TRUE, weight_digits = NULL, show_zero_edges = FALSE, ... )
tna_object |
A |
engine |
Which cograph renderer to use: |
plot |
Logical. If TRUE (default), immediately plot using the chosen engine. |
weight_digits |
Number of decimal places to round edge weights to.
Default |
show_zero_edges |
Logical. A zero weight means that the edge is
absent, so an edge whose weight rounds to zero at |
... |
Additional parameters passed to the plotting engine (e.g., |
The transition matrix (weights) supplies the edge weights, the state
labels (labels) supply the node labels, and the initial state
probabilities (inits) supply the donut_fill values. The
donuts are plotted with donut_inner_ratio = 0.8.
Directedness is read from the tna object when it is recorded there. Otherwise a symmetric matrix is treated as undirected and an asymmetric matrix as directed.
The following defaults are applied. Each can be overridden through
....
layout = "oval".
node_fill: the RColorBrewer Accent palette for up to 8
states, Set3 for 9 to 12 states, and a qualitative HCL palette for more.
node_size = 7.
edge_color = "#003355".
edge_labels = TRUE, with edge_label_size = 0.4 and
edge_label_position = 0.7.
edge_label_style = "estimate" and
edge_label_leading_zero = FALSE, so a label shows the weight
alone without a leading zero (for example .42).
minimum = 0.01, so transitions weaker than 0.01 are not
plotted.
For directed networks, arrow_size = 0.61,
edge_start_style = "dotted" and edge_start_length = 0.2
(the first 20 percent of each edge is dotted).
Invisibly, a named list of plotting parameters (the weight matrix
x, labels, directed, the donut settings and the
visual defaults above, after the overrides in ...). It can be
passed to splot() with do.call(). An input that is not a
tna object raises an error.
cograph for creating networks from scratch,
splot and soplot for plotting engines,
from_qgraph for qgraph object conversion
from_tna(tna::tna(regulation_net))from_tna(tna::tna(regulation_net))
Extracts the individual-level transition counts of a tna object as an edge list.
get_edge_list(x, by_individual = TRUE, drop_zeros = TRUE)get_edge_list(x, by_individual = TRUE, drop_zeros = TRUE)
x |
A tna object created by |
by_individual |
Logical. If TRUE (default), returns edge list with individual IDs. If FALSE, aggregates across all individuals. |
drop_zeros |
Logical. If TRUE (default), excludes edges with zero count. |
A data frame with columns:
Row number of the individual in the sequence data (only if
by_individual = TRUE).
Source state label.
Target state label.
Number of transitions.
With by_individual = FALSE, the rows are sorted by decreasing count.
extract_motifs() for motif analysis using edge lists
Other motifs:
extract_motifs(),
extract_triads(),
motif_census(),
motifs(),
subgraphs(),
triad_census()
get_edge_list(tna::tna(coding))get_edge_list(tna::tna(coding))
These functions read and replace the parts of a cograph_network
object created by as_cograph. The getters return the node
table, the edge table, the node labels, the node groups, the source type,
the stored estimation data, the metadata list, and the counts of nodes and
edges. The setters return a modified copy of the network.
get_nodes(x) get_edges(x) get_labels(x) get_source(x) get_data(x) get_meta(x) set_nodes(x, nodes_df) set_edges(x, edges_df) set_layout(x, layout_df) set_groups( x, groups = NULL, type = c("group", "cluster", "layer"), nodes = NULL, layers = NULL, clusters = NULL ) get_groups(x) nodes(x) is_directed(x) n_nodes(x) n_edges(x)get_nodes(x) get_edges(x) get_labels(x) get_source(x) get_data(x) get_meta(x) set_nodes(x, nodes_df) set_edges(x, edges_df) set_layout(x, layout_df) set_groups( x, groups = NULL, type = c("group", "cluster", "layer"), nodes = NULL, layers = NULL, clusters = NULL ) get_groups(x) nodes(x) is_directed(x) n_nodes(x) n_edges(x)
x |
A |
nodes_df |
A data frame of node information. A missing |
edges_df |
A data frame with columns |
layout_df |
A data frame with |
groups |
Node groupings in one of these formats:
|
type |
Group type stored by |
nodes |
Character vector of node labels, used with |
layers |
Character or factor vector of layer assignments, the same
length as |
clusters |
Character or factor vector of cluster assignments, the same
length as |
get_nodes(), nodes()
The node table, with id
and label columns plus layout coordinates or other metadata
columns when present. nodes() is a deprecated alias of
get_nodes() and signals a deprecation warning.
get_edges()A data frame with one row per edge and columns
from and to (integer row numbers into the node table),
weight, and any extra edge columns. An undirected network stores
one row per unordered pair. as.data.frame()
returns the same table with node labels as endpoints.
get_labels()A character vector of node labels.
get_groups()A data frame with a node column and one
of layer, cluster or group, or NULL when no
groups are set.
get_source()A character string naming the input type (for
example "matrix", "tna", "igraph",
"edgelist"), or "unknown".
get_data()The original estimation data (for example the
sequence data of a tna model), or NULL when none is stored.
get_meta()A list with component source (input
type). Networks built from a tna model also carry tna (type,
group name and group index).
n_nodes(), n_edges()
An integer count. Each undirected edge counts once.
is_directed()A single logical value.
set_nodes(), set_edges(), set_layout(),
set_groups()
The modified cograph_network.
set_layout() writes the coordinates into the x and
y columns of the node table. set_groups() stores the
grouping as node_groups for use by the group-aware plot
functions. It stops with an error when a node is assigned twice, when
a node is missing from the assignment or unknown to the network, and
when fewer than two groups result. set_edges() raises an error
of class cograph_bad_selection for endpoints outside the node
table and for duplicated edges.
as_cograph, splot,
detect_communities
net <- as_cograph(regulation_net) get_edges(net)net <- as_cograph(regulation_net) get_edges(net)
Plots robustness curves for one or more networks with ggplot2, with one facet per network and one line per attack strategy.
ggplot_robustness( ..., networks = NULL, measures = c("betweenness", "degree", "random"), strategy = "sequential", colors = NULL, title = NULL, n_iter = 1000, seed = NULL, type = "vertex", ncol = NULL, free_y = FALSE )ggplot_robustness( ..., networks = NULL, measures = c("betweenness", "degree", "random"), strategy = "sequential", colors = NULL, title = NULL, n_iter = 1000, seed = NULL, type = "vertex", ncol = NULL, free_y = FALSE )
... |
Networks, with network names as argument names. Unnamed networks are labelled "Network 1", "Network 2", and so on. |
networks |
Named list of networks, used when |
measures |
Attack strategies to compare. Default c("betweenness", "degree", "random"). |
strategy |
Character string; "sequential" (default) recalculates centrality after each removal, "static" uses initial centrality ranking throughout. |
colors |
Vector of colors named "Betweenness", "Degree" and "Random". Default NULL uses red, green and blue. |
title |
Overall title. Default NULL. With a single network the title
is replaced by " |
n_iter |
Iterations for random. Default 1000. |
seed |
Random seed. Default NULL. |
type |
Removal type. Default "vertex". |
ncol |
Columns in facet. Default NULL (auto). |
free_y |
If TRUE, allow different y-axis scales per facet. Default FALSE. |
A ggplot object.
ggplot_robustness(regulation = regulation_net, n_iter = 20, seed = 1)ggplot_robustness(regulation = regulation_net, n_iter = 20, seed = 1)
Computes the centrality of a set of nodes . Distances
are unweighted hop counts in the direction of the edges. The measures are
defined as follows.
group_centrality( x, nodes, measure = c("betweenness", "closeness", "degree"), mode = c("all", "out", "in"), normalized = TRUE )group_centrality( x, nodes, measure = c("betweenness", "closeness", "degree"), mode = c("all", "out", "in"), normalized = TRUE )
x |
Network input (matrix, igraph, network, cograph_network, tna object). |
nodes |
Integer vector of node indices (1-based) or character vector
of node names identifying the group |
measure |
One of |
mode |
For directed graphs with |
normalized |
Logical, for |
, where is the
number of shortest - paths and
is the number of those paths passing through at least one node in
. Normalized by .
, where is the shortest
distance from to any group member. Unreachable nodes
contribute 0 to the denominator sum. For directed graphs,
follows the edges from to .
, the
fraction of non-group nodes adjacent to at least one group member.
For directed graphs, mode selects the neighborhood.
Numeric scalar: the group centrality of the set nodes.
Unknown node names and out-of-range indices raise an error.
Group betweenness is computed directly from the Everett and Borgatti
definition, counting the shortest paths that pass through at least one
node in . On some graphs the result differs from
networkx.group_betweenness_centrality, which uses the iterative
algorithm of Puzis, Elovici and Dolev.
Everett, M. G., & Borgatti, S. P. (1999). The centrality of groups and classes. Journal of Mathematical Sociology, 23(3), 181-201.
Puzis, R., Elovici, Y., & Dolev, S. (2007). Fast algorithm for successive computation of group betweenness centrality. Physical Review E, 76, 056709. doi:10.1103/PhysRevE.76.056709.
centrality for per-node measures.
group_centrality(regulation_net, nodes = c("Plan", "Monitor"), measure = "betweenness")group_centrality(regulation_net, nodes = c("Plan", "Monitor"), measure = "betweenness")
Coded sequences of human-AI programming interactions from 34 projects
across 429 sessions. Actions are coded at two granularity levels
(broad categories and fine-grained codes) and split by actor
(human, AI, or both combined). The AI datasets contain 428 sessions. Each row is one session and every column is
a time step: the columns are named T1, T2, ... Tn and hold the sequential
actions. NA indicates the session ended before that time step.
coding coding_detailed ai_coding ai_detailed human_ai human_ai_detailedcoding coding_detailed ai_coding ai_detailed human_ai human_ai_detailed
429 x 164 data.frame. Human actions by category (9 states: Command, Correct, Frustrate, Inquire, Interrupt, Refine, Request, Specify, Verify).
429 x 164 data.frame. Human actions by fine-grained code (15 states: Accept, Arguing, Ask, Command, Context, Correction, Direct, Frustration, Interrupt, Refinement, Reject, Request, Specification, Thinking, Verification).
428 x 138 data.frame. AI actions by category (8 states: Ask, Delegate, Execute, Explain, Investigate, Plan, Repair, Report).
428 x 138 data.frame. AI actions by fine-grained code (18 states: Acknowledge, Apologize, Ask, Comply, Delegate, Diagnose, Escape, Execute, Explain, Hedge, Investigate, Plan, Refuse, Report, Retry, Scaffold, Suggest, Warn).
429 x 287 data.frame. Both actors combined, by category (17 states).
429 x 287 data.frame. Both actors combined, by fine-grained code (32 states).
An object of class data.frame with 429 rows and 164 columns.
An object of class data.frame with 429 rows and 164 columns.
An object of class data.frame with 428 rows and 138 columns.
An object of class data.frame with 428 rows and 138 columns.
An object of class data.frame with 429 rows and 287 columns.
An object of class data.frame with 429 rows and 287 columns.
Each dataset is a data.frame with one row per session and
one character column per time step (T1, T2, ... Tn). It has no
identifier columns.
Human-AI programming interaction study, 34 projects, 429 sessions.
data(coding) str(coding, list.len = 6) dim(coding)data(coding) str(coding, list.len = 6) dim(coding)
Turns strong ties into short distances. Path-based measures treat weights as costs, so similarity weights are inverted before such measures are computed.
invert_weights( x, method = c("reciprocal", "max_minus", "reflect"), keep_format = FALSE, directed = NULL )invert_weights( x, method = c("reciprocal", "max_minus", "reflect"), keep_format = FALSE, directed = NULL )
x |
Network input. |
method |
How to invert:
|
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network with inverted weights, or the input format
when keep_format = TRUE.
normalize_weights, shortest_paths
invert_weights(regulation_net, method = "reciprocal")invert_weights(regulation_net, method = "reciprocal")
Tests whether a matrix could represent a bipartite incidence matrix. A non-square matrix is considered bipartite by default. For square matrices, checks whether the corresponding graph has bipartite structure (i.e., nodes can be partitioned into two groups with edges only between groups).
is_bipartite(x)is_bipartite(x)
x |
A numeric matrix. |
For non-square matrices, returns TRUE since they naturally represent
two-mode data (rows and columns are distinct node types).
For square matrices, the function checks whether the corresponding
undirected graph is bipartite by attempting a two-coloring via
igraph::bipartite_mapping() when igraph is available. Without igraph,
it uses a breadth-first two-coloring. Positive entries define the edges,
edge direction is ignored, and the diagonal (self-loops) is dropped before
the check.
Logical. TRUE if the matrix could represent a bipartite
network, FALSE otherwise.
inc <- matrix(c(1, 0, 1, 1, 1, 0), 2, 3) cograph::is_bipartite(inc)inc <- matrix(c(1, 0, 1, 1, 1, 0), 2, 3) cograph::is_bipartite(inc)
Checks whether a cograph_network was created from a tna object, such as one model of a group_tna object.
is_tna_network(x)is_tna_network(x)
x |
A CographNetwork or cograph_network object. |
Logical. TRUE if the network was created from a tna object,
FALSE otherwise, including for any input that is not a network.
is_tna_network(as_cograph(regulation_net))is_tna_network(as_cograph(regulation_net))
Computes up to k shortest loopless paths between two nodes using
Yen's algorithm. Each path is a sequence of distinct nodes from source to
target.
k_shortest_paths(x, from, to, k = 3, weights = NULL, directed = NULL, ...)k_shortest_paths(x, from, to, k = 3, weights = NULL, directed = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
from |
Character or numeric node identifier for the source node. |
to |
Character or numeric node identifier for the target node. |
k |
Integer; number of shortest paths to find. Default 3. |
weights |
Edge weight handling: NULL (default) auto-detects from edge attributes, NA forces unweighted distances, or a numeric vector of custom weights. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
... |
Not used. Any argument supplied here raises an
|
Yen's algorithm finds the k shortest loopless (simple) paths in a graph. It works by:
Finding the shortest path via Dijkstra's algorithm
For each subsequent path, systematically exploring deviations from previously found paths by temporarily removing edges, finding spur paths, and selecting the shortest candidate
The algorithm may return fewer than k paths if fewer distinct loopless
paths exist between the two nodes.
A list with class "cograph_k_paths" containing:
List of up to k character vectors, each containing node
names in path order
Numeric vector of path lengths (sum of edge weights or hop count)
Source node name
Target node name
Number of paths requested
Yen, J.Y. (1971). Finding the K shortest loopless paths in a network. Management Science, 17(11), 712-716. doi:10.1287/mnsc.17.11.712
cograph::k_shortest_paths(regulation_net, from = "Plan", to = "Share", k = 3)cograph::k_shortest_paths(regulation_net, from = "Plan", to = "Share", k = 3)
Measures the consistency of hubs across layers as the Pearson correlation of node degrees between layers.
layer_degree_correlation(layers, mode = c("total", "in", "out")) ldegcor(layers, mode = c("total", "in", "out"))layer_degree_correlation(layers, mode = c("total", "in", "out")) ldegcor(layers, mode = c("total", "in", "out"))
layers |
List of adjacency matrices of the same dimensions |
mode |
Degree type: "total" (default, row plus column sums), "in" (column sums) or "out" (row sums). The sums use the edge weights, so on a weighted layer the degree is the node strength. |
An L x L Pearson correlation matrix of the layer degree sequences,
with the layer names (or "Layer1", "Layer2", ...) as
dimnames.
layers <- list(forward = regulation_net, backward = t(regulation_net)) layer_degree_correlation(layers, mode = "total")layers <- list(forward = regulation_net, backward = t(regulation_net)) layer_degree_correlation(layers, mode = "total")
Computes similarity between two network layers.
layer_similarity( A1, A2, method = c("jaccard", "overlap", "hamming", "cosine", "pearson") ) lsim(A1, A2, method = c("jaccard", "overlap", "hamming", "cosine", "pearson"))layer_similarity( A1, A2, method = c("jaccard", "overlap", "hamming", "cosine", "pearson") ) lsim(A1, A2, method = c("jaccard", "overlap", "hamming", "cosine", "pearson"))
A1 |
First adjacency matrix |
A2 |
Second adjacency matrix, with the same dimensions as |
method |
Comparison method: "jaccard" (default), "overlap", "hamming", "cosine" or "pearson" |
"jaccard", "overlap" and "hamming" compare edge
presence (A > 0) and ignore weights. "cosine" and
"pearson" are computed on the cell values, diagonal included.
Matrices of different dimensions raise an error.
A single numeric value. All methods except "hamming" return a
similarity, where higher values mean more alike layers. "hamming"
returns a distance, the number of matrix cells whose edge presence
differs between the two layers. Lower values then mean more alike layers,
and the value is not bounded by 1. NA is returned when the
denominator is undefined
("jaccard" with no edges in either layer, "overlap" with an
empty layer, "cosine" with an all-zero layer).
layer_similarity(regulation_net, t(regulation_net), method = "cosine")layer_similarity(regulation_net, t(regulation_net), method = "cosine")
Computes the similarity of every pair of layers with
layer_similarity.
layer_similarity_matrix( layers, method = c("jaccard", "overlap", "cosine", "pearson") ) lsim_matrix(layers, method = c("jaccard", "overlap", "cosine", "pearson"))layer_similarity_matrix( layers, method = c("jaccard", "overlap", "cosine", "pearson") ) lsim_matrix(layers, method = c("jaccard", "overlap", "cosine", "pearson"))
layers |
Named list of adjacency matrices (one per layer); at least two are required. |
method |
Comparison method: "jaccard" (default), "overlap", "cosine" or
"pearson". The |
A symmetric L x L matrix of pairwise similarities with 1 on the
diagonal. The dimnames are the layer names, or "Layer1",
"Layer2", ... for an unnamed list.
layers <- list(forward = regulation_net, backward = t(regulation_net)) layer_similarity_matrix(layers, method = "cosine")layers <- list(forward = regulation_net, backward = t(regulation_net)) layer_similarity_matrix(layers, method = "cosine")
Places the nodes at evenly spaced positions on a circle of radius 0.4 centered at (0.5, 0.5). A single node is placed at the center.
layout_circle(network, order = NULL, start_angle = pi/2, clockwise = TRUE, ...)layout_circle(network, order = NULL, start_angle = pi/2, clockwise = TRUE, ...)
network |
A |
order |
Optional vector of node indices or labels. Its i-th element is
the node placed at the i-th position. Labels are matched only for a
|
start_angle |
Angle in radians of the reference position. Default
|
clockwise |
Logical. Default |
... |
Ignored. |
A data frame with columns x and y and one row per
node, in node order.
layout_circle(CographNetwork$new(regulation_net))layout_circle(CographNetwork$new(regulation_net))
Places the nodes by group membership. The group centers lie on a circle around (0.5, 0.5), starting at the top and proceeding counterclockwise in the order of the group levels. A single group is centered at (0.5, 0.5). The nodes of each group lie on a circle around their group center, and a group with one node is placed at its center.
layout_groups( network, groups, group_positions = NULL, inner_radius = 0.15, outer_radius = 0.35 )layout_groups( network, groups, group_positions = NULL, inner_radius = 0.15, outer_radius = 0.35 )
network |
A |
groups |
Vector of group memberships, one per node (numeric, character, or factor). A length different from the number of nodes raises an error. |
group_positions |
Optional list or data frame with columns |
inner_radius |
Radius of the circle of nodes within each group. Default 0.15. |
outer_radius |
Radius of the circle of group centers. Default 0.35. |
A data frame with columns x and y and one row per
node, in node order.
layout_groups(CographNetwork$new(regulation_net), groups = rep(c("A", "B"), each = 5))layout_groups(CographNetwork$new(regulation_net), groups = rep(c("A", "B"), each = 5))
Arrange nodes evenly spaced around an ellipse. This creates an oval-shaped network layout that is wider than it is tall (or vice versa depending on ratio).
layout_oval( network, ratio = 1.5, order = NULL, start_angle = pi/2, clockwise = TRUE, rotation = 0, ... )layout_oval( network, ratio = 1.5, order = NULL, start_angle = pi/2, clockwise = TRUE, rotation = 0, ... )
network |
A CographNetwork or cograph_network object. |
ratio |
Aspect ratio (width/height). Values > 1 create horizontal ovals, values < 1 create vertical ovals. Default 1.5. |
order |
Optional vector specifying node order, as node indices or as
node labels. Labels are matched for both |
start_angle |
Starting angle in radians (default: pi/2 for top). |
clockwise |
Logical. Arrange nodes clockwise? Default TRUE. |
rotation |
Rotation angle in radians to tilt the entire oval. Default 0. |
... |
Additional arguments (ignored). |
Data frame with x, y coordinates.
layout_oval(CographNetwork$new(regulation_net), ratio = 1.5)layout_oval(CographNetwork$new(regulation_net), ratio = 1.5)
Layout algorithms are stored in a registry and selected by name through the
layout argument of splot, soplot and
sn_layout. register_layout() adds a layout function,
get_layout() returns the function of a registered layout, and
list_layouts() returns the names of all registered layouts.
Registering an existing name replaces that layout for the rest of the
session.
register_layout(name, layout_fn) get_layout(name) list_layouts()register_layout(name, layout_fn) get_layout(name) list_layouts()
name |
Character. The name of the layout. |
layout_fn |
A function that computes node positions. It receives the
network as the argument |
register_layout() returns NULL invisibly.
get_layout() returns the layout function, or NULL if no
layout has that name. list_layouts() returns a character vector of
layout names.
layout_circle, layout_spring,
layout_groups, layout_oval
list_layouts() splot(regulation_net, layout = "circle")list_layouts() splot(regulation_net, layout = "circle")
Places the nodes of a directed transition network in rows between a Start and an End node (Saqr et al., LAK25). The Start node is alone on the top row and the End node, when present, is alone on the bottom row. The other nodes are ranked by the weight of the edge they receive from Start, with the strongest nearest Start. They are split into two middle rows when there are at most 10 of them and into three rows otherwise. A sine envelope narrows the rows near Start and End, which gives the layout a lens shape. The first middle row is offset in a zig-zag pattern.
layout_saqr(network, start = "Start", end = "End", jitter = 0.32, ...)layout_saqr(network, start = "Start", end = "End", jitter = 0.32, ...)
network |
A |
start |
Label of the Start node (default |
end |
Label of the End node (default |
jitter |
Numeric in |
... |
Additional arguments (ignored). |
Data frame with x, y coordinates, one row per node.
layout_saqr(CographNetwork$new(regulation_net), start = "Explore", end = "Share")layout_saqr(CographNetwork$new(regulation_net), start = "Explore", end = "Share")
Computes node positions with the Fruchterman-Reingold force-directed algorithm. Nodes connected by edges attract each other and all nodes repel each other. Attraction along an edge is scaled by the absolute edge weight. Duplicate edges between the same pair of nodes, in either direction, are merged by summing their weights.
layout_spring( network, iterations = 200, cooling = 0.95, repulsion = 1.5, attraction = 1, seed = NULL, initial = NULL, max_displacement = NULL, anchor_strength = 0, area = 1.5, gravity = 0, init = c("random", "circular"), cooling_mode = c("exponential", "vcf", "linear"), ... )layout_spring( network, iterations = 200, cooling = 0.95, repulsion = 1.5, attraction = 1, seed = NULL, initial = NULL, max_displacement = NULL, anchor_strength = 0, area = 1.5, gravity = 0, init = c("random", "circular"), cooling_mode = c("exponential", "vcf", "linear"), ... )
network |
A |
iterations |
Number of iterations (default: 200). |
cooling |
Factor by which the temperature is multiplied after each
iteration when |
repulsion |
Repulsion constant (default: 1.5). |
attraction |
Attraction constant (default: 1). |
seed |
Random seed for the random initial positions. NULL (default) uses the current random state. When a seed is given, the caller's random state is restored on exit. |
initial |
Optional initial coordinates, a matrix or a data frame with
columns |
max_displacement |
Maximum distance a node can move from its initial
position (default: NULL, no limit). Applies only when |
anchor_strength |
Strength of the force pulling nodes toward their
initial positions (default: 0). Higher values (for example 0.5 to 2) keep
nodes closer to their starting positions. Applies only when
|
area |
Area parameter (default: 1.5). It sets the ideal edge length
|
gravity |
Strength of the force pulling nodes toward the centroid of the layout (default: 0). Higher values (for example 0.5 to 2) give a more compact layout. |
init |
Initialization method, |
cooling_mode |
Cooling schedule. |
... |
Additional arguments (ignored). |
A data frame with columns x and y and one row per
node. The coordinates are centered on their mean and scaled by a common
factor into , which preserves the aspect ratio of the
layout. A
network without edges returns the initial positions, and a single node is
placed at (0.5, 0.5).
layout_spring(CographNetwork$new(regulation_net), seed = 42)layout_spring(CographNetwork$new(regulation_net), seed = 42)
Adapts the flow() layout of qgraph. One node of interest (the
target) is placed alone, and every other node is placed in successive
levels ordered by its unweighted graph distance (number of hops) from the
target. Edge direction is ignored. The layout shows how the target node
connects to the rest of the network.
layout_target(network, target = NULL, horizontal = TRUE, equalize = TRUE, ...)layout_target(network, target = NULL, horizontal = TRUE, equalize = TRUE, ...)
network |
A |
target |
Node of interest, given as a label (character) or 1-based
index. When |
horizontal |
Logical. If |
equalize |
Logical. If |
... |
Additional arguments (ignored). |
Weights are binarized for layering, so only connectivity matters. Nodes that cannot be reached from the target are placed in one extra level after the last. qgraph raises an error for such nodes.
Data frame with x, y coordinates, one row per node.
layout_target(CographNetwork$new(regulation_net), target = "Plan")layout_target(CographNetwork$new(regulation_net), target = "Plan")
Returns a table of every measure centrality can compute.
For each measure the table records which end of the scale marks a
prominent node, whether the measure accepts mode, whether it
requires a community partition, whether it uses edge weights, and
whether type = "all" holds it back because its cost grows
steeply with network size.
list_centralities(orientation = NULL, costly = NULL, needs_membership = NULL)list_centralities(orientation = NULL, costly = NULL, needs_membership = NULL)
orientation |
Keep only measures with this orientation:
|
costly |
Keep only costly measures ( |
needs_membership |
Keep only measures that require a partition
( |
For some measures a low value marks the more central node, so a
descending sort of their column places the most peripheral nodes first.
orientation = "lower" lists them.
A data.frame with one row per measure and the columns
measure (the name to pass to centrality(measures = )),
orientation ("higher" or "lower", which end of
the scale marks a prominent node), mode_aware (whether the
measure accepts mode and its column carries a mode suffix),
needs_membership, uses_weights, and costly
(held back from type = "all"; add it with
include = ). Rows are ordered by measure name.
centrality to compute them,
centrality_degree and the other one-measure verbs.
list_centralities(orientation = "lower")list_centralities(orientation = "lower")
Extracts a named membership vector from a cograph_communities
data frame or an igraph communities object.
membership(x)membership(x)
x |
A |
A numeric vector of community numbers named by node. For an igraph
object it is the igraph membership vector.
comm <- community_walktrap(regulation_net) membership(comm)comm <- community_walktrap(regulation_net) membership(comm)
Counts the subgraph classes (motifs) of size 3 or 4 in a network and tests their frequencies against random networks from a null model. Edge weights are ignored, and self-loops and multiple edges are removed before counting.
motif_census( x, size = 3, n_random = 100, method = c("configuration", "gnm"), directed = NULL, seed = NULL )motif_census( x, size = 3, n_random = 100, method = c("configuration", "gnm"), directed = NULL, seed = NULL )
x |
A matrix, igraph object, or cograph_network. |
size |
Motif size: 3 (triads) or 4 (tetrads). Default 3. |
n_random |
Number of random networks for the null model. Must be a whole number of at least 2. Default 100. |
method |
Null model method. |
directed |
Logical or NULL. Whether the network is treated as directed. NULL (default) treats a matrix as directed when it is not symmetric and takes the directedness of an igraph or cograph_network input. A value that conflicts with an igraph or cograph_network input raises an error. |
seed |
Random seed for reproducibility. Default NULL. When supplied, the caller's RNG state is saved and restored. |
Printing the result shows the motif table with the null-model
settings and the number of over- and under-represented motifs. The result
is a data frame and serves as the tidy table directly. plot() on the
result is documented in plot-results.
A cograph_motifs data frame with one row per motif class and
columns:
Motif class name. Directed triads use the 16 MAN codes,
undirected triads the classes empty, edge,
wedge and triangle, and size 4 the igraph isomorphism
class labels M1 to M218 (directed) or M1 to
M11 (undirected).
Observed number of that motif in the network.
Mean and standard deviation of the count
across the n_random null graphs.
(count - null_mean) / null_sd. When
null_sd = 0, it is 0 if the count equals the null mean and
NA otherwise.
Two-sided empirical permutation p-value with add-one correction, based on the absolute deviation from the null mean.
Logical, p_value < 0.05.
The motif size ("size"), directed flag ("directed"),
null-model method ("method"), and number of random networks
("n_random") are stored as attributes.
motifs() for the unified API, extract_motifs() for detailed
triad extraction, plot-results for plotting
Other motifs:
extract_motifs(),
extract_triads(),
get_edge_list(),
motifs(),
subgraphs(),
triad_census()
motif_census(regulation_net, n_random = 20, seed = 1)motif_census(regulation_net, n_random = 20, seed = 1)
Classifies the node triples of a network into the 16 directed MAN triad types and tests their frequencies against a permutation null. The function has two modes.
In census mode (named_nodes = FALSE, the default), the result
counts the triads of each MAN type. Nodes are exchangeable.
In instance mode (named_nodes = TRUE, or subgraphs()),
the result lists the node triples that form each type.
motifs( x, named_nodes = FALSE, actor = NULL, window = NULL, window_type = c("rolling", "tumbling"), pattern = c("triangle", "network", "closed", "all"), include = NULL, exclude = NULL, significance = TRUE, n_perm = 1000L, cores = 1L, min_count = if (named_nodes) 5L else NULL, edge_method = c("any", "expected", "percent"), edge_threshold = 1.5, min_transitions = 5, top = NULL, seed = NULL ) ## S3 method for class 'cograph_motif_result' as.data.frame( x, row.names = NULL, optional = FALSE, ..., what = c("results", "types") )motifs( x, named_nodes = FALSE, actor = NULL, window = NULL, window_type = c("rolling", "tumbling"), pattern = c("triangle", "network", "closed", "all"), include = NULL, exclude = NULL, significance = TRUE, n_perm = 1000L, cores = 1L, min_count = if (named_nodes) 5L else NULL, edge_method = c("any", "expected", "percent"), edge_threshold = 1.5, min_transitions = 5, top = NULL, seed = NULL ) ## S3 method for class 'cograph_motif_result' as.data.frame( x, row.names = NULL, optional = FALSE, ..., what = c("results", "types") )
x |
Input data: a tna object, cograph_network, matrix, igraph object or
edge-list data frame. For |
named_nodes |
Logical. If FALSE (default), the MAN type census is
computed. If TRUE, the individual node triples are listed.
|
actor |
Character. Name of the edge-list column that identifies the
units. If NULL (default), the first column named |
window |
Numeric. Window size for edge-list input. Each actor's transitions are split into windows of this size. NULL (default) applies no windowing. |
window_type |
Character. |
pattern |
Which MAN triad types to include in the analysis:
|
include |
Character vector of MAN types to keep. When supplied,
|
exclude |
Character vector of MAN types to drop in addition to those
removed by |
significance |
Logical. If TRUE (default), a permutation significance test is run. In instance mode the test requires individual data, and for aggregate input it is skipped with a warning. |
n_perm |
Number of permutations for significance. When
|
cores |
Number of worker processes for the permutation null. Default
1 runs serially and draws all replicates from a single RNG stream.
|
min_count |
Inclusive minimum count for a row to be kept. In census
mode it filters the |
edge_method |
Method for determining edge presence: |
edge_threshold |
Threshold for |
min_transitions |
Minimum total edge weight for a unit to be included. Default 5. At aggregate level the network is the only unit, so a network whose weights sum to less than this value gives NULL. |
top |
Integer or NULL. Only the first |
seed |
Random seed. Default NULL. When supplied, the caller's RNG state is restored on exit. |
row.names, optional
|
Standard |
... |
Unused. |
what |
Which table |
The input type and the analysis level are detected automatically. Inputs
that carry per-unit data are analyzed per unit. These are tna objects,
networks that store tna sequence data, and edge lists (or networks built
from edge lists) with an actor column. Matrices, igraph objects and other
networks are analyzed as one aggregate network. The adjacency is always
classified as directed. The four-class undirected census is computed by
motif_census(..., directed = FALSE).
For aggregate inputs, significance is computed by motif_census()
with its degree-preserving rewiring null on the simple loop-free graph.
Individual weighted inputs use a directed stub-matching null. Each positive
edge weight is converted to at least one integer stub, and target stubs are
shuffled within each unit so that its integer in- and out-margins are
preserved. The resulting multigraph, which may contain loops or parallel
edges, is classified through its simple loop-free triad projection.
Self-loops are removed before counting and before the null is constructed.
With edge_method = "percent", edge presence is computed within each
node triple. The weight of an edge is divided by the sum of the six possible
directed edge weights of that triple. A threshold above 1 is read as a
percentage (1.5 means 1.5 percent), and a threshold at or below 1 is read
as a proportion.
With an edge_method other than "any", the significance test
has limits. For aggregate census input, the observed counts use the
threshold while the null tests the unthresholded network, and a warning is
raised. For individual census input, the threshold is reapplied to each
stub-null replicate. For individual instance input, the null classifies raw
stub presence and does not reapply edge_method or
edge_threshold. In every weighted individual null, a positive
fractional weight keeps at least one stub. This preserves the support but
can change the weight scale used by "percent" and "expected".
Descriptive results with significance = FALSE or
edge_method = "any" are unaffected.
A cograph_motif_result object, or NULL with a message when no
motif passes the filters. The object is a list with the elements below.
Data frame of results. In census mode it has one row per
retained, observed MAN type and the columns type and
count. In instance mode it has one row per node triple and MAN
type and the columns triad, node1, node2,
node3, type and observed. At individual level,
observed is the number of units in which the triple has that
type, so one triple can occupy several rows. With
significance = TRUE, the columns expected, z,
p and sig are added and the rows are sorted by
decreasing absolute z-score. Otherwise the rows are sorted by
decreasing count.
Named table of counts per MAN type, sorted in
decreasing order. In census mode it holds the count column. In
instance mode it holds the number of node triples of each type.
"individual" when the input carried per-unit data,
otherwise "aggregate".
The value of the named_nodes argument.
Number of units analyzed. 1 at aggregate level.
List of the analysis settings: labels,
n_states, pattern, edge_method,
edge_threshold, significance, n_perm,
min_count, window, window_type and
actor.
as.data.frame() returns one of these tables as a plain data frame.
With what = "results" (default) it returns the results
table described above. With what = "types" it returns one row per
MAN type with columns type and count, where count is
the number of triads of that type in a census or the number of node
triples of that type in instance mode.
Printing the result shows the analysis settings, the MAN type distribution
and the first 20 rows of the results table. as.data.frame() returns
the tidy tables. plot() on the result is documented in
plot-results.
subgraphs(), motif_census(), extract_motifs()
Other motifs:
extract_motifs(),
extract_triads(),
get_edge_list(),
motif_census(),
subgraphs(),
triad_census()
census <- motifs(regulation_net, significance = FALSE) as.data.frame(census, what = "types")census <- motifs(regulation_net, significance = FALSE) as.data.frame(census, what = "types")
Evaluates expressions against the edge table and stores the results as edge columns.
mutate_edges( x, ..., community = "louvain", keep_format = FALSE, directed = NULL )mutate_edges( x, ..., community = "louvain", keep_format = FALSE, directed = NULL )
x |
Network input. |
... |
Named expressions evaluated against the edge table, with the same
metrics and predicates |
community |
Community detection method used when an expression refers
to |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network whose edge table has the new columns, or
the input format when keep_format = TRUE.
as.data.frame(mutate_edges(regulation_net, strong = weight > 0.2))as.data.frame(mutate_edges(regulation_net, strong = weight > 0.2))
Evaluates expressions against the node table, with the same centrality and
structural vocabulary that select_nodes() offers, and stores
the results as node columns.
mutate_nodes(x, ..., keep_format = FALSE, directed = NULL)mutate_nodes(x, ..., keep_format = FALSE, directed = NULL)
x |
Network input. |
... |
Named expressions, for example |
keep_format |
Logical. Return the input format when TRUE. Note that only igraph and cograph_network formats can carry node attributes; a matrix cannot, and the new columns are lost. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network whose node table has the new columns, or
the input format when keep_format = TRUE.
mutate_edges, select_nodes,
centrality
as.data.frame(mutate_nodes(regulation_net, deg = degree), what = "nodes")as.data.frame(mutate_nodes(regulation_net, deg = degree), what = "nodes")
Get Number of Communities
n_communities(x)n_communities(x)
x |
A |
A single integer, the number of distinct communities.
comm <- community_walktrap(regulation_net) n_communities(comm)comm <- community_walktrap(regulation_net) n_communities(comm)
Convenience wrapper around edge_centrality that returns only
the overlap measure sorted by overlap descending.
neighborhood_overlap(x, top = NULL, directed = NULL, digits = NULL, ...)neighborhood_overlap(x, top = NULL, directed = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
top |
Integer or NULL. Return only the top N edges. Default NULL. |
directed |
Logical or NULL. Default NULL (auto-detect). |
digits |
Integer or NULL. Round numeric columns. Default NULL. |
... |
Additional arguments passed to |
A data frame sorted by overlap (descending) with columns:
from, to, weight, overlap,
shared_neighbors.
edge_centrality, simmelian_strength
cograph::neighborhood_overlap(regulation_net, top = 5)cograph::neighborhood_overlap(regulation_net, top = 5)
Finds edges whose removal would disconnect the network. These are critical edges for network connectivity.
network_bridges(x, count_only = FALSE, ...)network_bridges(x, count_only = FALSE, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
count_only |
Logical. If TRUE, return only the count. Default FALSE. |
... |
Passed to |
If count_only = FALSE, a data frame with one row per bridge
and columns from and to (node names, or integer indices
when the graph has no names). If count_only = TRUE, an integer
count.
strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) network_bridges(strong)strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) network_bridges(strong)
Computes the size of the largest clique (complete subgraph) in the network, also called the clique number or omega of the graph.
network_clique_size(x, ...)network_clique_size(x, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
... |
Passed to |
A clique is defined on undirected ties, so a directed network is read with each pair of nodes joined when either direction is present, and loops and repeated edges are dropped before counting.
Numeric scalar: the size of the largest clique.
network_clique_size(regulation_net)network_clique_size(regulation_net)
Finds nodes whose removal would disconnect the network. These are critical nodes for network connectivity.
network_cut_vertices(x, count_only = FALSE, ...)network_cut_vertices(x, count_only = FALSE, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
count_only |
Logical. If TRUE, return only the count. Default FALSE. |
... |
Passed to |
If count_only = FALSE, a character vector of node names, or
an integer vector of node indices when the graph has no names. If
count_only = TRUE, an integer count.
strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) network_cut_vertices(strong)strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) network_cut_vertices(strong)
Computes the girth of a network, the length of its shortest cycle. Edge direction, self-loops and repeated undirected edges are ignored. A pair of reciprocal directed edges counts as a cycle of length 2, so a directed network with any mutual tie has girth 2. An undirected forest has girth Inf.
network_girth(x, ...)network_girth(x, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
... |
Passed to |
Numeric scalar: the length of the shortest cycle, or Inf if the graph has no cycle.
network_girth(regulation_net)network_girth(regulation_net)
Computes the global efficiency of a network, the average of the inverse
shortest path lengths between all ordered pairs of distinct nodes. Higher
values indicate more efficient global communication. Unreachable pairs
contribute 0. A graph with fewer than two nodes returns NA.
network_global_efficiency( x, directed = NULL, weights = NULL, invert_weights = NULL, alpha = 1, ... )network_global_efficiency( x, directed = NULL, weights = NULL, invert_weights = NULL, alpha = 1, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
directed |
Logical or NULL. Consider edge direction? Default NULL, which follows the directedness of the converted graph. |
weights |
Numeric vector of edge weights. Default NULL uses the
graph's |
invert_weights |
Logical or NULL. If TRUE, weights are converted to
distances as |
alpha |
Numeric. Exponent for weight inversion. Default 1. |
... |
Passed to |
Numeric scalar: the global efficiency. For unweighted simple graphs
it lies in . Weighted graphs can exceed 1 when edge distances
are below 1.
network_global_efficiency(regulation_net)network_global_efficiency(regulation_net)
Computes the average local efficiency across all nodes with
igraph::average_local_efficiency(). For each node, igraph removes
the node and measures the distances between its neighbors through the rest
of the network. The value can therefore exceed the Latora and Marchiori
(2001) form, which restricts those distances to the subgraph induced on the
neighbors. centrality(x, measures = "local_efficiency") reports the
induced-subgraph form. The two agree when the neighbors have no path
outside their induced subgraph.
network_local_efficiency( x, weights = NULL, invert_weights = NULL, alpha = 1, ... )network_local_efficiency( x, weights = NULL, invert_weights = NULL, alpha = 1, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
weights |
Numeric vector of edge weights. Default NULL uses the
graph's |
invert_weights |
Logical or NULL. If TRUE, weights are converted to
distances as |
alpha |
Numeric. Exponent for weight inversion. Default 1. |
... |
Passed to |
Numeric scalar: the average local efficiency, or NA for a
graph with fewer than two nodes. For unweighted simple graphs it lies in
. Weighted graphs can exceed 1 when edge distances are below 1.
network_local_efficiency(regulation_net)network_local_efficiency(regulation_net)
Computes the radius of a network, the minimum eccentricity across all nodes. The eccentricity of a node is its largest shortest-path distance to any other node. Edge weights are used as distances, and directed networks use outgoing paths.
network_radius(x, directed = NULL, ...)network_radius(x, directed = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
directed |
Logical or NULL. Consider edge direction? Default NULL, which follows the directedness of the converted graph. |
... |
Passed to |
Numeric scalar: the network radius.
network_radius(regulation_net)network_radius(regulation_net)
Computes the rich club coefficient for a degree threshold k, the
density of ties among nodes with degree above k. It measures the
tendency of high-degree nodes to connect to each other. Degrees are taken
on the undirected simple skeleton of the network.
network_rich_club(x, k = NULL, normalized = FALSE, n_random = 10, ...)network_rich_club(x, k = NULL, normalized = FALSE, n_random = 10, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
k |
Degree threshold. Only nodes with degree greater than |
normalized |
Logical. If TRUE, divide by the mean coefficient of random graphs with the same degree sequence. Default FALSE. |
n_random |
Number of random graphs for normalization. Default 10. |
... |
Passed to |
Numeric scalar: the rich club coefficient. A normalized value above
1 indicates a rich club effect. NA when fewer than two nodes
exceed k.
When normalized = TRUE the null graphs are drawn from the caller's
RNG stream; this function takes no seed argument and does not save or
restore .Random.seed. Call set.seed() beforehand for a
reproducible result. rich_club() offers a seed
argument, confidence intervals, and the full rich club curve.
network_rich_club(regulation_net, k = 5)network_rich_club(regulation_net, k = 5)
Computes the small-world coefficient
where is the global clustering coefficient, is the mean
shortest path length, and and are their means
over Erdos-Renyi graphs with the same numbers of nodes and edges. A
directed network is collapsed to undirected first.
network_small_world(x, n_random = 10, ...)network_small_world(x, n_random = 10, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
n_random |
Number of Erdos-Renyi comparison graphs (same |
... |
Passed to |
Values above 1 indicate small-world structure.
Numeric: small-world coefficient sigma. NA when the graph has
fewer than 4 nodes, no edges, or an undefined/zero mean path length.
The comparison graphs are drawn from the caller's RNG stream; this function
takes no seed argument and does not save or restore
.Random.seed. Call set.seed() beforehand for a reproducible
result. A larger n_random gives a more stable estimate.
set.seed(1) network_small_world(regulation_net, n_random = 5)set.seed(1) network_small_world(regulation_net, n_random = 5)
Computes network-level statistics and returns them as a one-row data frame. The basic set covers size, density, connectivity, path lengths, centralization, transitivity, reciprocity and degree assortativity.
network_summary( x, directed = NULL, weighted = TRUE, mode = "all", loops = TRUE, simplify = "sum", detailed = FALSE, extended = FALSE, digits = 3, ... )network_summary( x, directed = NULL, weighted = TRUE, mode = "all", loops = TRUE, simplify = "sum", detailed = FALSE, extended = FALSE, digits = 3, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
weighted |
Logical. Use edge weights for strength, shortest-path, and centrality calculations where the underlying igraph routine accepts them. Default TRUE. |
mode |
For directed networks: "all", "in", or "out". Used by the
degree, strength and closeness statistics added by |
loops |
Logical. If TRUE (default), keep self-loops. Set FALSE to remove them. |
simplify |
How to combine multiple edges between the same node pair. Options: "sum" (default), "mean", "max", "min", or FALSE/"none" to keep multiple edges. |
detailed |
Logical. If TRUE, add 11 summary statistics of node-level centralities to the 16 basic metrics. Default FALSE. |
extended |
Logical. If TRUE, add 8 structural metrics (girth, radius, vertex connectivity, clique size, cut vertices, bridges, global and local efficiency). Default FALSE. |
digits |
Integer. Round numeric results to this many decimal places. Default 3. NULL skips rounding. |
... |
Additional arguments (currently unused) |
A data frame with one row. The basic measures are always computed:
Number of nodes in the network
Number of edges in the network
Edge density (proportion of possible edges)
Number of connected components
Longest shortest path in the network
Average shortest path length
Minimum number of edges whose removal disconnects the network. Edge weights are not used.
Degree centralization over all ties (0-1)
In-degree centralization (directed only)
Out-degree centralization (directed only)
Betweenness centralization (0-1)
Closeness centralization (0-1)
Eigenvector centralization (0-1)
Global clustering coefficient
Proportion of mutual edges (directed only)
Degree assortativity coefficient
The extended measures are added when extended = TRUE:
Length of shortest cycle (Inf if acyclic)
Minimum eccentricity over all nodes
Minimum nodes to remove to disconnect graph
Size of the largest complete subgraph
Number of articulation points (cut vertices)
Number of bridge edges
Average inverse shortest path length
Average local efficiency across nodes
The detailed measures are added when detailed = TRUE:
Degree distribution statistics
Weighted degree statistics
Average betweenness centrality
Average closeness centrality
Average eigenvector centrality
Average PageRank
Average Burt's constraint
Average local clustering coefficient
network_summary(regulation_net)network_summary(regulation_net)
Computes the vertex connectivity of a network, the minimum number of vertices whose removal disconnects the graph or leaves a single vertex. Higher values indicate a more robust structure.
network_vertex_connectivity(x, ...)network_vertex_connectivity(x, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
... |
Passed to |
Numeric scalar: the minimum vertex cut size, or NA when
igraph cannot compute it.
network_vertex_connectivity(regulation_net)network_vertex_connectivity(regulation_net)
cograph provides verbs for reshaping a network. Each verb accepts any
supported input (matrix, edge list, igraph, statnet network, tna model,
cograph_network) and takes its options as named arguments. The
result is a cograph_network, or the input format when
keep_format = TRUE. as.data.frame() returns the edge or node
table of a result.
Each verb returns a cograph_network, except
split_components(), which returns a list of them. With
keep_format = TRUE a matrix, igraph, statnet network or tna input
comes back in that format. An edge-list data frame comes back as a
cograph_network with a warning.
filter_nodes(), select_nodes()
Keep nodes by expression, name, index, top-N, neighborhood or component.
filter_edges(), select_edges()
Keep edges by expression, endpoints, bridges, mutuality or top-N.
select_neighbors(), select_component(),
select_top(), select_k_core()
Named shorthands for the common selections.
split_components()One network per connected component.
threshold_edges()Keep edges by weight, count, proportion or density.
binarize()Replace weights with 0/1.
symmetrize()Combine opposite arcs into one edge.
normalize_weights()Rescale by row, column, maximum, total, or to [0, 1].
invert_weights()Turn similarities into distances.
to_undirected(), to_directed(),
reverse_edges()
Change directedness.
remove_isolates()Drop nodes with no edges.
contract_nodes()Collapse groups of nodes into one.
spanning_tree(),
complement_network()
Derived graphs.
reorder_nodes(), rename_nodes()
Change node order or labels without changing the network.
simplify()Merge duplicate edges and drop loops. It returns the input format.
add_nodes(), remove_nodes(),
add_edges(), remove_edges()
Add and remove.
mutate_nodes(),
mutate_edges()
Compute and store attributes.
bind_networks()Union, intersection or difference of two networks.
as_cograph(), to_matrix(),
to_igraph(), to_network(),
to_df(), and as.data.frame() on a
cograph_network (see as.data.frame.cograph_network).
Filtering edges does not remove nodes, as in
igraph::delete_edges() and tidygraph. Nodes left without edges
raise a cograph_isolates_created warning. They are dropped by
remove_isolates() or by keep_isolates = FALSE
in the verbs that have that argument.
The weight matrix of an undirected result is symmetric, so the result is still detected as undirected downstream.
Node groups, estimation data, layout coordinates and the original source type are carried through the verbs.
Unknown node names, out-of-range or fractional indices, unknown
measure names and a malformed between raise a
cograph_bad_selection error. The name argument of
select_nodes() is an exception. Unknown names in it are
skipped, and a warning is given when no node matches.
ego_networks(), shortest_paths(),
disparity_filter(), detect_communities(),
summarize_clusters(), aggregate_layers().
as.data.frame(threshold_edges(regulation_net, minimum = 0.2))as.data.frame(threshold_edges(regulation_net, minimum = 0.2))
Rescales the edge weights. Row normalization turns a transition count matrix into the transition probabilities used by TNA models.
normalize_weights( x, method = c("row", "column", "max", "sum", "minmax"), keep_format = FALSE, directed = NULL )normalize_weights( x, method = c("row", "column", "max", "sum", "minmax"), keep_format = FALSE, directed = NULL )
x |
Network input. |
method |
How to rescale:
|
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A row or column whose total is zero is left at zero. Zero totals, and a zero
denominator for "max" or "sum", raise a
cograph_zero_norm warning.
"minmax" maps the weakest edge to .Machine$double.eps. A
weight of exactly 0 would remove the edge, because 0 stores "no edge". When
all weights are equal they all become 1.
"max", "sum" and "minmax" rescale each edge
independently and keep any extra edge columns. "row" and
"column" scale an edge by a total that differs at its two endpoints.
They break symmetry, so an undirected input is returned as a directed
network.
A cograph_network with rescaled weights, or the input format
when keep_format = TRUE.
binarize, invert_weights,
symmetrize
normalize_weights(regulation_net, method = "row")normalize_weights(regulation_net, method = "row")
Plots a network with splot and overlays smooth blob
shapes that mark node communities.
overlay_communities( x, communities, blob_colors = NULL, blob_alpha = 0.25, blob_linewidth = 0.7, blob_line_alpha = 0.8, ... )overlay_communities( x, communities, blob_colors = NULL, blob_alpha = 0.25, blob_linewidth = 0.7, blob_line_alpha = 0.8, ... )
x |
A network object passed to |
communities |
Community assignments in any of these formats:
|
blob_colors |
Character vector of fill colors for blobs.
Recycled if shorter than the number of communities. Default
|
blob_alpha |
Numeric. Fill transparency (0-1). Default |
blob_linewidth |
Numeric. Border line width. Default |
blob_line_alpha |
Numeric. Border line transparency (0-1). Default |
... |
Additional arguments passed to |
Invisibly, the cograph_network object returned by
splot. Called for the side effect of plotting.
comm <- cograph::communities(regulation_net, method = "walktrap") overlay_communities(regulation_net, comm)comm <- cograph::communities(regulation_net, method = "walktrap") overlay_communities(regulation_net, comm)
The palette_*() functions generate a vector of n colors for
nodes or edges. They are registered under their short names (for example
"colorblind"), which sn_palette accepts, and
list_palettes() returns the registered names.
palette_rainbow()Rainbow hues.
palette_colorblind()The colorblind-safe colors of Wong.
palette_pastel()Soft pastel colors.
palette_viridis()The viridis family, chosen by
option.
palette_blues(), palette_reds()
Sequential blue or red shades.
palette_diverging()Blue to red through midpoint.
list_palettes() palette_rainbow(n, alpha = 1) palette_colorblind(n, alpha = 1) palette_pastel(n, alpha = 1) palette_viridis(n, alpha = 1, option = "viridis") palette_blues(n, alpha = 1) palette_reds(n, alpha = 1) palette_diverging(n, alpha = 1, midpoint = "white")list_palettes() palette_rainbow(n, alpha = 1) palette_colorblind(n, alpha = 1) palette_pastel(n, alpha = 1) palette_viridis(n, alpha = 1, option = "viridis") palette_blues(n, alpha = 1) palette_reds(n, alpha = 1) palette_diverging(n, alpha = 1, midpoint = "white")
n |
Number of colors to generate. |
alpha |
Transparency, from 0 (transparent) to 1 (opaque). |
option |
Viridis option, one of |
midpoint |
Color of the midpoint of the diverging palette. |
The palette_*() functions return a character vector of
n colors. list_palettes() returns a character vector of
palette names.
splot(regulation_net, node_fill = palette_colorblind(n = 10))splot(regulation_net, node_fill = palette_colorblind(n = 10))
Sets up a multi-panel device layout for use with cograph plotting
functions called with combined = FALSE. The previous par()
settings are returned so that the caller can restore the device state.
panel_layout(spec, mar = c(2, 2, 3, 1), widths = NULL, heights = NULL)panel_layout(spec, mar = c(2, 2, 3, 1), widths = NULL, heights = NULL)
spec |
Either a length-2 vector of positive integers
|
mar |
Numeric vector of length 4 giving panel margins. Default
|
widths, heights
|
Optional numeric vectors of column widths and row
heights, passed to |
A length-2 spec = c(nrow, ncol) creates a uniform grid through
graphics::par(mfrow = ...). A matrix spec creates a
non-uniform layout through graphics::layout(). The matrix values
number the panel cells and are read in column-major order, so
matrix(c(1, 1, 2, 3), 2, 2) gives one tall cell in the left column
and two stacked cells in the right column.
Invisibly, a list of the previous par() settings
(mar and mfrow). Passing it to graphics::par()
restores the prior device state and also clears a layout set by
graphics::layout().
The combined = FALSE argument applies to the multi-panel plot
functions plot_netobject_group(),
plot_netobject_ml(), plot_net_bootstrap_group(),
plot_group_permutation(), plot_difference(),
splot.net_mlvar(type = "all"), plot_network_evolution(),
plot.cograph_motifs(type = "network"),
plot.cograph_motif_result(type = "patterns"),
plot.cograph_motif_analysis(type = "patterns"),
plot.tna_disparity(type = "comparison"), and splot() on
group_tna and other list inputs. A single-network splot()
call plots one panel and ignores combined.
op <- panel_layout(c(1, 2)) splot(regulation_net, combined = FALSE) splot(regulation_net, layout = "circle", combined = FALSE) graphics::par(op)op <- panel_layout(c(1, 2)) splot(regulation_net, combined = FALSE) splot(regulation_net, layout = "circle", combined = FALSE) graphics::par(op)
Creates an alluvial (Sankey) diagram of aggregated flows between states.
It calls plot_transitions() with track_individuals = FALSE.
plot_alluvial( x, from_title = "From", to_title = "To", title = NULL, from_colors = NULL, to_colors = NULL, flow_fill = "#888888", flow_alpha = 0.4, flow_color_by = NULL, flow_border = NA, flow_border_width = 0.5, node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, show_values = FALSE, value_position = c("center", "origin", "destination", "outside_origin", "outside_destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", conserve_flow = TRUE, min_flow = 0, threshold = 0, value_digits = 2, column_gap = 1 )plot_alluvial( x, from_title = "From", to_title = "To", title = NULL, from_colors = NULL, to_colors = NULL, flow_fill = "#888888", flow_alpha = 0.4, flow_color_by = NULL, flow_border = NA, flow_border_width = 0.5, node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, show_values = FALSE, value_position = c("center", "origin", "destination", "outside_origin", "outside_destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", conserve_flow = TRUE, min_flow = 0, threshold = 0, value_digits = 2, column_gap = 1 )
x |
Input data in one of these formats:
|
from_title |
Title for the left column. Default "From". For multi-step and individual-tracking plots, a vector with one title per column. Data frame input then uses the column names by default, and a vector shorter than the number of columns is replaced by "T1", "T2", ... |
to_title |
Title for the right column. Default "To". Ignored for multi-step plots. |
title |
Optional plot title. |
from_colors |
Colors for the left-side nodes. In multi-step and individual-tracking plots, the colors of all states. Default NULL uses the built-in palette. |
to_colors |
Colors for the right-side nodes in two-column plots. Default NULL uses the built-in palette. |
flow_fill |
Fill color for flows. Default "#888888" (grey). In
multi-step plots it is replaced by the state colors when
|
flow_alpha |
Alpha transparency for flows. Default 0.4. |
flow_color_by |
Color flows by state. Multi-step aggregate plots
accept |
flow_border |
Border color for flows. Default NA (no border). |
flow_border_width |
Line width for flow borders. Default 0.5. |
node_width |
Width of node rectangles (0-1 scale). Default 0.08. |
node_border |
Border color for nodes. Default NA (no border). |
node_spacing |
Vertical spacing between nodes (0-1 scale). Default 0.02. |
label_size |
Size of node labels. Default 3.5. |
label_position |
Position of node labels: "beside" (default),
"inside", "above", "below", "outside". In multi-step and
individual-tracking plots, "beside" and "outside" label the first and
last columns only. See |
label_halo |
Logical: add a white halo around labels and column titles? Default TRUE. |
label_color |
Color of state name labels. Default "black". Applied to multi-step and individual-tracking plots. Two-column aggregate plots use black external labels and white inside labels. |
label_fontface |
Font face of state name labels ("plain", "bold", "italic", "bold.italic"). Default "plain". Applied to multi-step and individual-tracking plots. |
label_nudge |
Distance between node edge and label (in plot units). Default 0.02. Used by multi-step and individual-tracking plots. |
title_size |
Size of column titles. Default 5. |
title_color |
Color of column title text. Default "black". Applied to multi-step and individual-tracking plots. |
title_fontface |
Font face of column titles. Default "bold". Applied to multi-step and individual-tracking plots. |
curve_strength |
Controls bezier curve shape (0-1). Default 0.6. |
show_values |
Logical: show transition counts on flows? Default FALSE. |
value_position |
Position of flow values: "center", "origin", "destination", "outside_origin", "outside_destination". Default "center". Individual-tracking plots use "center", "origin" and "destination". |
value_size |
Size of value labels on flows. Default 3. |
value_color |
Color of value labels. Default "black". |
value_halo |
Logical: add halo around flow value labels? Default NULL
uses |
value_fontface |
Font face of flow value labels. Default "bold". Applied to multi-step and individual-tracking plots. |
value_nudge |
Distance of value labels from node edge when using "origin" or "destination" positions. Default 0.03. |
value_min |
Minimum count to show a flow value label in multi-step and
individual-tracking plots. Default 0 (show all). Two-column aggregate
plots show every nonzero value label when |
show_totals |
Logical: show total counts on nodes? Default FALSE. |
total_size |
Size of total labels. Default 4. |
total_color |
Color of total labels. Default "white". |
total_fontface |
Font face of total labels. Default "bold". Applied to multi-step and individual-tracking plots. |
conserve_flow |
Logical. When TRUE (default), node heights on both sides of a two-column plot are proportions of the same total flow. When FALSE, each side is scaled to its own total. Ignored for multi-step and individual-tracking plots. |
min_flow |
Minimum flow value to display in aggregate plots. Default 0 (show all). |
threshold |
Minimum flow value to display in aggregate plots. Flows
below |
value_digits |
Number of decimal places for flow value labels and node totals. Default 2. |
column_gap |
Horizontal spread of columns (0-1) for multi-step and individual-tracking plots. Default 1 uses the full width. Smaller values (e.g., 0.6) bring the columns closer together. |
A ggplot object.
plot_transitions, plot_trajectories
plot_alluvial(regulation_net)plot_alluvial(regulation_net)
Plots bootstrap results of net_bootstrap,
net_bootstrap_group, tna_bootstrap and boot_glasso
objects as a ggplot2 forest plot. Each row is one non-zero network edge.
A square marks the point estimate, a horizontal bar spans the selected
interval, and a dashed reference line marks zero. Significant edges are
plotted in sig_color and non-significant edges in a faded
nonsig_color.
plot_bootstrap_forest(x, ...) ## S3 method for class 'net_bootstrap' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'tna_bootstrap' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'boot_glasso' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'net_bootstrap_group' plot_bootstrap_forest( x, layout = c("linear", "circular"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, n_top = NULL, all_edges = FALSE, pos_color = NULL, title = NULL, subtitle = NULL, label_size = 2.8, ... )plot_bootstrap_forest(x, ...) ## S3 method for class 'net_bootstrap' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'tna_bootstrap' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'boot_glasso' plot_bootstrap_forest( x, alpha = NULL, layout = c("linear", "circular", "grouped"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, sort_by = c("estimate", "significance", "name"), n_top = NULL, node_colors = NULL, sig_color = "#2C6E8A", cr_color = "#D4829A", nonsig_color = "#CCCCCC", ring_color = "#C8C8C8", median_color = "#AAAAAA", label_size = NULL, label_color = NULL, point_size = NULL, r_inner = NULL, r_outer = NULL, gap_rad = NULL, label_offset = NULL, src_label_size = NULL, margins = c(0.1, 0.1, 0.1, 0.1), scale = 1, title = NULL, subtitle = NULL, ... ) ## S3 method for class 'net_bootstrap_group' plot_bootstrap_forest( x, layout = c("linear", "circular"), interval = c("ci", "cr", "both"), show_nonsig = TRUE, n_top = NULL, all_edges = FALSE, pos_color = NULL, title = NULL, subtitle = NULL, label_size = 2.8, ... )
x |
A |
... |
Currently unused. |
alpha |
Significance threshold. Default |
layout |
|
interval |
Which interval to display: |
show_nonsig |
Logical. Include non-significant edges.
Default |
sort_by |
Order of edges on the y-axis in the linear layout:
|
n_top |
Integer. Keeps only the |
node_colors |
Optional named vector of node colors for the grouped layout. When NULL, node colors stored in the original network or tna model are used if present. |
sig_color |
Color for significant CI bars and points (linear and
circular layouts). Default |
cr_color |
Color for the consistency range bar ( |
nonsig_color |
Color for non-significant edges (linear and circular
layouts). Default |
ring_color |
Color for the reference rings (circular and grouped
layouts). Default |
median_color |
Color for the dashed median ring (circular and grouped
layouts). Default |
label_size |
Text size for edge labels (circular and grouped layouts).
Default |
label_color |
Fixed color for edge labels (circular and grouped
layouts). |
point_size |
Size of the estimate square. Default |
r_inner |
Inner ring radius (grouped layout). Default |
r_outer |
Outer ring radius (grouped layout). Default |
gap_rad |
Gap in radians between sectors (grouped layout). Default |
label_offset |
Distance between outer ring and labels (grouped layout). Default |
src_label_size |
Text size for source node labels in the center (grouped layout).
Default |
margins |
Margins as |
scale |
Scaling factor applied to all text and point sizes (grouped layout).
Default |
title |
Plot title. Default |
subtitle |
Plot subtitle. Default |
all_edges |
For |
pos_color |
Currently unused by the |
Objects from stability inference (net_bootstrap and
tna_bootstrap) carry both a bootstrap confidence interval and a
consistency range, and interval = "both" overlays the two. When the
consistency range is requested but absent, a message is issued and the
confidence interval is shown. For boot_glasso, an edge is
significant when its inclusion proportion is at least 1 - alpha.
The net_bootstrap_group method plots the groups side by side in
the linear layout, with the edges ordered by their mean estimate across
groups. Its interval = "both" shows the confidence interval only,
and its circular layout shows the first group only.
A ggplot object.
boot <- tna::bootstrap(tna::tna(coding), iter = 50) plot_bootstrap_forest(boot)boot <- tna::bootstrap(tna::tna(coding), iter = 50) plot_bootstrap_forest(boot)
Plots one or more centrality measures, one facet per measure. Accepts the
data frame from centrality or any network input.
plot_centrality( x, measures = NULL, style = c("line", "bar", "lollipop", "dot"), orientation = c("horizontal", "vertical"), scale = c("raw", "normalized", "z", "rank"), order_by = NULL, top_n = NULL, highlight = 0L, cluster = NULL, palette = "cograph", ncol = NULL, title = NULL, subtitle = NULL, ... )plot_centrality( x, measures = NULL, style = c("line", "bar", "lollipop", "dot"), orientation = c("horizontal", "vertical"), scale = c("raw", "normalized", "z", "rank"), order_by = NULL, top_n = NULL, highlight = 0L, cluster = NULL, palette = "cograph", ncol = NULL, title = NULL, subtitle = NULL, ... )
x |
Output of |
measures |
Character vector of measure names. When |
style |
Character: "line" (default), "bar", "lollipop", or "dot". |
orientation |
Character: "horizontal" (default, nodes on y-axis) or "vertical" (nodes on x-axis). |
scale |
Character: "raw" (default, native units with a free value axis per facet), "normalized" (min-max scaled to [0, 1] within measure), "z" (standardized within measure), or "rank" (1 = highest value within measure). |
order_by |
Character. Name of the measure column that sorts the
nodes (e.g., "degree_all"), or |
top_n |
Optional integer. Keeps only the top-N nodes by
|
highlight |
Integer. In the "bar", "lollipop" and "dot" styles, the top-N nodes per measure are plotted in full color and the rest are muted. Default 0 (no highlighting). Ignored by the "line" style. |
cluster |
Optional cluster assignment of the nodes, given as the name
of a column of |
palette |
Currently unused. Cluster colors are taken from the built-in cograph palette. |
ncol |
Number of facet columns. Default |
title |
Plot title. Default NULL. |
subtitle |
Plot subtitle. Default NULL. |
... |
Passed to |
Four styles are available:
"line"Points connected by a line within each measure, with
nodes in the order set by order_by.
"bar"Bars of the measure values.
"lollipop"Segments ending in a dot.
"dot"Dots only.
A ggplot object.
plot_centrality(regulation_net)plot_centrality(regulation_net)
Plots one centrality measure across two or more groups as stacked,
faceted, grouped, dumbbell, line, or pyramid charts. The
"pyramid" style is a back-to-back horizontal bar chart for exactly
two groups. Groups are aligned on the node names they share.
plot_centrality_compare( ..., measure = NULL, style = c("stacked", "facet", "grouped", "dumbbell", "line", "pyramid"), group_labels = NULL, group_colors = NULL, node_colors = NULL, sort_by = c("max", "delta", "first", "alpha"), top_n = NULL, scale = c("raw", "normalized"), show_values = TRUE, size_by_value = FALSE, size_range = c(2, 9), orientation = c("horizontal", "vertical"), ncol = NULL, title = NULL, subtitle = NULL, centrality_args = list() )plot_centrality_compare( ..., measure = NULL, style = c("stacked", "facet", "grouped", "dumbbell", "line", "pyramid"), group_labels = NULL, group_colors = NULL, node_colors = NULL, sort_by = c("max", "delta", "first", "alpha"), top_n = NULL, scale = c("raw", "normalized"), show_values = TRUE, size_by_value = FALSE, size_range = c(2, 9), orientation = c("horizontal", "vertical"), ncol = NULL, title = NULL, subtitle = NULL, centrality_args = list() )
... |
Two or more centrality data frames (from
|
measure |
Character, a single centrality measure to compare. For network inputs, a name such as "strength" also matches a shared column with an "_all", "_in" or "_out" suffix when the match is unique. For centrality data frames, it must be an exact column name. If NULL, the first shared measure is used. |
style |
Character: |
group_labels |
Character vector with one label per group. Default
|
group_colors |
Character vector of colors, one per group. Default cycles through the cograph palette. |
node_colors |
Colors of the nodes in |
sort_by |
|
top_n |
Show top N nodes (by |
scale |
|
show_values |
Logical. Print the value of each bar or point. Default TRUE. |
size_by_value |
Logical. For |
size_range |
Numeric vector of length 2 giving the min and max
dot size (mm) when |
orientation |
Character: |
ncol |
Number of facet columns for |
title |
Plot title. NULL (default) gives "Centrality comparison:" followed by the measure name. |
subtitle |
Plot subtitle. When NULL, the |
centrality_args |
Named list of additional arguments passed to
|
A ggplot object.
plot_centrality_compare(Full = regulation_net, Strong = threshold_edges(regulation_net, minimum = 0.1), measure = "strength")plot_centrality_compare(Full = regulation_net, Strong = threshold_edges(regulation_net, minimum = 0.1), measure = "strength")
Histogram or density plot of one centrality measure. The input is either
the data frame returned by centrality or a network, for
which the measure is computed first.
plot_centrality_distribution( x, measure = "degree_all", type = c("histogram", "density"), normalize = FALSE, bins = NULL, log = "", col = "steelblue", border = "white", main = NULL, xlab = NULL, ... )plot_centrality_distribution( x, measure = "degree_all", type = c("histogram", "density"), normalize = FALSE, bins = NULL, log = "", col = "steelblue", border = "white", main = NULL, xlab = NULL, ... )
x |
A data frame from |
measure |
Character. Column of the centrality output to plot, for
example |
type |
Character. |
normalize |
Logical. Show proportions instead of counts. Default FALSE. |
bins |
Integer or NULL. Number of equal-width histogram bins. The default NULL uses the Freedman-Diaconis rule. |
log |
Character. |
col |
Fill color (line color for the density). Default
|
border |
Bar border color for the histogram. Default |
main |
Plot title. The default NULL builds a title such as
|
xlab |
X-axis label. The default NULL uses the measure name. |
... |
Invisibly, a numeric vector of the finite centrality values plotted.
cograph::plot_centrality_distribution(regulation_net, measure = "strength_all")cograph::plot_centrality_distribution(regulation_net, measure = "strength_all")
Plots a heatmap of nodes (rows) by centrality measures (columns). Cell fill is the z-score of each value within its measure, mapped to a diverging color scale. Optional row clustering places nodes with similar centrality profiles next to each other.
plot_centrality_heatmap( x, measures = NULL, cluster_rows = TRUE, order_by = NULL, show_values = FALSE, value_digits = 1L, low = "#2171B5", mid = "white", high = "#CB181D", limits = c(-2.5, 2.5), title = NULL, subtitle = "z-scored within measure", ... )plot_centrality_heatmap( x, measures = NULL, cluster_rows = TRUE, order_by = NULL, show_values = FALSE, value_digits = 1L, low = "#2171B5", mid = "white", high = "#CB181D", limits = c(-2.5, 2.5), title = NULL, subtitle = "z-scored within measure", ... )
x |
Centrality data frame (from |
measures |
Character vector of measure names. When |
cluster_rows |
Logical. Order rows by hierarchical clustering (Euclidean distance, average linkage) of the z-scored profiles. Applied when there are more than two nodes. Default TRUE. |
order_by |
Used when rows are not clustered. Name of the measure that sorts rows in descending order. NULL (default) or an unknown name uses the first measure. |
show_values |
Logical. Print the raw centrality values in the cells. Default FALSE. |
value_digits |
Decimal places for cell values. Default 1. |
low, mid, high
|
Color stops for the diverging scale. Defaults to blue, white and red. |
limits |
Numeric c(min, max) z-score range. Values outside are squished to the endpoints. Default c(-2.5, 2.5). |
title, subtitle
|
Plot title and subtitle. The default subtitle is "z-scored within measure". |
... |
Passed to |
A ggplot object.
plot_centrality_heatmap(regulation_net)plot_centrality_heatmap(regulation_net)
Plots a chord diagram in which nodes are arcs on the outer ring and edges are curved ribbons (chords) connecting them. Arc length is proportional to the total absolute weight of each node's edges, and chord width is proportional to the absolute edge weight.
plot_chord( x, directed = NULL, segment_colors = NULL, segment_border_color = "white", segment_border_width = 1, segment_pad = 0.02, segment_width = 0.08, chord_color_by = "source", chord_alpha = 0.5, chord_border = NA, self_loop = TRUE, labels = NULL, label_size = 1, label_color = "black", label_offset = 0.05, label_threshold = 0, threshold = 0, ticks = FALSE, tick_interval = NULL, tick_labels = TRUE, tick_size = 0.6, tick_color = "grey30", start_angle = pi/2, clockwise = TRUE, title = NULL, title_size = 1.2, background = NULL, ... )plot_chord( x, directed = NULL, segment_colors = NULL, segment_border_color = "white", segment_border_width = 1, segment_pad = 0.02, segment_width = 0.08, chord_color_by = "source", chord_alpha = 0.5, chord_border = NA, self_loop = TRUE, labels = NULL, label_size = 1, label_color = "black", label_offset = 0.05, label_threshold = 0, threshold = 0, ticks = FALSE, tick_interval = NULL, tick_labels = TRUE, tick_size = 0.6, tick_color = "grey30", start_angle = pi/2, clockwise = TRUE, title = NULL, title_size = 1.2, background = NULL, ... )
x |
A weight matrix, |
directed |
Logical. If |
segment_colors |
Colors for the outer ring segments, recycled to the
number of nodes. |
segment_border_color |
Border color for segments. |
segment_border_width |
Border width for segments. |
segment_pad |
Gap between segments in radians. |
segment_width |
Radial thickness of the outer ring as a fraction of the radius. |
chord_color_by |
How to color chords. |
chord_alpha |
Alpha transparency for chords. |
chord_border |
Border color for chords. |
self_loop |
Logical. Ignored. Self-loop chords are always shown. |
labels |
Node labels. |
label_size |
Text size multiplier for labels. |
label_color |
Color for labels. |
label_offset |
Radial offset of labels beyond the outer ring. |
label_threshold |
Hide labels for nodes whose share of the total flow is below this value. |
threshold |
Minimum absolute weight to show a chord. |
ticks |
Logical. Add tick marks along the outer ring to indicate magnitude? |
tick_interval |
Spacing between major ticks in the same units as the
weight matrix. Minor ticks are placed at half this spacing. |
tick_labels |
Logical. Show numeric labels at major ticks? |
tick_size |
Text size multiplier for tick labels. |
tick_color |
Color for tick marks and labels. |
start_angle |
Starting angle in radians (default |
clockwise |
Logical. Lay out segments clockwise? |
title |
Optional plot title. |
title_size |
Text size multiplier for the title. |
background |
Background color for the plot. |
... |
Ignored. |
The diagram is plotted with base R graphics. Segments and chords are polygons, and each ribbon follows quadratic Bezier curves through the center.
For directed networks, each segment is split into an outgoing half and an incoming half, and chords attach to the matching half. For undirected networks each edge forms one chord and the full segment arc is shared. Nodes without edges receive a small minimum arc so that they remain visible.
Invisibly, a list with two data frames. segments has one row
per node with columns node, start, end, mid
(angles in radians) and flow. chords has one row per chord
with columns from, to (node indices), from_start,
from_end, to_start, to_end (attachment angles) and
weight (absolute edge weight).
plot_chord(regulation_net)plot_chord(regulation_net)
plot_compare() is an alias of plot_difference() and
calls the same implementation. tna::plot_compare() calls it by name.
plot_difference() is the preferred name.
plot_compare(x, ...)plot_compare(x, ...)
x |
First network (see |
... |
Arguments passed to |
Invisibly, the value of plot_difference.
plot_compare(regulation_net, t(regulation_net))plot_compare(regulation_net, t(regulation_net))
Plots a heatmap of the difference between two weight matrices, or of either matrix alone. Rows are source nodes and columns are target nodes.
plot_comparison_heatmap( x, y = NULL, type = c("difference", "x", "y"), name_x = "x", name_y = "y", low_color = "blue", mid_color = "white", high_color = "red", limits = NULL, show_values = FALSE, value_size = 3, digits = 2, title = NULL, xlab = "Target", ylab = "Source" )plot_comparison_heatmap( x, y = NULL, type = c("difference", "x", "y"), name_x = "x", name_y = "y", low_color = "blue", mid_color = "white", high_color = "red", limits = NULL, show_values = FALSE, value_size = 3, digits = 2, title = NULL, xlab = "Target", ylab = "Source" )
x |
First network: matrix, |
y |
Second network, of the same type and dimensions as |
type |
What to display: |
name_x |
Label for the first network in the default title. |
name_y |
Label for the second network in the default title. |
low_color |
Color for low (negative) values. |
mid_color |
Color for zero. |
high_color |
Color for high (positive) values. |
limits |
Color scale limits. |
show_values |
Logical. Display values in cells? |
value_size |
Text size for cell values. |
digits |
Decimal places for cell values. |
title |
Plot title. |
xlab |
X-axis label. |
ylab |
Y-axis label. |
A ggplot object. The color scale is a diverging gradient with its midpoint at 0.
plot_comparison_heatmap(regulation_net, t(regulation_net))plot_comparison_heatmap(regulation_net, t(regulation_net))
Scatter plot of each node's degree against the average degree of its neighbors. A positive slope indicates assortative mixing and a negative slope indicates disassortative mixing. When more than two nodes have neighbors, a least-squares line is added and the Pearson correlation is printed in the top margin.
plot_degree_correlation( x, mode = "all", directed = NULL, col = "steelblue", main = "Degree-Degree Correlation", ... )plot_degree_correlation( x, mode = "all", directed = NULL, col = "steelblue", main = "Degree-Degree Correlation", ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna. |
mode |
Character. Degree type and neighborhood used for directed
networks: |
directed |
Logical or NULL. Default NULL (auto-detect). |
col |
Point color. Default |
main |
Title. Default |
... |
Additional arguments passed to |
Invisibly, a data frame with one row per node and columns
node, degree and avg_neighbor_degree. The
average neighbor degree is NA for nodes without neighbors.
centrality, degree_distribution,
network_summary
cograph::plot_degree_correlation(student_interactions)cograph::plot_degree_correlation(student_interactions)
Plots the difference between two networks (x - y) with splot.
Positive differences (x > y) are shown in pos_color and negative
differences (x < y) in neg_color. Node-level differences, such as
initial probabilities, can be shown as donut charts.
plot_difference( x, y = NULL, i = NULL, j = NULL, pos_color = "#009900", neg_color = "#C62828", labels = NULL, title = NULL, inits_x = NULL, inits_y = NULL, show_inits = NULL, donut_inner_ratio = 0.8, force = FALSE, combined = TRUE, difference = FALSE, ... )plot_difference( x, y = NULL, i = NULL, j = NULL, pos_color = "#009900", neg_color = "#C62828", labels = NULL, title = NULL, inits_x = NULL, inits_y = NULL, show_inits = NULL, donut_inner_ratio = 0.8, force = FALSE, combined = TRUE, difference = FALSE, ... )
x |
First network: matrix, |
y |
Second network, of the same type as |
i |
Index or name of the first group when |
j |
Index or name of the second group, with the same rules as
|
pos_color |
Color for positive differences (x > y). |
neg_color |
Color for negative differences (x < y). |
labels |
Node labels. |
title |
Plot title. |
inits_x |
Node values for x (e.g., initial probabilities). |
inits_y |
Node values for y. |
show_inits |
Logical. Show node differences as donuts? |
donut_inner_ratio |
Inner radius ratio for donut (0-1). |
force |
Logical. Plot all pairs for a |
combined |
Logical. When |
difference |
Logical. If |
... |
Additional arguments passed to |
The weight matrices are subtracted element-wise. Both networks must have the same dimensions and, when present, the same node labels; otherwise the function stops with an error. A directed difference (or tna input) is styled with the TNA preset and an undirected difference with the psychometric preset.
When node values (inits) are given or extracted from tna objects, each node
is shown as a donut whose filled fraction is the absolute difference,
capped at 1, colored pos_color when x is higher and
neg_color when y is higher.
plot_compare() is an alias of plot_difference().
Invisibly, a list with elements weights (the element-wise
difference matrix x - y) and inits (the node-value
difference, or NULL when no node values were available). For the
group_tna all-pairs path, a named list of such lists with one
element per pair, named "<group_i>_vs_<group_j>".
plot_compare, plot_comparison_heatmap
plot_difference(regulation_net, t(regulation_net))plot_difference(regulation_net, t(regulation_net))
Plots pairwise edge weight differences from a boot_glasso object.
Each row (linear) or spoke (circular) is one edge pair. The square marks
the mean bootstrap difference, the bar spans its bootstrap percentile
interval at level 1 - alpha, and a dashed line or ring marks zero.
Significant pairs are plotted in pos_color when the first edge is
larger and in neg_color when the second edge is larger.
plot_edge_diff_forest(x, ...) ## S3 method for class 'boot_glasso' plot_edge_diff_forest( x, alpha = NULL, layout = c("linear", "circular", "chord", "tile"), show_nonsig = FALSE, nonzero_only = FALSE, sort_by = c("estimate", "significance", "name"), n_top = NULL, pos_color = "#C0392B", neg_color = "#2C6E8A", nonsig_color = "#AAAAAA", ring_color = "#C8C8C8", label_size = 2.3, label_color = NULL, point_size = if (match.arg(layout) == "circular") 2 else 3, r_inner = 0.38, r_outer = 0.72, title = NULL, subtitle = NULL, ... )plot_edge_diff_forest(x, ...) ## S3 method for class 'boot_glasso' plot_edge_diff_forest( x, alpha = NULL, layout = c("linear", "circular", "chord", "tile"), show_nonsig = FALSE, nonzero_only = FALSE, sort_by = c("estimate", "significance", "name"), n_top = NULL, pos_color = "#C0392B", neg_color = "#2C6E8A", nonsig_color = "#AAAAAA", ring_color = "#C8C8C8", label_size = 2.3, label_color = NULL, point_size = if (match.arg(layout) == "circular") 2 else 3, r_inner = 0.38, r_outer = 0.72, title = NULL, subtitle = NULL, ... )
x |
A |
... |
Currently unused. |
alpha |
Significance threshold. Default |
layout |
|
show_nonsig |
Logical. Include non-significant pairs. Default
|
nonzero_only |
If |
sort_by |
|
n_top |
Restrict to top N pairs by absolute difference. |
pos_color |
Color when edge1 > edge2. Default |
neg_color |
Color when edge1 < edge2. Default |
nonsig_color |
Color for non-significant pairs. Default
|
ring_color |
Ring color (circular and chord layouts). Default
|
label_size |
Text size of edge labels (circular and chord layouts).
Default |
label_color |
Fixed label color (circular and chord layouts).
|
point_size |
Size of estimate square (linear and circular layouts).
Default |
r_inner |
Inner ring radius (circular). Default |
r_outer |
Outer ring radius (circular). Default |
title |
Plot title. Default |
subtitle |
Plot subtitle. Default |
A ggplot object.
set.seed(1) data1 <- as.data.frame(matrix(rnorm(60), 20, 3, dimnames = list(NULL, c("A","B","C")))) bg <- Nestimate::boot_glasso(data1, iter = 50, cs_iter = 25, centrality = c("strength", "expected_influence")) plot_edge_diff_forest(bg)set.seed(1) data1 <- as.data.frame(matrix(rnorm(60), 20, 3, dimnames = list(NULL, c("A","B","C")))) bg <- Nestimate::boot_glasso(data1, iter = 50, cs_iter = 25, centrality = c("strength", "expected_influence")) plot_edge_diff_forest(bg)
Histogram of edge weights in a network. The number of edges and the mean and standard deviation of the weights are printed in the top margin.
plot_edge_weights( x, normalize = FALSE, bins = NULL, log = "", directed = NULL, col = "steelblue", border = "white", main = "Edge Weight Distribution", xlab = "Weight", ... )plot_edge_weights( x, normalize = FALSE, bins = NULL, log = "", directed = NULL, col = "steelblue", border = "white", main = "Edge Weight Distribution", xlab = "Weight", ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna. |
normalize |
Logical. Show proportions. Default FALSE. |
bins |
Integer or NULL. Number of equal-width bins. With the default NULL, integer weights spanning at most 30 units get one bin per integer and other weights use the Freedman-Diaconis rule. |
log |
Character. |
directed |
Logical or NULL. Default NULL (auto-detect). |
col |
Fill color. Default |
border |
Border color. Default |
main |
Title. Default |
xlab |
X-axis label. Default |
... |
Additional arguments passed to |
Invisibly, a numeric vector of edge weights (all 1 for an unweighted network).
cograph::plot_edge_weights(regulation_net)cograph::plot_edge_weights(regulation_net)
Visualizes a network weight matrix as a heatmap. Single networks,
clustered networks (blocks along the diagonal), and multi-group networks
(group_tna, as a supra-adjacency matrix) are supported.
plot_heatmap( x, cluster_list = NULL, cluster_spacing = 0, show_legend = TRUE, legend_position = "right", legend_title = "Weight", colors = "viridis", limits = NULL, midpoint = NULL, na_color = "grey90", show_values = FALSE, value_size = 2.5, value_color = "black", value_fontface = "plain", value_fontfamily = "sans", value_halo = NULL, value_digits = 2, show_diagonal = TRUE, diagonal_color = NULL, cluster_labels = TRUE, cluster_borders = TRUE, border_color = "black", border_width = 0.5, row_labels = NULL, col_labels = NULL, show_axis_labels = TRUE, axis_text_size = 8, axis_text_angle = 45, title = NULL, subtitle = NULL, xlab = NULL, ylab = NULL, threshold = 0, aspect_ratio = 1, ... )plot_heatmap( x, cluster_list = NULL, cluster_spacing = 0, show_legend = TRUE, legend_position = "right", legend_title = "Weight", colors = "viridis", limits = NULL, midpoint = NULL, na_color = "grey90", show_values = FALSE, value_size = 2.5, value_color = "black", value_fontface = "plain", value_fontfamily = "sans", value_halo = NULL, value_digits = 2, show_diagonal = TRUE, diagonal_color = NULL, cluster_labels = TRUE, cluster_borders = TRUE, border_color = "black", border_width = 0.5, row_labels = NULL, col_labels = NULL, show_axis_labels = TRUE, axis_text_size = 8, axis_text_angle = 45, title = NULL, subtitle = NULL, xlab = NULL, ylab = NULL, threshold = 0, aspect_ratio = 1, ... )
x |
Network input: matrix, CographNetwork, cograph_network, tna,
igraph, group_tna, or a list-like object with a |
cluster_list |
Optional list of character vectors of node names defining node clusters. The matrix is reordered so that clusters form blocks along the diagonal. Nodes not listed are dropped, and a listed name that is not in the matrix is an error. |
cluster_spacing |
Gap size between clusters (in cell units). Default 0. |
show_legend |
Logical: display color legend? Default TRUE. |
legend_position |
Position: "right" (default), "left", "top", "bottom", "none". |
legend_title |
Title for legend. Default "Weight". |
colors |
Color palette: a vector of colors for the gradient, a palette name ("viridis", "heat", "blues", "reds", "greens", "diverging"), or a single color name, which gives a gradient from white to that color. With a diverging scale the first three colors are used as low, mid and high. Two colors are used as low and high around a white midpoint, and a single color name is used as the high end, with the blue low end and the light gray midpoint of the "diverging" palette. Default "viridis". |
limits |
Numeric vector c(min, max) for color scale. NULL for auto. |
midpoint |
Midpoint of a diverging scale. Supplying it makes the scale diverging. With the default NULL, the scale is diverging around 0 when the values span negative and positive numbers. |
na_color |
Color for NA values. Default "grey90". |
show_values |
Logical: display values in cells? Default FALSE. |
value_size |
Text size for cell values. Default 2.5. |
value_color |
Color for cell value text. Default "black". |
value_fontface |
Font face for values: "plain", "bold", "italic", "bold.italic". Default "plain". |
value_fontfamily |
Font family for values: "sans", "serif", "mono". Default "sans". |
value_halo |
Halo color behind value labels for readability on dark cells. Set to a color (e.g., "white") to enable, or NULL (default) to disable. |
value_digits |
Decimal places for values. Default 2. |
show_diagonal |
Logical: show diagonal values? Default TRUE. |
diagonal_color |
Currently unused. Diagonal cells use the fill scale
unless they are hidden with |
cluster_labels |
Logical: show cluster or group labels? With a
|
cluster_borders |
Logical: plot borders around clusters? Default TRUE. |
border_color |
Color for cluster borders. Default "black". |
border_width |
Width of cluster borders. Default 0.5. |
row_labels |
Row labels for a single-network heatmap. NULL uses the row names or indices. |
col_labels |
Column labels for a single-network heatmap. NULL uses the column names or indices. |
show_axis_labels |
Logical: show axis tick labels? Default TRUE. A clustered heatmap never shows axis tick labels. |
axis_text_size |
Size of axis labels. Default 8. |
axis_text_angle |
Angle for x-axis labels. Default 45. |
title |
Plot title. Default NULL, which gives no title, or
"Supra-Adjacency Heatmap" for |
subtitle |
Plot subtitle. Default NULL. |
xlab |
X-axis label. Default NULL. |
ylab |
Y-axis label. Default NULL. |
threshold |
Minimum absolute value to display. Values with
|
aspect_ratio |
Aspect ratio. Default 1 (square cells). |
... |
Additional arguments (currently unused). |
For group_tna objects, each group network becomes a diagonal block
of a supra-adjacency matrix, with cells labelled group:node. The
off-diagonal blocks are NA and take na_color. The node
labels are taken from the first group.
A ggplot object.
plot_heatmap(regulation_net)plot_heatmap(regulation_net)
Plots a TNA model with nodes arranged in groups by a geometric layout. The
circular layout (the default for layout = "auto") places each group
on an arc of a circle. The bipartite layout places exactly two groups in
two columns, two rows, or facing arrangements. The polygon layout places
three or more groups along the sides of a regular polygon with one side
per group.
plot_htna( x, node_list = NULL, community = NULL, layout = "auto", use_list_order = TRUE, jitter = FALSE, jitter_amount = 0.8, jitter_side = "first", orientation = "vertical", group1_pos = -2, group2_pos = 2, group_spacing = NULL, node_spacing = NULL, columns = 1, column_spacing = NULL, layout_margin = 0.15, curvature = 0.4, group1_color = "#4FC3F7", group2_color = "#fbb550", group1_shape = "circle", group2_shape = "square", group_colors = NULL, group_shapes = NULL, angle_spacing = 0.15, edge_colors = NULL, intra_curvature = NULL, legend = TRUE, legend_position = "bottom", legend_horiz = NULL, legend_ncol = NULL, legend_size = 0.8, extend_lines = FALSE, scale = 1, nodes = NULL, label_abbrev = NULL, ... ) htna( x, node_list = NULL, community = NULL, layout = "auto", use_list_order = TRUE, jitter = FALSE, jitter_amount = 0.8, jitter_side = "first", orientation = "vertical", group1_pos = -2, group2_pos = 2, group_spacing = NULL, node_spacing = NULL, columns = 1, column_spacing = NULL, layout_margin = 0.15, curvature = 0.4, group1_color = "#4FC3F7", group2_color = "#fbb550", group1_shape = "circle", group2_shape = "square", group_colors = NULL, group_shapes = NULL, angle_spacing = 0.15, edge_colors = NULL, intra_curvature = NULL, legend = TRUE, legend_position = "bottom", legend_horiz = NULL, legend_ncol = NULL, legend_size = 0.8, extend_lines = FALSE, scale = 1, nodes = NULL, label_abbrev = NULL, ... )plot_htna( x, node_list = NULL, community = NULL, layout = "auto", use_list_order = TRUE, jitter = FALSE, jitter_amount = 0.8, jitter_side = "first", orientation = "vertical", group1_pos = -2, group2_pos = 2, group_spacing = NULL, node_spacing = NULL, columns = 1, column_spacing = NULL, layout_margin = 0.15, curvature = 0.4, group1_color = "#4FC3F7", group2_color = "#fbb550", group1_shape = "circle", group2_shape = "square", group_colors = NULL, group_shapes = NULL, angle_spacing = 0.15, edge_colors = NULL, intra_curvature = NULL, legend = TRUE, legend_position = "bottom", legend_horiz = NULL, legend_ncol = NULL, legend_size = 0.8, extend_lines = FALSE, scale = 1, nodes = NULL, label_abbrev = NULL, ... ) htna( x, node_list = NULL, community = NULL, layout = "auto", use_list_order = TRUE, jitter = FALSE, jitter_amount = 0.8, jitter_side = "first", orientation = "vertical", group1_pos = -2, group2_pos = 2, group_spacing = NULL, node_spacing = NULL, columns = 1, column_spacing = NULL, layout_margin = 0.15, curvature = 0.4, group1_color = "#4FC3F7", group2_color = "#fbb550", group1_shape = "circle", group2_shape = "square", group_colors = NULL, group_shapes = NULL, angle_spacing = 0.15, edge_colors = NULL, intra_curvature = NULL, legend = TRUE, legend_position = "bottom", legend_horiz = NULL, legend_ncol = NULL, legend_size = 0.8, extend_lines = FALSE, scale = 1, nodes = NULL, label_abbrev = NULL, ... )
x |
A tna object, weight matrix, or cograph_network. |
node_list |
Node groups can be specified as:
Groups must not overlap, every name must be a node of |
community |
Community detection method to use for auto-grouping.
If specified, overrides |
layout |
Layout type: |
use_list_order |
Logical. Use node_list order (TRUE) or weight-based order (FALSE).
Only applies to the bipartite layout with |
jitter |
Controls horizontal spread of nodes. Options:
Only applies to the bipartite layout with |
jitter_amount |
Base jitter amount when jitter=TRUE. Default 0.8. Higher values spread nodes more toward the center. Only applies to bipartite layout. |
jitter_side |
Which side(s) to apply jitter: "first" (or "left"), "second" (or "right"), "both", or "none". Default "first" (only first group nodes are jittered toward center). Only applies to bipartite layout. |
orientation |
Layout orientation for bipartite: "vertical" (two columns, default), "horizontal" (two rows), "facing" (both groups on same horizontal line, group1 left, group2 right, tip-to-tip), or "circular" (two facing semicircles with a gap between them). Ignored for non-bipartite layouts. |
group1_pos |
Position of the first group in the bipartite layout, an
x position for vertical and a y position for horizontal orientation.
Overridden by |
group2_pos |
Position of the second group in the bipartite layout.
Overridden by |
group_spacing |
Numeric. Distance between the two groups in bipartite layout.
Overrides |
node_spacing |
Numeric. Vertical (or horizontal) gap between nodes within a group. Default NULL (computed from the largest number of rows in a group). Increase for more space between nodes (e.g., 0.5 or 0.8). |
columns |
Integer or vector of length 2. Number of sub-columns per group.
A single value applies to both groups. A vector of 2 sets columns per group
independently (e.g., |
column_spacing |
Numeric. Horizontal distance between sub-columns within
a group. Default NULL (auto: |
layout_margin |
Margin around the layout (0-1). Default 0.15. Increase if labels or self-loops are clipped at the edges. |
curvature |
Edge curvature amount. |
group1_color |
Color for first group nodes. |
group2_color |
Color for second group nodes. |
group1_shape |
Shape for first group nodes. |
group2_shape |
Shape for second group nodes. |
group_colors |
Vector of colors for each group. Overrides group1_color/group2_color. If NULL, two-group layouts use group1_color/group2_color and 3+ group layouts cycle through a built-in palette of 12 colors. The length must equal the number of groups. |
group_shapes |
Vector of shapes for each group. Overrides group1_shape/group2_shape. If NULL, two-group layouts use group1_shape/group2_shape and 3+ group layouts cycle through a built-in palette of 8 shapes. The length must equal the number of groups. |
angle_spacing |
Controls empty space at corners (0-1). Default 0.15. Higher values create larger gaps in polygon and circular layouts. For circular auto layout, the default is increased to 0.35 unless explicitly set. |
edge_colors |
Vector of colors for edges by source group. If NULL (default), uses darker versions of group_colors. Set to FALSE to use the default edge color. |
intra_curvature |
Numeric. Curvature amount for intra-group edges (edges between nodes in the same group). When set, intra-group edges are removed from the main plot and added separately as curves that arc away from the opposing group. Default NULL (intra-group edges are plotted by splot). |
legend |
Logical. Whether to show a legend of the groups. |
legend_position |
Position for legend: "topright", "topleft", "bottomright", "bottomleft", "right", "left", "top", "bottom". Side positions place the legend in a reserved margin band, and corner positions place it inside the plot region. |
legend_horiz |
Logical. Force horizontal (TRUE) or vertical (FALSE) legend. NULL (default) auto-selects: horizontal for "top"/"bottom" positions, vertical otherwise. |
legend_ncol |
Integer. Number of columns when the legend is vertical.
NULL (default) lets |
legend_size |
Legend text size ( |
extend_lines |
Logical or numeric. Add extension lines from nodes. Only applies to bipartite layout.
|
scale |
Scaling factor for high-resolution output (e.g., scale = 4
for 300 dpi). The legend text and symbols are divided by
|
nodes |
Node metadata. |
label_abbrev |
Label abbreviation: NULL (none), integer (max chars),
or "auto" (adaptive based on node count). See |
... |
Additional parameters passed to |
Invisibly, the cograph_network object returned by
tplot(). The function is called for its plot.
clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_htna(regulation_net, node_list = clusters)clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_htna(regulation_net, node_list = clusters)
Produces a two-layer hierarchical visualization of a clustered network.
The bottom layer shows every node inside an elliptical cluster shell, with
the within-cluster and between-cluster edges of the individual nodes. The
top layer shows one summary node per cluster, with edges carrying the
aggregated between-cluster weights. By default the colored slice of a
summary node is the cluster's share of the initial state distribution
(see summary_pie). Dashed lines connect each detail node to its
summary node.
plot_mcml( x, cluster_list = NULL, expand = NULL, mode = c("weights", "tna"), theme = c("classic", "rich", "light"), layer_spacing = NULL, spacing = 3, shape_size = 1.2, summary_size = 4, skew_angle = 60, aggregation = c("sum", "mean", "max"), minimum = 0, colors = NULL, legend = TRUE, show_labels = TRUE, nodes = NULL, label_size = NULL, label_abbrev = NULL, node_size = 2.4, node_shape = "circle", cluster_shape = "circle", title = NULL, subtitle = NULL, title_size = 1.2, subtitle_size = 0.9, legend_position = "right", legend_size = 0.7, legend_pt_size = 1.2, summary_labels = TRUE, summary_label_size = 0.8, summary_label_position = 3, summary_label_color = "gray20", summary_arrows = TRUE, summary_arrow_size = 0.1, node_donut = NULL, node_donut_inner_ratio = 0.55, summary_donut_inner_ratio = 0.6, summary_donut_show_value = FALSE, curved_edges = NULL, summary_curve = NULL, summary_pie = c("inits", "self"), edge_color_by = c("auto", "cluster", "sign"), edge_positive_color = "#2E7D32", edge_negative_color = "#C62828", between_arrows = FALSE, edge_width_range = c(0.3, 1.3), between_edge_width_range = c(0.5, 2), summary_edge_width_range = c(0.5, 2), edge_alpha = 0.35, between_edge_alpha = 0.6, summary_edge_alpha = 0.7, inter_layer_alpha = 0.5, edge_labels = FALSE, edge_label_size = 0.5, edge_label_color = "gray40", edge_label_digits = 2, summary_edge_labels = FALSE, summary_edge_label_size = 0.6, top_layer_scale = c(0.8, 0.25), inter_layer_gap = 0.6, node_radius_scale = 0.55, shell_alpha = 0.15, shell_border_width = 0.75, node_border_color = "gray30", node_border_width = 0.4, summary_border_color = "gray20", summary_border_width = 0.6, label_color = "gray20", label_position = 3, directed = NULL, ... )plot_mcml( x, cluster_list = NULL, expand = NULL, mode = c("weights", "tna"), theme = c("classic", "rich", "light"), layer_spacing = NULL, spacing = 3, shape_size = 1.2, summary_size = 4, skew_angle = 60, aggregation = c("sum", "mean", "max"), minimum = 0, colors = NULL, legend = TRUE, show_labels = TRUE, nodes = NULL, label_size = NULL, label_abbrev = NULL, node_size = 2.4, node_shape = "circle", cluster_shape = "circle", title = NULL, subtitle = NULL, title_size = 1.2, subtitle_size = 0.9, legend_position = "right", legend_size = 0.7, legend_pt_size = 1.2, summary_labels = TRUE, summary_label_size = 0.8, summary_label_position = 3, summary_label_color = "gray20", summary_arrows = TRUE, summary_arrow_size = 0.1, node_donut = NULL, node_donut_inner_ratio = 0.55, summary_donut_inner_ratio = 0.6, summary_donut_show_value = FALSE, curved_edges = NULL, summary_curve = NULL, summary_pie = c("inits", "self"), edge_color_by = c("auto", "cluster", "sign"), edge_positive_color = "#2E7D32", edge_negative_color = "#C62828", between_arrows = FALSE, edge_width_range = c(0.3, 1.3), between_edge_width_range = c(0.5, 2), summary_edge_width_range = c(0.5, 2), edge_alpha = 0.35, between_edge_alpha = 0.6, summary_edge_alpha = 0.7, inter_layer_alpha = 0.5, edge_labels = FALSE, edge_label_size = 0.5, edge_label_color = "gray40", edge_label_digits = 2, summary_edge_labels = FALSE, summary_edge_label_size = 0.6, top_layer_scale = c(0.8, 0.25), inter_layer_gap = 0.6, node_radius_scale = 0.55, shell_alpha = 0.15, shell_border_width = 0.75, node_border_color = "gray30", node_border_width = 0.4, summary_border_color = "gray20", summary_border_width = 0.6, label_color = "gray20", label_position = 3, directed = NULL, ... )
x |
A square weight matrix with row and column names matching the
node names in |
cluster_list |
Assignment of nodes to clusters. A named list of
character vectors gives the node names of each cluster, and the list
names become the cluster labels, for example
|
expand |
Names of clusters whose member states are shown as separate
nodes in the summary layer. |
mode |
|
theme |
Visual preset, one of |
layer_spacing |
Vertical position of the summary layer, which sets
the height of the figure. |
spacing |
Distance from the center to each cluster in the bottom layer. Default 3. |
shape_size |
Radius of each cluster shell in the bottom layer. Default 1.2. |
summary_size |
Size of the summary nodes. The radius of a summary
node is |
skew_angle |
Perspective tilt in degrees, from 0 to 90. At 0 the bottom layer is seen from directly above and at 90 it collapses to a line. Default 60. |
aggregation |
Method for aggregating node-level edge weights into
cluster-level weights: |
minimum |
Edge weight threshold. Edges whose absolute weight does not exceed this value are not plotted. Default 0. |
colors |
Character vector of cluster colors, recycled to the number
of clusters. |
legend |
Logical. Add a legend of cluster colors. Default
|
show_labels |
Logical. Show node labels in the bottom layer. Default
|
nodes |
Node metadata data frame for display labels. Its
|
label_size |
Text size ( |
label_abbrev |
Label abbreviation passed to |
node_size |
Size of the detail nodes. The radius of a detail node is
|
node_shape |
Shape of the detail nodes, a single value or one value
per node. |
cluster_shape |
Not used. It is kept for compatibility with earlier versions. |
title |
Plot title. Default |
subtitle |
Subtitle shown below the figure. Default |
title_size |
Text size ( |
subtitle_size |
Text size ( |
legend_position |
Legend position: |
legend_size |
Text size ( |
legend_pt_size |
Point size ( |
summary_labels |
Logical. Show cluster names next to the summary
nodes. Default |
summary_label_size |
Text size of summary labels. Default 0.8. |
summary_label_position |
Position of summary labels relative to their nodes: 1 = below, 2 = left, 3 = above, 4 = right. When it is not supplied, each label is placed on the side of its node that faces away from the center of the summary layer. |
summary_label_color |
Color of summary labels. Default
|
summary_arrows |
Logical. Add arrowheads to summary edges. Default
|
summary_arrow_size |
Size of the arrowheads on summary edges. Default 0.10. |
node_donut |
Logical or |
node_donut_inner_ratio |
Hole size, from 0 to 1, of the detail-node donut. Default 0.55. |
summary_donut_inner_ratio |
Hole size, from 0 to 1, of the summary donut. Default 0.6. |
summary_donut_show_value |
Logical. Print the fill proportion in the
center of each summary donut. Default |
curved_edges |
Logical or |
summary_curve |
Numeric or |
summary_pie |
What the colored slice of a summary node shows.
|
edge_color_by |
Edge coloring on all layers. |
edge_positive_color |
Color of positive edges under sign coloring.
Default |
edge_negative_color |
Color of negative edges under sign coloring.
Default |
between_arrows |
Logical. Add arrowheads to between-cluster edges in
the bottom layer. Default |
edge_width_range |
Numeric vector |
between_edge_width_range |
Numeric vector |
summary_edge_width_range |
Numeric vector |
edge_alpha |
Opacity, from 0 to 1, of within-cluster edges. Default 0.35. |
between_edge_alpha |
Opacity, from 0 to 1, of between-cluster edges. Default 0.6. |
summary_edge_alpha |
Opacity, from 0 to 1, of summary edges. Default 0.7. |
inter_layer_alpha |
Opacity, from 0 to 1, of the dashed inter-layer lines. Default 0.5. |
edge_labels |
Logical. Show weight labels on within-cluster edges.
Default |
edge_label_size |
Text size of within-cluster edge labels. Default 0.5. |
edge_label_color |
Color of within-cluster edge labels. Default
|
edge_label_digits |
Number of decimal places of edge labels on both layers. Default 2. |
summary_edge_labels |
Logical. Show weight labels on summary edges.
Default |
summary_edge_label_size |
Text size of summary edge labels. Default 0.6. |
top_layer_scale |
Numeric vector |
inter_layer_gap |
Vertical distance from the upper edge of the bottom
layer to the center of the summary layer, as a multiple of
|
node_radius_scale |
Radius of the circle of nodes inside each cluster
shell, as a fraction of |
shell_alpha |
Fill opacity, from 0 to 1, of the cluster shells.
Default 0.15, or 0.10 with |
shell_border_width |
Line width of the cluster shell borders. Default
0.75, or 0 with |
node_border_color |
Border color of the detail nodes. Default
|
node_border_width |
Border width of the detail nodes. Default 0.4. |
summary_border_color |
Border color of the summary nodes. Default
|
summary_border_width |
Border width of the summary nodes. Default 0.6. |
label_color |
Text color of detail node labels. Default
|
label_position |
Not used. Detail labels are placed to the left or right of each node according to its position in the shell. |
directed |
Logical or |
... |
Not used. |
For a multi-cluster plot without the summary layer, see
plot_mtna. For stacked multilevel or multiplex layers, see
plot_mlna.
A weight matrix, tna object or cograph_network is passed together with
cluster_list, and the aggregated weights are computed with
csum. A cluster_summary computed beforehand with
csum can be passed as x instead, which avoids
repeating the aggregation when the same clustering is plotted several
times.
For a directed network the aggregated weights are computed with
type = "tna", so each row of the summary matrix sums to 1. For an
undirected network they are computed with type = "cooccurrence".
The mode argument changes only the default of the edge labels.
Bottom-layer clusters are arranged on a circle of radius spacing,
flattened by the perspective skew_angle. Nodes inside each cluster
sit on a smaller circle of radius shape_size * node_radius_scale.
The summary nodes are placed on an oval above the bottom layer whose radii
are set by top_layer_scale.
Invisibly, the cluster_summary object used for plotting. It
can be passed back to plot_mcml(), printed, or converted with
as_tna.
The plot contains four kinds of edges, each with its own visual parameters.
Edges between nodes of the same cluster,
set by edge_width_range, edge_alpha, edge_labels,
edge_label_size, edge_label_color and
edge_label_digits.
Edges between cluster shells, set by
between_edge_width_range, between_edge_alpha and
between_arrows.
Edges between summary nodes, set by
summary_edge_width_range, summary_edge_alpha,
summary_edge_labels, summary_edge_label_size,
summary_arrows and summary_arrow_size.
Lines from each detail node to its summary
node, set by inter_layer_alpha.
csum for the aggregated cluster data,
plot_mtna for a multi-cluster plot without a summary layer,
plot_mlna for stacked multilevel or multiplex layers,
detect_communities for algorithmic cluster detection
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) plot_mcml(regulation_net, clusters)clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) plot_mcml(regulation_net, clusters)
Plots one network that combines the edges of a symmetric matrix, shown as straight undirected edges, with the edges of an asymmetric matrix, shown as curved directed edges.
plot_mixed_network( sym_matrix, asym_matrix, layout = "oval", sym_color = "ivory4", asym_color = COGRAPH_SCALE$tna_edge_color, curvature = 0.3, edge_width = NULL, node_size = 7, title = NULL, threshold = 0, edge_labels = TRUE, arrow_size = 0.61, edge_label_size = 0.6, edge_label_position = 0.7, initial = NULL, ... )plot_mixed_network( sym_matrix, asym_matrix, layout = "oval", sym_color = "ivory4", asym_color = COGRAPH_SCALE$tna_edge_color, curvature = 0.3, edge_width = NULL, node_size = 7, title = NULL, threshold = 0, edge_labels = TRUE, arrow_size = 0.61, edge_label_size = 0.6, edge_label_position = 0.7, initial = NULL, ... )
sym_matrix |
A symmetric matrix of undirected relationships. Each non-zero pair is plotted once as a straight edge without arrows. |
asym_matrix |
An asymmetric matrix of directed relationships, with
the same dimensions as |
layout |
Layout algorithm or coordinate matrix. Default "oval". |
sym_color |
Color for undirected edges. Default |
asym_color |
Color for directed edges. Either a single color, or two
colors for reciprocal pairs: the first for the edge from the
lower-indexed node and the second for the reverse edge. Non-reciprocal
edges use the first color. Default |
curvature |
Curvature magnitude for directed edges. Default 0.3. |
edge_width |
Edge width(s). If NULL (default), widths scale with edge weight as in TNA plots. A numeric value overrides the scaling. |
node_size |
Node size. Default 7. |
title |
Plot title. Default NULL. |
threshold |
Minimum absolute edge weight to display. Values with
|
edge_labels |
Show edge weight labels. Default TRUE. |
arrow_size |
Arrow head size for directed edges. Default 0.61 (TNA style). |
edge_label_size |
Size of edge labels. Default 0.6. |
edge_label_position |
Position of edge labels along edge (0-1). Default 0.7. |
initial |
Optional numeric vector of initial state probabilities. A named vector is matched to the node names, with missing states set to 0; an unnamed vector is used in node order. Nodes are then plotted as donuts filled in proportion to the initial probability. A warning is issued when the values do not sum to 1 (tolerance 0.01). Default NULL. |
... |
Additional arguments passed to |
Invisibly, a list with three elements: edges, a data frame
with one row per plotted edge and columns from, to
(node indices), weight, type ("undirected" or
"directed") and color; and sym_matrix and
asym_matrix, the input matrices after thresholding.
plot_mixed_network(symmetrize(regulation_net, keep_format = TRUE), regulation_net)plot_mixed_network(symmetrize(regulation_net, keep_format = TRUE), regulation_net)
Visualizes multiple network layers as heatmaps on tilted 3D-perspective
planes, in the style of plot_mlna.
plot_ml_heatmap( x, layer_list = NULL, colors = "viridis", layer_spacing = NULL, skew = 0.4, compress = 0.6, show_connections = FALSE, connection_color = "#E63946", connection_style = "dashed", show_borders = TRUE, border_color = "black", border_width = 1, cell_border_color = "white", cell_border_width = 0.2, show_labels = TRUE, show_node_labels = TRUE, node_label_size = 3, label_size = 5, show_legend = TRUE, legend_title = "Weight", title = NULL, limits = NULL, na_color = "grey90", threshold = 0 )plot_ml_heatmap( x, layer_list = NULL, colors = "viridis", layer_spacing = NULL, skew = 0.4, compress = 0.6, show_connections = FALSE, connection_color = "#E63946", connection_style = "dashed", show_borders = TRUE, border_color = "black", border_width = 1, cell_border_color = "white", cell_border_width = 0.2, show_labels = TRUE, show_node_labels = TRUE, node_label_size = 3, label_size = 5, show_legend = TRUE, legend_title = "Weight", title = NULL, limits = NULL, na_color = "grey90", threshold = 0 )
x |
A list of matrices (one per layer), a group_tna object, a
cograph_network, or a single matrix with |
layer_list |
Named list of node vectors, one per layer. For a matrix
|
colors |
Color palette: "viridis", "heat", "blues", "reds", "inferno", "plasma", or a vector of colors. Any other single name gives the viridis colors. Default "viridis". |
layer_spacing |
Vertical spacing between layers, in data units.
|
skew |
Horizontal skew for perspective effect (0-1). Default 0.4. |
compress |
Vertical compression for perspective (0-1). Default 0.6. |
show_connections |
Show inter-layer connection lines? Default FALSE. |
connection_color |
Color for inter-layer connections. Default "#E63946". |
connection_style |
Line style: "dashed", "solid", "dotted". Default "dashed". |
show_borders |
Show layer outline borders? Default TRUE. |
border_color |
Color for layer borders. Default "black". |
border_width |
Width of layer borders. Default 1. |
cell_border_color |
Color for cell borders. Default "white". |
cell_border_width |
Width of cell borders. Default 0.2. |
show_labels |
Show layer name labels? Default TRUE. |
show_node_labels |
Show the row and column names? Default TRUE. When all layers have the same row and column names, the names are shown once, along the left and lower edges of the front plane. When the layers hold different nodes, each plane shows its own row names along its left edge and the column names below the front plane are those of the front (last) layer. |
node_label_size |
Size of the row and column names. Default 3. |
label_size |
Size of layer labels. Default 5. |
show_legend |
Show color legend? Default TRUE. |
legend_title |
Title for legend. Default "Weight". |
title |
Plot title. Default NULL. |
limits |
Color scale limits c(min, max). NULL for auto. |
na_color |
Color for NA values. Default "grey90". |
threshold |
Minimum absolute value to display. Cells with
|
A ggplot2 object.
clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_ml_heatmap(regulation_net, layer_list = clusters)clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_ml_heatmap(regulation_net, layer_list = clusters)
Plots a multilevel network as a stack of layers in a pseudo-3D perspective
view. Each layer is enclosed in a parallelogram shell. Edges within a layer
are plotted as solid curved arrows, and edges between adjacent layers are
plotted as straight lines in the style set by between_style.
plot_mlna( model, layer_list = NULL, community = NULL, layout = "horizontal", layer_spacing = 4, layer_width = 8, layer_depth = 4, skew_angle = 25, node_spacing = 0.7, colors = NULL, shapes = NULL, edge_colors = NULL, within_edges = TRUE, between_edges = TRUE, between_style = 2, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.15, node_size = 3, minimum = 0, scale = 1, show_labels = TRUE, nodes = NULL, label_abbrev = NULL, ... ) mlna( model, layer_list = NULL, community = NULL, layout = "horizontal", layer_spacing = 4, layer_width = 8, layer_depth = 4, skew_angle = 25, node_spacing = 0.7, colors = NULL, shapes = NULL, edge_colors = NULL, within_edges = TRUE, between_edges = TRUE, between_style = 2, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.15, node_size = 3, minimum = 0, scale = 1, show_labels = TRUE, nodes = NULL, label_abbrev = NULL, ... )plot_mlna( model, layer_list = NULL, community = NULL, layout = "horizontal", layer_spacing = 4, layer_width = 8, layer_depth = 4, skew_angle = 25, node_spacing = 0.7, colors = NULL, shapes = NULL, edge_colors = NULL, within_edges = TRUE, between_edges = TRUE, between_style = 2, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.15, node_size = 3, minimum = 0, scale = 1, show_labels = TRUE, nodes = NULL, label_abbrev = NULL, ... ) mlna( model, layer_list = NULL, community = NULL, layout = "horizontal", layer_spacing = 4, layer_width = 8, layer_depth = 4, skew_angle = 25, node_spacing = 0.7, colors = NULL, shapes = NULL, edge_colors = NULL, within_edges = TRUE, between_edges = TRUE, between_style = 2, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.15, node_size = 3, minimum = 0, scale = 1, show_labels = TRUE, nodes = NULL, label_abbrev = NULL, ... )
model |
A tna object, weight matrix, or cograph_network. |
layer_list |
Layer assignment of the nodes. One of
|
community |
Community detection method used to form the layers. When
given, it overrides |
layout |
Node layout within layers. "horizontal" (default) places nodes on a horizontal line, "circle" arranges them in an ellipse, and "spring" uses force-directed placement based on within-layer edges. |
layer_spacing |
Vertical distance between layer centers. Default 4. |
layer_width |
Horizontal width of each layer shell. Default 8. |
layer_depth |
Depth of each layer shell in the perspective view. Default 4. |
skew_angle |
Angle of perspective skew in degrees. Default 25. |
node_spacing |
Proportion of the layer width (0-1) over which nodes are spread. Higher values place nodes closer to the layer edges. Default 0.7. |
colors |
Vector of fill colors, one per layer. NULL (default) uses a built-in palette. |
shapes |
Vector of node shapes, one per layer. Supported values are "circle", "square", "diamond" and "triangle"; other values are plotted as circles. NULL (default) assigns "circle", "square", "diamond" and "triangle" to the first four layers. |
edge_colors |
Vector of colors for between-layer edges, indexed by the source layer. NULL (default) uses a built-in palette. Within-layer edges use a darkened version of the layer color. |
within_edges |
Logical. Plot edges within layers. Default TRUE. |
between_edges |
Logical. Plot edges between adjacent layers. Default TRUE. |
between_style |
Line type of between-layer edges. Default 2 (dashed). Use 1 for solid, 3 for dotted. |
show_border |
Logical. Plot the parallelogram shells around layers. Default TRUE. |
legend |
Logical. Show the layer legend. Default TRUE. |
legend_position |
Position of the legend. Default "topright". |
curvature |
Curvature of within-layer edges. Default 0.15. |
node_size |
Size of nodes. Default 3. |
minimum |
Edge weight threshold. Edges whose weight does not exceed this value are not plotted. Default 0. |
scale |
Scaling factor for high-resolution output (e.g., scale = 4
for 300 dpi). Node sizes, line widths and text sizes are divided by
|
show_labels |
Logical. Show node labels. Default TRUE. |
nodes |
Node metadata. NULL (default) uses the node data of a
cograph_network. A data frame replaces it and must have one row per node
in the node order of |
label_abbrev |
Label abbreviation: NULL (none), integer (max chars), or "auto" (adaptive based on node count). |
... |
Additional parameters (currently unused). |
Invisibly returns NULL.
See plot_mlna.
clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_mlna(regulation_net, layer_list = clusters)clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_mlna(regulation_net, layer_list = clusters)
Plots a network whose nodes are grouped into clusters. Each cluster is plotted as a shell shape containing its nodes. By default, edges between clusters are aggregated into summary edges and edges within clusters are plotted individually.
plot_mtna( x, cluster_list = NULL, community = NULL, layout = "circle", spacing = 4, shape_size = 1.8, node_spacing = 0.5, colors = NULL, shapes = NULL, edge_colors = NULL, bundle_edges = TRUE, bundle_strength = 0.8, summary_edges = TRUE, aggregation = c("sum", "mean", "max", "min", "median", "density"), within_edges = TRUE, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.3, node_size = 3, layout_margin = 0.15, scale = 1, show_labels = FALSE, nodes = NULL, label_size = NULL, label_abbrev = NULL, cluster_shape = NULL, ... ) mtna( x, cluster_list = NULL, community = NULL, layout = "circle", spacing = 4, shape_size = 1.8, node_spacing = 0.5, colors = NULL, shapes = NULL, edge_colors = NULL, bundle_edges = TRUE, bundle_strength = 0.8, summary_edges = TRUE, aggregation = c("sum", "mean", "max", "min", "median", "density"), within_edges = TRUE, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.3, node_size = 3, layout_margin = 0.15, scale = 1, show_labels = FALSE, nodes = NULL, label_size = NULL, label_abbrev = NULL, cluster_shape = NULL, ... )plot_mtna( x, cluster_list = NULL, community = NULL, layout = "circle", spacing = 4, shape_size = 1.8, node_spacing = 0.5, colors = NULL, shapes = NULL, edge_colors = NULL, bundle_edges = TRUE, bundle_strength = 0.8, summary_edges = TRUE, aggregation = c("sum", "mean", "max", "min", "median", "density"), within_edges = TRUE, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.3, node_size = 3, layout_margin = 0.15, scale = 1, show_labels = FALSE, nodes = NULL, label_size = NULL, label_abbrev = NULL, cluster_shape = NULL, ... ) mtna( x, cluster_list = NULL, community = NULL, layout = "circle", spacing = 4, shape_size = 1.8, node_spacing = 0.5, colors = NULL, shapes = NULL, edge_colors = NULL, bundle_edges = TRUE, bundle_strength = 0.8, summary_edges = TRUE, aggregation = c("sum", "mean", "max", "min", "median", "density"), within_edges = TRUE, show_border = TRUE, legend = TRUE, legend_position = "topright", curvature = 0.3, node_size = 3, layout_margin = 0.15, scale = 1, show_labels = FALSE, nodes = NULL, label_size = NULL, label_abbrev = NULL, cluster_shape = NULL, ... )
x |
A tna object, weight matrix, or cograph_network. |
cluster_list |
Cluster assignment of the nodes. One of
|
community |
Community detection method used to form the clusters.
When given, it overrides |
layout |
How to arrange the clusters: "circle" (default), "grid", "horizontal", "vertical". |
spacing |
Distance between cluster centers. Default 4. |
shape_size |
Size of each cluster shape (shell radius). Default 1.8. |
node_spacing |
Radius for node placement within shapes in summary
mode, as a proportion (0-1) of |
colors |
Vector of colors for each cluster. NULL (default) uses a built-in palette. |
shapes |
Vector of shapes for each cluster. Defaults cycle through "circle", "square", "diamond", "triangle", "pentagon", "hexagon", "star", and "cross". In summary mode, shells other than circle, square, diamond and triangle are plotted as circles. |
edge_colors |
Vector of edge colors by source cluster. NULL (default) uses a built-in palette. |
bundle_edges |
Logical. Order the nodes around each shell by the
direction of the clusters they connect to, so that edges toward the
same cluster leave from neighbouring nodes. Used when
|
bundle_strength |
Currently unused. |
summary_edges |
Logical. Show aggregated summary edges between clusters instead of individual node edges. Default TRUE. |
aggregation |
Method for aggregating edge weights between clusters: "sum" (total flow), "mean" (average strength), "max" (strongest link), "min" (weakest link), "median", or "density" (normalized by possible edges). Default "sum". Only used when summary_edges = TRUE. |
within_edges |
Logical. When summary_edges is TRUE, also show individual edges within each cluster. Default TRUE. |
show_border |
Logical. When |
legend |
Logical. Whether to show legend. Default TRUE. |
legend_position |
Position for legend. Default "topright". |
curvature |
Edge curvature. Default 0.3. |
node_size |
Size of nodes inside shapes (summary mode). Default 3. |
layout_margin |
Margin around the layout as fraction of range (summary mode). Default 0.15. |
scale |
Scaling factor for high-resolution output. Values greater than
1 reduce node, edge, label, and legend sizes by |
show_labels |
Logical. Show node labels inside clusters (summary mode). Default FALSE. |
nodes |
Node metadata. NULL (default) uses the node data of a
cograph_network. A data frame replaces it and must have one row per node
in the node order of |
label_size |
Label text size (summary mode). Default NULL (auto-scaled). |
label_abbrev |
Label abbreviation in summary mode: NULL (none), integer (max chars), or "auto" (adaptive based on node count). |
cluster_shape |
Accepted for compatibility; currently unused. Use
|
... |
When |
Invisibly returns a cluster_summary object when
summary_edges = TRUE, and otherwise the
plot_tna() result (a cograph_network object).
See plot_mtna.
clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_mtna(regulation_net, cluster_list = clusters)clusters <- list(Plan = c("Explore", "Plan", "Monitor", "Adapt", "Reflect"), Act = c("Discuss", "Synthesize", "Evaluate", "Create", "Share")) plot_mtna(regulation_net, cluster_list = clusters)
Plots a network at different time points side by side. The input is an
edge list data frame with a time column, a cograph_network whose
stored edge data contain such a column, or a list of networks. All panels
share one node layout. At least two periods are required.
plot_network_evolution( x, time = NULL, slices = NULL, cumulative = FALSE, labels = NULL, layout = "spring", ncol = NULL, node_size = 5, seed = 42, combined = TRUE, ... )plot_network_evolution( x, time = NULL, slices = NULL, cumulative = FALSE, labels = NULL, layout = "spring", ncol = NULL, node_size = 5, seed = 42, combined = TRUE, ... )
x |
An edge list data frame with columns |
time |
Character. Name of the time column in |
slices |
Integer or NULL. Number of equal-width bins of the numeric
time column. Default NULL uses the unique time values. Bins work with
|
cumulative |
Logical. If TRUE, each panel shows all edges up to that time point (growing network). If FALSE (default), each panel shows only edges from that period. |
labels |
Character vector of panel labels, one per period. The
default NULL uses the time values, or |
layout |
Character, or a matrix or data frame of coordinates. Any
character value computes one Fruchterman-Reingold layout from the union
of all edges and uses it for every panel. A matrix or data frame gives
the x and y coordinates of the nodes in its first two columns, one row
per node; rows named after the nodes are matched by name, otherwise they
are taken in node order. Default |
ncol |
Integer. Number of grid columns. The default NULL uses
|
node_size |
Numeric. Node size passed to |
seed |
Integer or NULL. Random seed for the shared layout. The caller's random number state is restored on exit. NULL sets no seed. Default 42. |
combined |
Logical. When TRUE (default), the period panels are
arranged in an internal grid via |
... |
Additional arguments passed to |
Invisibly, a list with one element per period. For data frame
input each element is the edge-list data frame of that period (all
earlier periods included when cumulative = TRUE). For list input
it is the input list.
set.seed(1) edges <- data.frame( from = sample(LETTERS[1:5], 30, replace = TRUE), to = sample(LETTERS[1:5], 30, replace = TRUE), week = sample(1:4, 30, replace = TRUE)) cograph::plot_network_evolution(edges, time = "week")set.seed(1) edges <- data.frame( from = sample(LETTERS[1:5], 30, replace = TRUE), to = sample(LETTERS[1:5], 30, replace = TRUE), week = sample(1:4, 30, replace = TRUE)) cograph::plot_network_evolution(edges, time = "week")
Plots the fraction of nodes remaining in the largest connected component against the fraction of nodes or edges removed, with one line per attack strategy, in base graphics.
plot_robustness( ..., x = NULL, measures = c("betweenness", "degree", "random"), colors = NULL, title = "Network Robustness: sequential removal of nodes", xlab = "Fraction of removed nodes", ylab = "Fraction of remaining nodes", lwd = 1.5, legend_pos = "topright", n_iter = 1000, seed = NULL, type = "vertex" )plot_robustness( ..., x = NULL, measures = c("betweenness", "degree", "random"), colors = NULL, title = "Network Robustness: sequential removal of nodes", xlab = "Fraction of removed nodes", ylab = "Fraction of remaining nodes", lwd = 1.5, legend_pos = "topright", n_iter = 1000, seed = NULL, type = "vertex" )
... |
One or more robustness results from |
x |
Network on which robustness is computed for each of
|
measures |
Character vector of attack strategies to compare when
|
colors |
Vector of colors named by measure ( |
title |
Plot title. Default "Network Robustness: sequential removal of nodes". |
xlab |
X-axis label. Default "Fraction of removed nodes". |
ylab |
Y-axis label. Default "Fraction of remaining nodes". |
lwd |
Line width. Default 1.5. |
legend_pos |
Legend position. Default "topright". |
n_iter |
Number of iterations for random removal when |
seed |
Random seed. Default NULL. |
type |
Removal type, "vertex" or "edge", when |
Invisibly, a cograph_robustness data frame that stacks the
plotted results (columns as in robustness).
plot_robustness(x = regulation_net, n_iter = 20, seed = 1)plot_robustness(x = regulation_net, n_iter = 20, seed = 1)
Visualizes higher-order pathways as smooth blobs overlaid on a network
layout. Source nodes are filled with node_color (blue by default)
and target nodes with target_color (orange by default).
plot_simplicial( x = NULL, pathways = NULL, method = "hon", max_pathways = 10L, pathway_index = NULL, anomaly = c("all", "over", "under"), layout = "circle", labels = NULL, node_color = "#4A7FB5", target_color = "#E8734A", ring_color = "#F5A623", node_size = 22, label_size = 5, label_color = "#e8e8e8", target_label_color = NULL, label_halo = TRUE, label_halo_color = NULL, label_halo_width = 0.035, label_halo_alpha = 0.6, blob_alpha = 0.25, blob_colors = NULL, blob_linetype = NULL, blob_linewidth = 0.7, blob_line_alpha = 0.8, shadow = TRUE, title = NULL, dismantled = FALSE, ncol = NULL, ordered = NULL, direction = NULL, direction_cues = c("shade", "ring", "arrows"), node_radius = NULL, legend = NULL, ... )plot_simplicial( x = NULL, pathways = NULL, method = "hon", max_pathways = 10L, pathway_index = NULL, anomaly = c("all", "over", "under"), layout = "circle", labels = NULL, node_color = "#4A7FB5", target_color = "#E8734A", ring_color = "#F5A623", node_size = 22, label_size = 5, label_color = "#e8e8e8", target_label_color = NULL, label_halo = TRUE, label_halo_color = NULL, label_halo_width = 0.035, label_halo_alpha = 0.6, blob_alpha = 0.25, blob_colors = NULL, blob_linetype = NULL, blob_linewidth = 0.7, blob_line_alpha = 0.8, shadow = TRUE, title = NULL, dismantled = FALSE, ncol = NULL, ordered = NULL, direction = NULL, direction_cues = c("shade", "ring", "arrows"), node_radius = NULL, legend = NULL, ... )
x |
A network object: |
pathways |
Character vector of pathway strings, a list of character
vectors, a |
method |
Pathway source when building from a |
max_pathways |
Maximum number of pathways to display. HON pathways are
ranked by count and HYPA pathways by anomaly ratio. |
pathway_index |
Optional positive integer vector selecting ranked
pathways before |
anomaly |
HYPA anomaly type to display, one of |
layout |
|
labels |
Display labels. |
node_color |
Source node fill color. |
target_color |
Target node fill color. |
ring_color |
Donut ring color. |
node_size |
Node point size. |
label_size |
Label text size. |
label_color |
Label text color for source and target nodes. Default
|
target_label_color |
Target-node label color. |
label_halo |
Logical. Place a contrasting halo behind each label so
that it stays readable on node, blob and background fills. Default
|
label_halo_color |
Halo color. |
label_halo_width |
Halo thickness in plot units. Default
|
label_halo_alpha |
Halo opacity, from 0 to 1. Default |
blob_alpha |
Blob fill transparency. |
blob_colors |
Blob fill colors (recycled). |
blob_linetype |
Blob border line styles (recycled). |
blob_linewidth |
Blob border line width. |
blob_line_alpha |
Blob border line transparency. |
shadow |
Add soft drop shadows? |
title |
Plot title of the combined overlay. |
dismantled |
If |
ncol |
Number of columns in the grid when |
ordered |
Logical. |
direction |
Logical. Show the order of traversal in each per-pathway
panel by a light-to-dark shading of the node cores along the path, a ring
whose |
direction_cues |
Which direction cues to show, any of |
node_radius |
Node core radius in data units, used in panels that show
direction. |
legend |
Add a legend strip beneath a dismantled grid. |
... |
Additional arguments passed to |
When x is a tna or netobject model with sequence data
and pathways is NULL, the pathways are built from the
sequences with the Nestimate package. Pathways passed as
net_hon or net_hypa objects have their numeric state
identifiers translated to labels when x is a tna or
netobject.
Invisibly, a ggplot object for the combined overlay. With
dismantled = TRUE the arranged grid is returned instead, as a
gtable when gridExtra is available and otherwise as a list of
the per-pathway ggplot objects. NULL is returned, with a
message, when no pathways could be extracted. The figure is printed as a
side effect.
plot_simplicial(regulation_net, c("Plan Monitor -> Adapt", "Explore Reflect -> Plan"))plot_simplicial(regulation_net, c("Plan Monitor -> Adapt", "Explore Reflect -> Plan"))
Plots a network at different time points as vertical planes inside a 3D oblique-projection box, with time running from left to right. Each network plane extends into the depth of the box, and all planes share one node layout. At least two time points are required.
plot_temporal( x, time = NULL, slices = NULL, cumulative = FALSE, labels = NULL, layout = "spring", node_size = 2.5, node_color = "steelblue", color_by = c("layer", "node"), node_shape = 21, node_border = "gray30", edge_color = "#E41A1C", edge_width = 1.5, edge_alpha = 0.35, plane_color = "gray92", plane_alpha = 0.2, plane_border = "gray60", plane_lty = 2, box = TRUE, box_color = "gray40", connections = FALSE, connection_color = "gray50", connection_alpha = 0.15, minimum = 0, show_labels = FALSE, label_size = 0.4, title = NULL, angle = c(1, 0.7), seed = 42, ... )plot_temporal( x, time = NULL, slices = NULL, cumulative = FALSE, labels = NULL, layout = "spring", node_size = 2.5, node_color = "steelblue", color_by = c("layer", "node"), node_shape = 21, node_border = "gray30", edge_color = "#E41A1C", edge_width = 1.5, edge_alpha = 0.35, plane_color = "gray92", plane_alpha = 0.2, plane_border = "gray60", plane_lty = 2, box = TRUE, box_color = "gray40", connections = FALSE, connection_color = "gray50", connection_alpha = 0.15, minimum = 0, show_labels = FALSE, label_size = 0.4, title = NULL, angle = c(1, 0.7), seed = 42, ... )
x |
An edge list data frame with columns |
time |
Character. Name of the time column. Required for data frame input. It also labels the time axis. |
slices |
Integer or NULL. Number of equal-width bins of the numeric time column. Empty bins are kept as empty planes. Default NULL uses the unique time values. |
cumulative |
Logical. If TRUE, each plane contains all edges up to its time point. Default FALSE. |
labels |
Character vector of layer labels, one per plane. The default
NULL uses the time values, or |
layout |
Character or matrix. A character value computes one
Fruchterman-Reingold layout from the summed network. A two-column matrix
supplies shared coordinates, one row per node. Default |
node_size |
Numeric. Point size ( |
node_color |
Character or vector. Node fill color. A single color
applies to every node. An unnamed vector is recycled across layers and
colors each plane as a whole, unless |
color_by |
One of |
node_shape |
Integer. Point shape ( |
node_border |
Character. Node border color. Default |
edge_color |
Character or vector. Edge color (single or per-layer).
Default |
edge_width |
Numeric. Maximum added edge width. An edge has width
|
edge_alpha |
Numeric. Edge transparency (0-1). Default 0.35. |
plane_color |
Character or vector. Plane fill color (single or
per-layer). Default |
plane_alpha |
Numeric. Plane fill transparency (0-1). Default 0.2. |
plane_border |
Character. Plane border color. Default
|
plane_lty |
Integer. Plane border line type. Default 2 (dashed). |
box |
Logical. Whether the 3D bounding box is plotted. Default TRUE. |
box_color |
Character. Box edge color. Default |
connections |
Logical. Whether lines connect each node to itself on the next plane. Default FALSE. |
connection_color |
Character. Color of the connecting lines. Default
|
connection_alpha |
Numeric. Transparency of the connecting lines. Default 0.15. |
minimum |
Numeric. Only edges with weight greater than
|
show_labels |
Logical. Show node labels. Default FALSE. |
label_size |
Numeric. Label text size. Default 0.4. |
title |
Character or NULL. Plot title. Default NULL. |
angle |
Numeric vector of length 2: |
seed |
Integer or NULL. Random seed for the shared layout. The caller's random number state is restored on exit. NULL sets no seed. Default 42. |
... |
Currently unused. |
Invisibly, a list of weight matrices, one per plane, with one row and one column per node.
plot_network_evolution, plot_mlna
set.seed(1) edges <- data.frame( from = sample(LETTERS[1:5], 30, replace = TRUE), to = sample(LETTERS[1:5], 30, replace = TRUE), week = sample(1:3, 30, replace = TRUE)) cograph::plot_temporal(edges, time = "week")set.seed(1) edges <- data.frame( from = sample(LETTERS[1:5], 30, replace = TRUE), to = sample(LETTERS[1:5], 30, replace = TRUE), week = sample(1:3, 30, replace = TRUE)) cograph::plot_temporal(edges, time = "week")
Plots a network with splot() and TNA styling, using qgraph argument
names such as vsize, edge.color and pie.
tplot() is an alias.
plot_tna( x, color = NULL, labels = NULL, layout = "oval", theme = "colorblind", mar = c(0.1, 0.1, 0.1, 0.1), cut = NULL, edge.label.position = 0.7, edge.label.cex = 0.6, edge.color = COGRAPH_SCALE$tna_edge_color, vsize = 7, pie = NULL, pieColor = NULL, lty = NULL, directed = NULL, minimum = NULL, posCol = NULL, negCol = NULL, arrowAngle = NULL, title = NULL, ... ) tplot( x, color = NULL, labels = NULL, layout = "oval", theme = "colorblind", mar = c(0.1, 0.1, 0.1, 0.1), cut = NULL, edge.label.position = 0.7, edge.label.cex = 0.6, edge.color = COGRAPH_SCALE$tna_edge_color, vsize = 7, pie = NULL, pieColor = NULL, lty = NULL, directed = NULL, minimum = NULL, posCol = NULL, negCol = NULL, arrowAngle = NULL, title = NULL, ... )plot_tna( x, color = NULL, labels = NULL, layout = "oval", theme = "colorblind", mar = c(0.1, 0.1, 0.1, 0.1), cut = NULL, edge.label.position = 0.7, edge.label.cex = 0.6, edge.color = COGRAPH_SCALE$tna_edge_color, vsize = 7, pie = NULL, pieColor = NULL, lty = NULL, directed = NULL, minimum = NULL, posCol = NULL, negCol = NULL, arrowAngle = NULL, title = NULL, ... ) tplot( x, color = NULL, labels = NULL, layout = "oval", theme = "colorblind", mar = c(0.1, 0.1, 0.1, 0.1), cut = NULL, edge.label.position = 0.7, edge.label.cex = 0.6, edge.color = COGRAPH_SCALE$tna_edge_color, vsize = 7, pie = NULL, pieColor = NULL, lty = NULL, directed = NULL, minimum = NULL, posCol = NULL, negCol = NULL, arrowAngle = NULL, title = NULL, ... )
x |
A weight matrix (adjacency matrix) or tna object |
color |
Node fill colors |
labels |
Node labels |
layout |
Layout: "oval" (default), "circle", "spring", or a coordinate matrix. |
theme |
Plot theme. Default "colorblind". |
mar |
Plot margins (numeric vector of length 4) |
cut |
Edge emphasis threshold, passed to |
edge.label.position |
Position of edge labels along edge (0-1) |
edge.label.cex |
Edge label size multiplier |
edge.color |
Edge colors |
vsize |
Node size |
pie |
Donut fill values in 0-1 (for example, initial probabilities). |
pieColor |
Donut fill colors. |
lty |
Line type for edges: 1 solid, 2 dashed, 3 dotted, 4 dotdash, 5 longdash, 6 twodash, or a line-type name. |
directed |
Logical, is the graph directed? NULL (default) treats a symmetric weight matrix as undirected and any other input as directed. |
minimum |
Minimum absolute edge weight to display, passed to
|
posCol |
Color for positive edges |
negCol |
Color for negative edges |
arrowAngle |
Arrow head angle in radians. Default NULL, which leaves
|
title |
Plot title |
... |
Additional arguments passed to |
The cograph_network object returned by splot(),
invisibly.
plot_tna(regulation_net)plot_tna(regulation_net)
Creates an alluvial-style diagram in which each individual's trajectory is
plotted as a separate line. It calls plot_transitions() with
track_individuals = TRUE.
plot_trajectories( x, from_title = NULL, title = NULL, from_colors = NULL, flow_color_by = "first", node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), mid_label_position = NULL, label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, line_alpha = 0.3, line_width = 0.5, jitter_amount = 0.8, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", show_values = FALSE, value_position = c("center", "origin", "destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, value_digits = 2, column_gap = 1, proportional_nodes = TRUE, node_label_format = NULL, bundle_size = NULL, bundle_legend = TRUE, bundle_legend_size = 3, bundle_legend_color = "grey50", bundle_legend_fontface = "italic", bundle_legend_position = c("bottom", "top") )plot_trajectories( x, from_title = NULL, title = NULL, from_colors = NULL, flow_color_by = "first", node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), mid_label_position = NULL, label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, line_alpha = 0.3, line_width = 0.5, jitter_amount = 0.8, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", show_values = FALSE, value_position = c("center", "origin", "destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, value_digits = 2, column_gap = 1, proportional_nodes = TRUE, node_label_format = NULL, bundle_size = NULL, bundle_legend = TRUE, bundle_legend_size = 3, bundle_legend_color = "grey50", bundle_legend_fontface = "italic", bundle_legend_position = c("bottom", "top") )
x |
Data frame with one column per time point and one row per
individual trajectory, or a |
from_title |
Column titles. Default |
title |
Optional plot title. |
from_colors |
Colors for the left-side nodes. In multi-step and individual-tracking plots, the colors of all states. Default NULL uses the built-in palette. |
flow_color_by |
Color trajectory lines by state. Supports
|
node_width |
Width of node rectangles (0-1 scale). Default 0.08. |
node_border |
Border color for nodes. Default NA (no border). |
node_spacing |
Vertical spacing between nodes (0-1 scale). Default 0.02. |
label_size |
Size of node labels. Default 3.5. |
label_position |
Position of node labels: "beside" (default),
"inside", "above", "below", "outside". In multi-step and
individual-tracking plots, "beside" and "outside" label the first and
last columns only. See |
mid_label_position |
Position of labels for intermediate (middle)
columns in individual-tracking plots. Same options as
|
label_halo |
Logical: add a white halo around labels and column titles? Default TRUE. |
label_color |
Color of state name labels. Default "black". Applied to multi-step and individual-tracking plots. Two-column aggregate plots use black external labels and white inside labels. |
label_fontface |
Font face of state name labels ("plain", "bold", "italic", "bold.italic"). Default "plain". Applied to multi-step and individual-tracking plots. |
label_nudge |
Distance between node edge and label (in plot units). Default 0.02. Used by multi-step and individual-tracking plots. |
title_size |
Size of column titles. Default 5. |
title_color |
Color of column title text. Default "black". Applied to multi-step and individual-tracking plots. |
title_fontface |
Font face of column titles. Default "bold". Applied to multi-step and individual-tracking plots. |
curve_strength |
Controls bezier curve shape (0-1). Default 0.6. |
line_alpha |
Alpha for individual tracking lines. Default 0.3. When bundling is active, values up to 0.3 are raised to 0.9 and larger values are increased by 0.3, capped at 1. |
line_width |
Width of individual tracking lines. Default 0.5. When
bundling is active, widths range from |
jitter_amount |
Currently unused. Lines are spaced evenly within each node. Default 0.8. |
show_totals |
Logical: show total counts on nodes? Default FALSE. |
total_size |
Size of total labels. Default 4. |
total_color |
Color of total labels. Default "white". |
total_fontface |
Font face of total labels. Default "bold". Applied to multi-step and individual-tracking plots. |
show_values |
Logical: show transition counts on flows? Default FALSE. |
value_position |
Position of trajectory value labels: |
value_size |
Size of value labels on flows. Default 3. |
value_color |
Color of value labels. Default "black". |
value_halo |
Logical: add halo around flow value labels? Default NULL
uses |
value_fontface |
Font face of flow value labels. Default "bold". Applied to multi-step and individual-tracking plots. |
value_nudge |
Distance of value labels from node edge when using "origin" or "destination" positions. Default 0.03. |
value_min |
Minimum count to show a flow value label in multi-step and
individual-tracking plots. Default 0 (show all). Two-column aggregate
plots show every nonzero value label when |
value_digits |
Number of decimal places for flow value labels and node totals. Default 2. |
column_gap |
Horizontal spread of columns (0-1) for multi-step and individual-tracking plots. Default 1 uses the full width. Smaller values (e.g., 0.6) bring the columns closer together. |
proportional_nodes |
Logical: size nodes proportionally to counts in individual-tracking plots? When FALSE, all states in a column have equal height. Default TRUE. |
node_label_format |
Format string for node labels with |
bundle_size |
Controls line bundling for large datasets in individual-tracking plots. Default NULL (no bundling). A value of 1 or more sets the number of cases each line represents. A value in (0, 1) sets the fraction of the original number of lines to keep (e.g., 0.15 keeps about 15 percent). Paths with fewer than half the cases of one line are dropped. |
bundle_legend |
Logical or character: show an annotation when
bundling is active? Default TRUE shows "Each line ~ N cases". A string
is used as custom text, with |
bundle_legend_size |
Size of the bundle legend text. Default 3. |
bundle_legend_color |
Color of the bundle legend text. Default "grey50". |
bundle_legend_fontface |
Font face of the bundle legend text. Default "italic". |
bundle_legend_position |
Position of the bundle legend: "bottom" (default) or "top". |
A ggplot object.
plot_transitions, plot_alluvial
df <- data.frame( Baseline = c("Light", "Light", "Intense", "Resource"), Week4 = c("Light", "Intense", "Intense", "Light"), Week8 = c("Resource", "Intense", "Light", "Light")) plot_trajectories(df, flow_color_by = "first")df <- data.frame( Baseline = c("Light", "Light", "Intense", "Resource"), Week4 = c("Light", "Intense", "Intense", "Light"), Week8 = c("Resource", "Intense", "Light", "Light")) plot_trajectories(df, flow_color_by = "first")
Creates an alluvial (Sankey) diagram of how items flow from one set of
categories to another, for example cluster membership changes or state
changes between time points. Aggregated flows are plotted as ribbons whose
width is proportional to the transition count. With
track_individuals = TRUE, each row of a data frame is plotted as a
separate line.
plot_transitions( x, from_title = "From", to_title = "To", title = NULL, from_colors = NULL, to_colors = NULL, flow_fill = "#888888", flow_alpha = 0.4, flow_color_by = NULL, flow_border = NA, flow_border_width = 0.5, node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), mid_label_position = NULL, label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, show_values = FALSE, value_position = c("center", "origin", "destination", "outside_origin", "outside_destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", conserve_flow = TRUE, min_flow = 0, threshold = 0, value_digits = 2, column_gap = 1, track_individuals = FALSE, line_alpha = 0.3, line_width = 0.5, jitter_amount = 0.8, proportional_nodes = TRUE, node_label_format = NULL, bundle_size = NULL, bundle_legend = TRUE, bundle_legend_size = 3, bundle_legend_color = "grey50", bundle_legend_fontface = "italic", bundle_legend_position = c("bottom", "top") )plot_transitions( x, from_title = "From", to_title = "To", title = NULL, from_colors = NULL, to_colors = NULL, flow_fill = "#888888", flow_alpha = 0.4, flow_color_by = NULL, flow_border = NA, flow_border_width = 0.5, node_width = 0.08, node_border = NA, node_spacing = 0.02, label_size = 3.5, label_position = c("beside", "inside", "above", "below", "outside"), mid_label_position = NULL, label_halo = TRUE, label_color = "black", label_fontface = "plain", label_nudge = 0.02, title_size = 5, title_color = "black", title_fontface = "bold", curve_strength = 0.6, show_values = FALSE, value_position = c("center", "origin", "destination", "outside_origin", "outside_destination"), value_size = 3, value_color = "black", value_halo = NULL, value_fontface = "bold", value_nudge = 0.03, value_min = 0, show_totals = FALSE, total_size = 4, total_color = "white", total_fontface = "bold", conserve_flow = TRUE, min_flow = 0, threshold = 0, value_digits = 2, column_gap = 1, track_individuals = FALSE, line_alpha = 0.3, line_width = 0.5, jitter_amount = 0.8, proportional_nodes = TRUE, node_label_format = NULL, bundle_size = NULL, bundle_legend = TRUE, bundle_legend_size = 3, bundle_legend_color = "grey50", bundle_legend_fontface = "italic", bundle_legend_position = c("bottom", "top") )
x |
Input data in one of these formats:
|
from_title |
Title for the left column. Default "From". For multi-step and individual-tracking plots, a vector with one title per column. Data frame input then uses the column names by default, and a vector shorter than the number of columns is replaced by "T1", "T2", ... |
to_title |
Title for the right column. Default "To". Ignored for multi-step plots. |
title |
Optional plot title. |
from_colors |
Colors for the left-side nodes. In multi-step and individual-tracking plots, the colors of all states. Default NULL uses the built-in palette. |
to_colors |
Colors for the right-side nodes in two-column plots. Default NULL uses the built-in palette. |
flow_fill |
Fill color for flows. Default "#888888" (grey). In
multi-step plots it is replaced by the state colors when
|
flow_alpha |
Alpha transparency for flows. Default 0.4. |
flow_color_by |
Color flows by state. Multi-step aggregate plots
accept |
flow_border |
Border color for flows. Default NA (no border). |
flow_border_width |
Line width for flow borders. Default 0.5. |
node_width |
Width of node rectangles (0-1 scale). Default 0.08. |
node_border |
Border color for nodes. Default NA (no border). |
node_spacing |
Vertical spacing between nodes (0-1 scale). Default 0.02. |
label_size |
Size of node labels. Default 3.5. |
label_position |
Position of node labels: "beside" (default),
"inside", "above", "below", "outside". In multi-step and
individual-tracking plots, "beside" and "outside" label the first and
last columns only. See |
mid_label_position |
Position of labels for intermediate (middle)
columns in individual-tracking plots. Same options as
|
label_halo |
Logical: add a white halo around labels and column titles? Default TRUE. |
label_color |
Color of state name labels. Default "black". Applied to multi-step and individual-tracking plots. Two-column aggregate plots use black external labels and white inside labels. |
label_fontface |
Font face of state name labels ("plain", "bold", "italic", "bold.italic"). Default "plain". Applied to multi-step and individual-tracking plots. |
label_nudge |
Distance between node edge and label (in plot units). Default 0.02. Used by multi-step and individual-tracking plots. |
title_size |
Size of column titles. Default 5. |
title_color |
Color of column title text. Default "black". Applied to multi-step and individual-tracking plots. |
title_fontface |
Font face of column titles. Default "bold". Applied to multi-step and individual-tracking plots. |
curve_strength |
Controls bezier curve shape (0-1). Default 0.6. |
show_values |
Logical: show transition counts on flows? Default FALSE. |
value_position |
Position of flow values: "center", "origin", "destination", "outside_origin", "outside_destination". Default "center". Individual-tracking plots use "center", "origin" and "destination". |
value_size |
Size of value labels on flows. Default 3. |
value_color |
Color of value labels. Default "black". |
value_halo |
Logical: add halo around flow value labels? Default NULL
uses |
value_fontface |
Font face of flow value labels. Default "bold". Applied to multi-step and individual-tracking plots. |
value_nudge |
Distance of value labels from node edge when using "origin" or "destination" positions. Default 0.03. |
value_min |
Minimum count to show a flow value label in multi-step and
individual-tracking plots. Default 0 (show all). Two-column aggregate
plots show every nonzero value label when |
show_totals |
Logical: show total counts on nodes? Default FALSE. |
total_size |
Size of total labels. Default 4. |
total_color |
Color of total labels. Default "white". |
total_fontface |
Font face of total labels. Default "bold". Applied to multi-step and individual-tracking plots. |
conserve_flow |
Logical. When TRUE (default), node heights on both sides of a two-column plot are proportions of the same total flow. When FALSE, each side is scaled to its own total. Ignored for multi-step and individual-tracking plots. |
min_flow |
Minimum flow value to display in aggregate plots. Default 0 (show all). |
threshold |
Minimum flow value to display in aggregate plots. Flows
below |
value_digits |
Number of decimal places for flow value labels and node totals. Default 2. |
column_gap |
Horizontal spread of columns (0-1) for multi-step and individual-tracking plots. Default 1 uses the full width. Smaller values (e.g., 0.6) bring the columns closer together. |
track_individuals |
Logical: plot individual lines instead of
aggregated flows? Default FALSE. When TRUE and |
line_alpha |
Alpha for individual tracking lines. Default 0.3. When bundling is active, values up to 0.3 are raised to 0.9 and larger values are increased by 0.3, capped at 1. |
line_width |
Width of individual tracking lines. Default 0.5. When
bundling is active, widths range from |
jitter_amount |
Currently unused. Lines are spaced evenly within each node. Default 0.8. |
proportional_nodes |
Logical: size nodes proportionally to counts in individual-tracking plots? When FALSE, all states in a column have equal height. Default TRUE. |
node_label_format |
Format string for node labels with |
bundle_size |
Controls line bundling for large datasets in individual-tracking plots. Default NULL (no bundling). A value of 1 or more sets the number of cases each line represents. A value in (0, 1) sets the fraction of the original number of lines to keep (e.g., 0.15 keeps about 15 percent). Paths with fewer than half the cases of one line are dropped. |
bundle_legend |
Logical or character: show an annotation when
bundling is active? Default TRUE shows "Each line ~ N cases". A string
is used as custom text, with |
bundle_legend_size |
Size of the bundle legend text. Default 3. |
bundle_legend_color |
Color of the bundle legend text. Default "grey50". |
bundle_legend_fontface |
Font face of the bundle legend text. Default "italic". |
bundle_legend_position |
Position of the bundle legend: "bottom" (default) or "top". |
A ggplot object.
plot_transitions(regulation_net)plot_transitions(regulation_net)
Plot methods and plotting functions for the result objects returned by the analysis functions of cograph and by the tna and Nestimate packages. Each function accepts one class of result.
plot() or plot_motifs() on a cograph_motif_result
From
motifs() or subgraphs(). Plots triad
diagrams, MAN type frequencies, z-scores or MAN pattern diagrams.
plot() on a cograph_motif_analysis
From
extract_motifs(). Plots the same four views as above.
plot() on a cograph_motifs
From
motif_census(). Plots motif z-scores colored by
significance direction, a z-score heatmap or diagrams of the selected
motifs.
plot() on a cograph_communities
From
communities(). Plots the network with nodes grouped by
community through splot().
plot() on a cograph_core_periphery
From
core_periphery(). Plots the network with core nodes
enlarged and periphery nodes reduced.
plot() on a cograph_rich_club
From
rich_club(). Plots the rich club curve with the null
model band, or the club members on the network.
plot() on a cograph_degree_fit
From
fit_degree_distribution(). Plots a histogram of the
observed degrees with the fitted distribution curves overlaid.
plot() on a cograph_vulnerability
From
vulnerability(). Plots the node vulnerability scores as a
bar chart.
plot() and splot() on a tna_disparity
From
disparity_filter(). plot() plots the backbone or
the original and backbone networks side by side. splot() plots
the full network with backbone edges solid and the remaining edges
dashed and faded.
splot() on a tna_bootstrap
From
tna::bootstrap(). Plots the network with significant and
non-significant edges styled differently.
plot_permutation() or splot() on a
tna_permutation
From tna::permutation_test(). Plots the
edge differences between two networks, colored by sign and styled by
significance.
plot_group_permutation() or splot() on a
group_tna_permutation
From tna::permutation_test() on a
group_tna model. Plots one panel per pairwise comparison.
plot_netobject_group() or plot() on a
netobject_group
A named list of Nestimate networks. Plots one panel per group.
plot_net_bootstrap_group() or plot() on a
net_bootstrap_group
A list of Nestimate net_bootstrap
results. Plots one panel per group with significance styling.
plot_netobject_ml() or plot() on a
netobject_ml
A multilevel Nestimate network. Plots the between-person and within-person networks side by side.
plot_net_stability() on a net_stability
From
Nestimate::centrality_stability(). Plots the mean correlation of
each centrality measure with the original against the proportion of
cases dropped.
## S3 method for class 'cograph_communities' plot(x, network = NULL, ...) ## S3 method for class 'cograph_core_periphery' plot( x, core_color = "#E41A1C", periphery_color = "#377EB8", core_size = 12, periphery_size = 6, ... ) ## S3 method for class 'tna_disparity' plot(x, type = c("backbone", "comparison"), combined = TRUE, ...) splot.tna_disparity( x, show = c("styled", "backbone", "full"), edge_style_sig = 1, edge_style_nonsig = 2, alpha_nonsig = 0.3, ... ) ## S3 method for class 'cograph_degree_fit' plot( x, which = NULL, log = "", cols = NULL, lwd = 2, main = "Degree Distribution Fit", ... ) ## S3 method for class 'cograph_motif_result' plot( x, type = c("triads", "types", "significance", "patterns"), n = 15, ncol = 5, colors = c("#2166AC", "#B2182B"), node_size = 5, label_size = 11, title_size = 12, stats_size = 13, legend_size = 13, legend = TRUE, motif_color = "#800020", spacing = 1, base_size = 12, combined = TRUE, ... ) plot_motifs( x, type = c("triads", "types", "significance", "patterns"), n = 15, ncol = 5, colors = c("#2166AC", "#B2182B"), node_size = 5, label_size = 11, title_size = 12, stats_size = 13, legend_size = 13, legend = TRUE, motif_color = "#800020", spacing = 1, base_size = 12, ... ) ## S3 method for class 'cograph_motif_analysis' plot( x, type = c("triads", "types", "significance", "patterns"), n = 20, colors = c("#2166AC", "#B2182B"), res = 72, node_size = 5, label_size = 7, title_size = 7, stats_size = 5, ncol = 5, legend = TRUE, color = "#800020", spacing = 1, combined = TRUE, ... ) ## S3 method for class 'cograph_motifs' plot( x, type = c("bar", "heatmap", "network"), show_nonsig = FALSE, top_n = NULL, colors = c("#2166AC", "#F7F7F7", "#B2182B"), combined = TRUE, ... ) splot.tna_bootstrap( x, display = c("styled", "significant", "full", "ci"), edge_style_sig = 1, edge_style_nonsig = 2, color_nonsig = "#888888", show_ci = FALSE, show_stars = TRUE, width_by = NULL, inherit_style = TRUE, ... ) plot_netobject_group( x, nrow = NULL, ncol = NULL, common_scale = TRUE, title_prefix = NULL, combined = TRUE, ... ) plot_netobject_ml( x, layout = NULL, common_scale = TRUE, titles = c("Between-person", "Within-person"), combined = TRUE, ... ) plot_net_bootstrap_group( x, nrow = NULL, ncol = NULL, common_scale = TRUE, combined = TRUE, ... ) plot_net_stability(x, ...) splot.tna_permutation(x, ...) splot.group_tna_permutation(x, ...) plot_permutation( x, show_nonsig = FALSE, edge_positive_color = "#009900", edge_negative_color = "#C62828", edge_nonsig_color = "#888888", edge_nonsig_style = 2, show_stars = TRUE, show_effect = FALSE, edge_nonsig_alpha = 0.4, ... ) plot_group_permutation(x, i = NULL, combined = TRUE, ...) ## S3 method for class 'cograph_rich_club' plot(x, type = c("curve", "network"), k = NULL, col = "#E41A1C", ...) ## S3 method for class 'cograph_vulnerability' plot(x, top = NULL, col = "steelblue", ...)## S3 method for class 'cograph_communities' plot(x, network = NULL, ...) ## S3 method for class 'cograph_core_periphery' plot( x, core_color = "#E41A1C", periphery_color = "#377EB8", core_size = 12, periphery_size = 6, ... ) ## S3 method for class 'tna_disparity' plot(x, type = c("backbone", "comparison"), combined = TRUE, ...) splot.tna_disparity( x, show = c("styled", "backbone", "full"), edge_style_sig = 1, edge_style_nonsig = 2, alpha_nonsig = 0.3, ... ) ## S3 method for class 'cograph_degree_fit' plot( x, which = NULL, log = "", cols = NULL, lwd = 2, main = "Degree Distribution Fit", ... ) ## S3 method for class 'cograph_motif_result' plot( x, type = c("triads", "types", "significance", "patterns"), n = 15, ncol = 5, colors = c("#2166AC", "#B2182B"), node_size = 5, label_size = 11, title_size = 12, stats_size = 13, legend_size = 13, legend = TRUE, motif_color = "#800020", spacing = 1, base_size = 12, combined = TRUE, ... ) plot_motifs( x, type = c("triads", "types", "significance", "patterns"), n = 15, ncol = 5, colors = c("#2166AC", "#B2182B"), node_size = 5, label_size = 11, title_size = 12, stats_size = 13, legend_size = 13, legend = TRUE, motif_color = "#800020", spacing = 1, base_size = 12, ... ) ## S3 method for class 'cograph_motif_analysis' plot( x, type = c("triads", "types", "significance", "patterns"), n = 20, colors = c("#2166AC", "#B2182B"), res = 72, node_size = 5, label_size = 7, title_size = 7, stats_size = 5, ncol = 5, legend = TRUE, color = "#800020", spacing = 1, combined = TRUE, ... ) ## S3 method for class 'cograph_motifs' plot( x, type = c("bar", "heatmap", "network"), show_nonsig = FALSE, top_n = NULL, colors = c("#2166AC", "#F7F7F7", "#B2182B"), combined = TRUE, ... ) splot.tna_bootstrap( x, display = c("styled", "significant", "full", "ci"), edge_style_sig = 1, edge_style_nonsig = 2, color_nonsig = "#888888", show_ci = FALSE, show_stars = TRUE, width_by = NULL, inherit_style = TRUE, ... ) plot_netobject_group( x, nrow = NULL, ncol = NULL, common_scale = TRUE, title_prefix = NULL, combined = TRUE, ... ) plot_netobject_ml( x, layout = NULL, common_scale = TRUE, titles = c("Between-person", "Within-person"), combined = TRUE, ... ) plot_net_bootstrap_group( x, nrow = NULL, ncol = NULL, common_scale = TRUE, combined = TRUE, ... ) plot_net_stability(x, ...) splot.tna_permutation(x, ...) splot.group_tna_permutation(x, ...) plot_permutation( x, show_nonsig = FALSE, edge_positive_color = "#009900", edge_negative_color = "#C62828", edge_nonsig_color = "#888888", edge_nonsig_style = 2, show_stars = TRUE, show_effect = FALSE, edge_nonsig_alpha = 0.4, ... ) plot_group_permutation(x, i = NULL, combined = TRUE, ...) ## S3 method for class 'cograph_rich_club' plot(x, type = c("curve", "network"), k = NULL, col = "#E41A1C", ...) ## S3 method for class 'cograph_vulnerability' plot(x, top = NULL, col = "steelblue", ...)
x |
The result object. The Description lists the class each function accepts. |
network |
The network the communities were detected on. It is required only when the result does not store the network. |
... |
Additional arguments passed to the underlying plotting call.
Network plots pass them to |
core_color, periphery_color
|
Node colors of core and periphery nodes. |
core_size, periphery_size
|
Node sizes of core and periphery nodes. |
type |
Plot type. The values for each class are listed in Details. |
combined |
Logical. When |
show |
Network shown by |
edge_style_sig |
Line type of significant (or backbone) edges. Default 1 (solid). |
edge_style_nonsig |
Line type of non-significant (or non-backbone) edges. Default 2 (dashed). |
alpha_nonsig |
Transparency of non-backbone edges. Default 0.3. |
which |
Character vector of fitted distributions to show. |
log |
Log-scale axes for the degree fit, one of |
cols |
Colors of the fitted distribution curves, named or unnamed.
|
lwd |
Line width of the fitted distribution curves. |
main |
Title of the degree-fit plot. |
n |
Maximum number of triads, patterns or z-score bars plotted. For
|
ncol, nrow
|
Number of columns and rows of the panel grid. A
|
colors |
Colors of the significance scale in motif plots. For
|
node_size |
Relative size of the nodes in triad diagrams. |
label_size |
Font size of the node labels in triad diagrams. |
title_size |
Font size of the panel titles in triad diagrams. |
stats_size |
Font size of the statistics caption of each triad panel
(for example |
legend_size |
Font size of the legend below the triad grid. |
legend |
Logical. Whether to show the legend of node-label abbreviations below the triad grid. |
motif_color, color
|
Color of the nodes, edges and labels in triad
diagrams. |
spacing |
Spacing multiplier for triad diagrams. Values above 1 pull the three nodes of each panel inward and values below 1 push them apart. |
base_size |
Base font size of the ggplot2 theme used by
|
res |
Unused. It is kept for backward compatibility. |
show_nonsig |
Logical. Whether non-significant items are shown. For
|
top_n |
Number of motifs with the largest absolute z-scores to plot.
|
display |
Display mode of |
color_nonsig |
Accepted for compatibility. The styled bootstrap plot uses a fixed pink color for non-significant edges. |
show_ci |
Logical. Whether confidence interval bounds are added to the
edge labels. |
show_stars |
Logical. Whether significance stars ( |
width_by |
Set to |
inherit_style |
Logical. Whether the labels, node colors and initial-state donuts of the original TNA model are reused, with the oval layout as the default layout. |
common_scale |
Logical. Whether all panels share the same maximum
edge weight. Default |
title_prefix |
Optional text placed before each group name in the panel titles. |
layout |
Layout algorithm of the multilevel panels. |
titles |
Character vector of length 2 with the titles of the between-person and within-person panels. |
edge_positive_color, edge_negative_color
|
Colors of significant
positive ( |
edge_nonsig_color, edge_nonsig_style, edge_nonsig_alpha
|
Color, line type and transparency of non-significant edge differences. |
show_effect |
Logical. Whether the absolute effect size is added in parentheses to the labels of significant edges. |
i |
Index or name of a single comparison to plot. |
k |
Prominence threshold whose club members are highlighted with
|
col |
Color of the rich club curve and club members, or of the vulnerability bars. |
top |
Number of most vulnerable nodes to plot. |
For cograph_motif_result and cograph_motif_analysis,
type is one of the following values.
"triads"(default) Network diagrams of node triples
arranged in a grid. A census result without named nodes falls back to
"patterns". Each diagram shows a canonical representative of the
MAN class, so the node labels identify the participating nodes and
their positions do not encode observed source or sink roles. Panel
titles read "<MAN code>: <description>", and the caption gives
the count and, when significance was tested, the z-score and
p-value.
"types"Bar chart of MAN type frequencies. For a census
tested for significance the bars are colored by significance
direction. Instance results and cograph_motif_analysis use a
single fill, because per-type significance would require aggregating
several node-triple rows of the same type.
"significance"Z-score bars, one per MAN type for a census
and one per node triple for instance results. It requires the analysis
to have been run with significance = TRUE.
"patterns"Abstract MAN pattern diagrams of each triad
type. For a census tested for significance the nodes are filled by
significance direction, and the panel titles add the z-score and a
significance star (* p<.05, ** p<.01, ***
p<.001). Instance results use a single fill.
For cograph_motifs, type is "bar" (default; motif
z-scores colored by over- or under-representation), "heatmap"
(z-scores across motif types, labelled with the observed and expected
counts) or "network" (one diagram per motif that passes the
show_nonsig and top_n filters). The network view requires
a directed 3-node census and otherwise falls back to the bar chart with a
message. For cograph_rich_club, type is
"curve" (default; the coefficient across thresholds with null model
bands) or "network" (club members at threshold k). For
tna_disparity, type is "backbone" (default) or
"comparison" (original and backbone side by side).
splot() on a tna_bootstrap reads the original weights from
weights (or weights_orig), the significant weights from
weights_sig or the p_values matrix, the confidence bounds
from ci_lower and ci_upper, the significance level from
a level element and the styling from model. Results of
tna::bootstrap() store no level element, so their edges
are styled at a level of 0.05. In styled
mode significant edges are solid dark blue with bold starred labels and
are plotted on top, and non-significant edges are dashed pink with plain
labels.
plot_permutation() reads the edge differences (x - y) from
edges$diffs_true, the significant differences from
edges$diffs_sig and the edge statistics from edges$stats.
Significant positive differences are solid green and significant negative
differences solid red, both with bold starred labels.
plot_net_bootstrap_group() plots each group through the
splot() method for net_bootstrap, so every panel keeps the
solid and dashed significance styling.
Each function is called for its plot. The returned value depends on the class.
A ggplot2 object, printed and returned
invisibly, for type = "types", "significance",
"bar" and "heatmap". type = "triads" and
"patterns" return the input invisibly for
cograph_motif_result and NULL invisibly for
cograph_motif_analysis. cograph_motifs with
type = "network" returns NULL invisibly. Any
cograph_motifs plot returns NULL invisibly with a
message when no motif passes the show_nonsig and
top_n filters.
The cograph_network built by
splot(), invisibly, for cograph_communities,
tna_disparity, tna_bootstrap and
tna_permutation. plot_permutation() returns
NULL invisibly with a message when no edge remains to plot.
plot_group_permutation() returns the selected panel's
network when i is given and NULL invisibly
otherwise.
The input invisibly for netobject_group and
net_bootstrap_group. With a single group the network of that
panel is returned, and with no groups NULL.
The input invisibly for
cograph_core_periphery, cograph_rich_club,
cograph_vulnerability, netobject_ml and
net_stability, and NULL invisibly for
cograph_degree_fit.
splot() for the network plots of single networks.
census <- motifs(regulation_net, significance = FALSE) plot(census, type = "types")census <- motifs(regulation_net, significance = FALSE) plot(census, type = "types")
Projects a two-mode (bipartite/incidence) network into a one-mode adjacency matrix. Row-mode projection yields a matrix of shared-column connections among row nodes; column-mode projection does the converse.
project_bipartite(x, mode = "rows", method = "sum", ...)project_bipartite(x, mode = "rows", method = "sum", ...)
x |
An incidence matrix (rows = type 1 nodes, columns = type 2 nodes)
where non-zero entries indicate connections. Can also be a data.frame with
columns |
mode |
Character. |
method |
Character. Projection method:
|
... |
Additional arguments (currently unused). |
Only method = "sum" and method = "cosine" use the incidence
values themselves. "binary", "jaccard" and "newman"
first binarize the incidence matrix (x > 0), so any weights are
discarded for those three.
For the Newman projection, affiliations shared with only one node of the
focal type (d_k = 1) are skipped, since 1 / (d_k - 1) is
undefined. This follows the convention in Newman (2001).
A square adjacency matrix, one row and column per node of the
projected mode: n_rows x n_rows named by rownames(x) for
mode = "rows", n_cols x n_cols named by colnames(x)
for mode = "columns". The diagonal is set to 0 (no self-loops).
Newman, M. E. J. (2001). Scientific collaboration networks. II. Shortest paths, weighted networks, and centrality. Physical Review E, 64(1), 016132.
cograph::project_bipartite(regulation_net, mode = "rows", method = "jaccard")cograph::project_bipartite(regulation_net, mode = "rows", method = "jaccard")
A graph-level hierarchy measure computed from per-node local reaching centralities:
reaching_global(x, mode = "all", ...)reaching_global(x, mode = "all", ...)
x |
Network input (matrix, edge-list data frame, igraph, network, cograph_network, tna object). |
mode |
For directed networks: |
... |
Additional arguments passed to |
Values close to 0 indicate a flat network in which all nodes reach equal
proportions of the graph. Larger values indicate a more hierarchical
structure. The result matches networkx.global_reaching_centrality.
A single numeric value. On an unweighted graph it lies in
. On a weighted graph the local reaching centralities scale
with the edge weights, so the value is unbounded. A graph with at most
one node returns 0.
Mones, E., Vicsek, L., & Vicsek, T. (2012). Hierarchy measure for complex networks. PLoS ONE, 7(3), e33799.
centrality_reaching_local, summarize_network.
reaching_global(regulation_net, mode = "out")reaching_global(regulation_net, mode = "out")
A synthetic weighted transition network among ten learning regulation states, used in the package examples and the introduction vignette. Each cell holds the weight of the transition from the row state to the column state.
regulation_netregulation_net
A 10 x 10 numeric matrix with row and column names Explore,
Plan, Monitor, Adapt, Reflect, Discuss,
Synthesize, Evaluate, Create and Share. Thirty
of the 90 off-diagonal cells carry weights between 0.05 and 0.49. The
remaining cells, including the diagonal, are zero.
The network is synthetic and represents no observed data. It was
generated with set.seed(42). Thirty off-diagonal cells were drawn
at random and given weights drawn uniformly between 0.05 and 0.5, rounded
to two decimals. Rows are not normalized.
A 10 x 10 numeric matrix of transition weights with state names as row and column names.
Synthetic, generated for the package examples.
regulation_net splot(regulation_net, tna_styling = TRUE)regulation_net splot(regulation_net, tna_styling = TRUE)
Deletes the edges between given pairs of nodes. In an undirected network the order of the two endpoints does not matter.
remove_edges( x, from, to, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )remove_edges( x, from, to, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
from |
Source nodes, by label or index. |
to |
Target nodes, by label or index. The same length as |
keep_isolates |
Logical. Keep nodes that end up with no edges? Default
TRUE, matching |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network without those edges, or the input format
when keep_format = TRUE. Named pairs that carry no edge are
reported in a cograph_no_such_edge warning.
add_edges, filter_edges,
remove_isolates
remove_edges(regulation_net, from = "Plan", to = "Monitor")remove_edges(regulation_net, from = "Plan", to = "Monitor")
Removes every node with no edges. Edge filters such as
filter_edges keep all nodes, and this function removes the
isolates that such a filter leaves behind.
remove_isolates(x, keep_format = FALSE, directed = NULL)remove_isolates(x, keep_format = FALSE, directed = NULL)
x |
Network input: cograph_network, matrix, igraph, network, tna, or an edge-list data frame. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network with the isolated nodes removed (or the
input format when keep_format = TRUE). The remaining nodes keep
their order, and edge indices are remapped to the new node numbering.
filter_edges, split_components,
filter_nodes
remove_isolates(threshold_edges(regulation_net, minimum = 0.3))remove_isolates(threshold_edges(regulation_net, minimum = 0.3))
Deletes nodes and every edge incident to them. A node that is not in the
network raises a cograph_bad_selection error.
remove_nodes(x, nodes, keep_format = FALSE, directed = NULL)remove_nodes(x, nodes, keep_format = FALSE, directed = NULL)
x |
Network input. |
nodes |
Node labels or indices to remove. |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
A cograph_network without those nodes and without any edge
that touched them, or the input format when keep_format = TRUE.
add_nodes, filter_nodes,
remove_isolates
remove_nodes(regulation_net, nodes = "Share")remove_nodes(regulation_net, nodes = "Share")
Rename Nodes
rename_nodes(x, from, to = NULL, keep_format = FALSE, directed = NULL)rename_nodes(x, from, to = NULL, keep_format = FALSE, directed = NULL)
x |
Network input. |
from |
Character vector of current labels, or a named character vector
mapping old label to new (in which case |
to |
Character vector of new labels, the same length as |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network with the renamed nodes, or the input format
when keep_format = TRUE. Labels not named in from are
unchanged. A cograph_bad_selection error is raised when
from names a node that is not in the network or when the renaming
would give two nodes the same label.
rename_nodes(regulation_net, from = "Plan", to = "Planning")rename_nodes(regulation_net, from = "Plan", to = "Planning")
sn_ggplot() converts a network to a ggplot object.
sn_ggplot() returns a ggplot object representing the network.
sn_ggplot(regulation_net)sn_ggplot(regulation_net)
The grid rendering engine. soplot plots a
network with grid graphics, and sn_ggplot converts a network
into a ggplot2 object.
See individual functions: soplot returns a
cograph_network object invisibly; sn_ggplot returns a
ggplot2 object.
soplot(regulation_net)soplot(regulation_net)
Changes the order in which the nodes are stored, which is the order in which plotting functions place them. The edges and their weights are unchanged.
reorder_nodes(x, order, keep_format = FALSE, directed = NULL)reorder_nodes(x, order, keep_format = FALSE, directed = NULL)
x |
Network input. |
order |
Node labels or indices, in the wanted order, or one of
|
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network with the nodes in the requested order and
edge indices remapped, or the input format when keep_format = TRUE.
reorder_nodes(regulation_net, order = "degree")reorder_nodes(regulation_net, order = "degree")
Swaps the endpoints of every edge, which transposes the weight matrix. In a transition network the reversed arcs show where each transition came from. Additional edge columns are kept.
reverse_edges(x, keep_format = FALSE, directed = NULL)reverse_edges(x, keep_format = FALSE, directed = NULL)
x |
Network input. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network with every edge reversed, or the input
format when keep_format = TRUE. An undirected network is returned
unchanged, with a cograph_no_effect warning.
reverse_edges(regulation_net)reverse_edges(regulation_net)
Computes the rich club curve across all prominence thresholds. The unweighted coefficient (Colizza et al. 2006) measures the density of ties among prominent nodes. The weighted coefficient (Opsahl et al. 2008) measures whether prominent nodes concentrate the strongest ties of the network among themselves. A directed network is converted to an undirected one before the computation, with the weights of reciprocal edges summed, and self-loops are removed.
rich_club( x, rich = c("k", "s"), weighted = TRUE, normalized = TRUE, n_random = 100, directed = NULL, seed = NULL, digits = NULL, ... )rich_club( x, rich = c("k", "s"), weighted = TRUE, normalized = TRUE, n_random = 100, directed = NULL, seed = NULL, digits = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
rich |
Character. Prominence definition: |
weighted |
Logical. If TRUE (default), compute the weighted rich club coefficient. If FALSE, compute the unweighted version (density among rich nodes). |
normalized |
Logical. If TRUE (default), normalize against
degree-preserving random graphs and report the null distribution. The
null graphs are generated with |
n_random |
Integer. Number of random graphs for normalization. Default 100. |
directed |
Logical or NULL. Default NULL (auto-detect). |
seed |
Integer or NULL. Random seed for the null graphs. When a seed is given, the caller's random state is restored on exit. Default NULL. |
digits |
Integer or NULL. Round all numeric columns, including
|
... |
Passed to |
The unweighted coefficient is
, where is
the number of nodes with prominence above and the
number of edges among them.
The weighted coefficient is
, where
is the total weight of the edges among the rich nodes and
is the -th largest edge weight in the network.
The normalized coefficient is
. A value above 1
indicates rich club ordering beyond what the degree sequence alone
explains.
A data frame with class "cograph_rich_club", one row per
prominence threshold at which at least two nodes are rich, and columns:
The prominence cut-off. Nodes with prominence strictly greater than this value form the club. Thresholds range over the observed prominence values excluding the maximum.
Number of club members at that threshold.
Observed rich club coefficient.
Present only when
normalized = TRUE. They hold the observed coefficient divided by
the null mean, the null mean itself, and the 2.5\
quantiles of the null distribution.
The data frame has zero rows for graphs that are too small, complete, or
regular for any threshold to yield a club. The arguments rich,
weighted, normalized and the original input
("network") are stored as attributes.
Printing the result shows the prominence definition, the weighting and
normalization settings, the number of thresholds with phi_norm > 1
and the first ten rows of the table. plot() on the result is
documented in plot-results.
Opsahl, T., Colizza, V., Panzarasa, P. & Ramasco, J.J. (2008). Prominence and control: The weighted rich-club effect. Physical Review Letters, 101, 168702.
Colizza, V., Flammini, A., Serrano, M.A. & Vespignani, A. (2006). Detecting rich-club ordering in complex networks. Nature Physics, 2, 110-115.
rich_club_local, robustness,
centrality
rich_club(regulation_net, n_random = 20, seed = 1)rich_club(regulation_net, n_random = 20, seed = 1)
Computes, for each node, whether its strongest ties go to prominent nodes. The score is the mean weight of the node's ties to prominent neighbors divided by the mean weight of all its ties. A score above 1 means that the node's ties to prominent nodes are stronger than its average tie. A directed network is converted to an undirected one before the computation, with the weights of reciprocal edges summed, and self-loops are removed.
rich_club_local( x, prominence = NULL, rich = c("k", "s"), directed = NULL, digits = NULL, sort_by = "score", ... )rich_club_local( x, prominence = NULL, rich = c("k", "s"), directed = NULL, digits = NULL, sort_by = "score", ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
prominence |
Which nodes are prominent. Either a logical or 0/1 vector with one element per node (TRUE or 1 marks a prominent node), or a single number used as a threshold, in which case nodes with degree or strength strictly greater than it are prominent. If NULL (default), nodes with degree or strength strictly above the median are prominent. |
rich |
Character. |
directed |
Logical or NULL. Default NULL (auto-detect). |
digits |
Integer or NULL. Round scores. Default NULL. |
sort_by |
Character or NULL. Column to sort by in descending order,
|
... |
Passed to |
For each node , , where
both means are taken over the ties of with positive weight.
A plain data frame with one row per node and columns node
(node label) and score. A node with no neighbors or no prominent
neighbor scores 1.
Opsahl, T., Colizza, V., Panzarasa, P. & Ramasco, J.J. (2008). Prominence and control: The weighted rich-club effect. Physical Review Letters, 101, 168702.
cograph::rich_club_local(regulation_net)cograph::rich_club_local(regulation_net)
Performs a targeted attack or random failure analysis on a network and computes the size of the largest (weakly) connected component after each vertex or edge removal.
In a targeted attack, vertices are ranked by degree or betweenness centrality (edges by edge betweenness) and removed from highest to lowest. In a random failure analysis, vertices or edges are removed in random order.
robustness( x, type = c("vertex", "edge"), measure = c("betweenness", "degree", "random"), strategy = c("sequential", "static"), n_iter = 1000, mode = "all", seed = NULL, ... )robustness( x, type = c("vertex", "edge"), measure = c("betweenness", "degree", "random"), strategy = c("sequential", "static"), n_iter = 1000, mode = "all", seed = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
type |
Character string; either "vertex" or "edge" removals. Default: "vertex" |
measure |
Character string; rank by "betweenness", "degree", or remove in "random" order. Default: "betweenness". "degree" is not available for edge removals and raises an error. |
strategy |
Character string. "sequential" (default) recomputes the centrality after each removal. "static" computes the centrality once on the original network and removes elements in that fixed order, as in brainGraph. The argument applies to targeted attacks only. |
n_iter |
Integer; number of random removal sequences averaged when
|
mode |
Degree mode for directed networks: "all", "in", or "out".
Default "all". Used only when |
seed |
Random seed for reproducibility. Default NULL. |
... |
Passed to |
A betweenness attack removes the vertices or edges that lie on the most
shortest paths, which bridge different regions of the network. A degree
attack removes the most connected vertices first. Random failure removes
vertices or edges in random order and averages the component sizes over
n_iter sequences. Betweenness is computed with igraph, which treats
edge weights as distances.
The sequential strategy updates the ranking after every removal, so the attack follows the vertices that become new bridges or hubs. The static strategy ranks once on the original network, as in Albert et al. (2000).
Scale-free networks are typically robust to random failures and vulnerable to targeted attacks. Random networks degrade more uniformly.
A data frame (class "cograph_robustness") with one row per removal
step, from zero removed through all removed (n + 1 rows, where
n is the number of vertices or edges), and columns:
Fraction of vertices/edges removed (0 to 1)
Size of largest component after removal (averaged over
n_iter runs when measure = "random")
Ratio of component size to original maximum
The measure argument: "betweenness", "degree", or
"random"
A label for the analysis, one of "Targeted vertex attack", "Targeted edge attack", "Random vertex removal" or "Random edge removal"
The last row always has comp_size = 0. The original number of
vertices or edges ("n_original") and the original largest-component
size ("orig_max") are stored as attributes.
Albert, R., Jeong, H., & Barabasi, A.L. (2000). Error and attack tolerance of complex networks. Nature, 406, 378-381. doi:10.1038/35019019
plot_robustness, robustness_auc
robustness(regulation_net, measure = "betweenness")robustness(regulation_net, measure = "betweenness")
Computes the area under the robustness curve (comp_pct against
removed_pct) by trapezoidal integration. A higher AUC indicates a
more robust network. The maximum AUC is 1.
robustness_auc(x)robustness_auc(x)
x |
A robustness result from |
A single numeric AUC value between 0 and 1.
robustness_auc(robustness(regulation_net, measure = "degree"))robustness_auc(robustness(regulation_net, measure = "degree"))
Summarizes robustness results across attack strategies.
robustness_summary(..., x = NULL, measures = NULL, n_iter = 1000)robustness_summary(..., x = NULL, measures = NULL, n_iter = 1000)
... |
Robustness results from |
x |
Network on which vertex robustness is computed for each of
|
measures |
Measures to compute when |
n_iter |
Iterations for random removal. Default 1000. |
A data frame with one row per supplied (or computed) robustness
result and columns measure, auc (area under the robustness
curve), critical_50 (fraction removed when the largest component
first falls below 50\
same at 10\
crossed. All numeric columns are rounded to 4 decimal places.
Supplying neither results nor x raises an error.
robustness_summary(x = regulation_net, measures = c("degree", "random"), n_iter = 10)robustness_summary(x = regulation_net, measures = c("degree", "random"), n_iter = 10)
Select edges whose removal would disconnect the graph.
select_bridges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )select_bridges( x, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
... |
Additional filter expressions. |
keep_isolates |
Keep nodes that end up with no edges? Default TRUE. |
keep_format |
Keep input format? Default FALSE. |
directed |
Auto-detect if NULL. |
A cograph_network with bridge edges only.
strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) select_bridges(strong, keep_isolates = FALSE)strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) select_bridges(strong, keep_isolates = FALSE)
Select nodes belonging to a specific connected component.
select_component( x, which = "largest", ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )select_component( x, which = "largest", ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )
x |
Network input. |
which |
Component selection:
|
... |
Additional filter expressions to apply after component selection. |
keep_edges |
How to handle edges. Default "internal". |
keep_format |
Logical. Keep input format? Default FALSE. |
directed |
Logical or NULL. Auto-detect if NULL. |
A cograph_network with nodes in the selected component.
select_nodes, select_neighbors
select_component(regulation_net, which = "largest")select_component(regulation_net, which = "largest")
Selects edges by filter expressions, by node sets, by rank on a metric, or by structural properties such as bridges, communities and reciprocity.
select_edges( x, ..., top = NULL, by = "weight", involving = NULL, between = NULL, bridges_only = FALSE, mutual_only = FALSE, community = "louvain", keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL )select_edges( x, ..., top = NULL, by = "weight", involving = NULL, between = NULL, bridges_only = FALSE, mutual_only = FALSE, community = "louvain", keep_isolates = TRUE, keep_format = FALSE, directed = NULL, .keep_isolates = NULL )
x |
Network input: cograph_network, matrix, igraph, network, or tna object. |
... |
Filter expressions using edge columns or computed metrics. Available variables:
|
top |
Integer. Select top N edges by a metric. |
by |
Character. Metric for top selection. Default |
involving |
Character or integer. Select edges involving these nodes (by name or index). An edge is selected if either endpoint matches. |
between |
List of two character/integer vectors. Select edges between
two node sets. Example: |
bridges_only |
Logical. Select only bridge edges (edges whose removal disconnects the graph). Default FALSE. |
mutual_only |
Logical. For directed networks, select only mutual (reciprocated) edges. Default FALSE. |
community |
Character. Community detection method for |
keep_isolates |
Logical. Keep nodes that end up with no edges?
Default TRUE, matching |
keep_format |
Logical. If TRUE, matrix, igraph, statnet network and tna inputs are returned in that format. Default FALSE returns cograph_network. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
.keep_isolates |
Deprecated. Use |
Selection criteria are combined with AND logic, so an edge is selected only
when it satisfies all of them. The top ranking is applied to the
edges that pass involving, between, bridges_only and
mutual_only, and the filter expressions in ... are applied
afterwards. For example, select_edges(x, top = 10, involving = "A")
selects the 10 strongest edges among those involving node A.
Only the edge metrics referenced in expressions or required by a selection criterion are computed.
A cograph_network object with selected edges. If keep_format = TRUE,
matrix, igraph, statnet network and tna inputs are converted back to that type.
Nodes left without edges are kept and reported in a
cograph_isolates_created warning, unless
keep_isolates = FALSE.
filter_edges, select_nodes,
select_bridges, select_top_edges
select_edges(regulation_net, top = 5, keep_isolates = FALSE)select_edges(regulation_net, top = 5, keep_isolates = FALSE)
Select edges connecting two specified node sets.
select_edges_between( x, set1, set2, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )select_edges_between( x, set1, set2, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
set1 |
Character or integer. First node set (names or indices). |
set2 |
Character or integer. Second node set (names or indices). |
... |
Additional filter expressions. |
keep_isolates |
Keep nodes that end up with no edges? Default TRUE. |
keep_format |
Keep input format? Default FALSE. |
directed |
Auto-detect if NULL. |
A cograph_network with edges between the two node sets.
select_edges, select_edges_involving
select_edges_between(regulation_net, set1 = c("Plan", "Monitor"), set2 = c("Adapt", "Reflect"), keep_isolates = FALSE)select_edges_between(regulation_net, set1 = c("Plan", "Monitor"), set2 = c("Adapt", "Reflect"), keep_isolates = FALSE)
Select edges where at least one endpoint is in the specified node set.
select_edges_involving( x, nodes, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )select_edges_involving( x, nodes, ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
nodes |
Character or integer. Node names or indices. |
... |
Additional filter expressions. |
keep_isolates |
Keep nodes that end up with no edges? Default TRUE. |
keep_format |
Keep input format? Default FALSE. |
directed |
Auto-detect if NULL. |
A cograph_network with edges involving the specified nodes.
select_edges, select_edges_between
select_edges_involving(regulation_net, nodes = "Plan", keep_isolates = FALSE)select_edges_involving(regulation_net, nodes = "Plan", keep_isolates = FALSE)
The k-core is the maximal subgraph in which every node has degree at least
k, found by repeatedly removing nodes of degree below k.
Degree is the total degree, which is in-degree plus out-degree in a
directed network. A self-loop adds 2 to the degree of its node.
select_k_core(x, k, keep_format = FALSE, directed = NULL)select_k_core(x, k, keep_format = FALSE, directed = NULL)
x |
Network input. |
k |
A single non-negative whole number. The core number. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A cograph_network holding the k-core, or the input format
when keep_format = TRUE. When no node reaches coreness k,
the result is an empty network and a warning is raised.
Seidman, S. B. (1983). Network structure and minimum degree. Social Networks, 5(3), 269–287.
select_k_core(regulation_net, k = 2)select_k_core(regulation_net, k = 2)
Select nodes within a specified distance from focal nodes.
select_neighbors( x, of, order = 1L, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )select_neighbors( x, of, order = 1L, ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )
x |
Network input. |
of |
Character or integer. Focal node(s) by name or index. |
order |
Integer. Neighborhood order (1 = direct neighbors). Default 1. |
... |
Additional filter expressions to apply after neighborhood selection. |
keep_edges |
How to handle edges. Default "internal". |
keep_format |
Logical. Keep input format? Default FALSE. |
directed |
Logical or NULL. Auto-detect if NULL. |
A cograph_network with nodes in the neighborhood.
select_nodes, select_component
select_neighbors(regulation_net, of = "Plan")select_neighbors(regulation_net, of = "Plan")
Selects nodes by name, index, rank on a centrality measure, neighborhood, connected component, or filter expressions on node columns, centrality measures and structural variables.
select_nodes( x, ..., name = NULL, index = NULL, top = NULL, by = "degree", neighbors_of = NULL, order = 1L, component = NULL, keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL )select_nodes( x, ..., name = NULL, index = NULL, top = NULL, by = "degree", neighbors_of = NULL, order = 1L, component = NULL, keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL, .keep_edges = NULL )
x |
Network input: cograph_network, matrix, igraph, network, or tna object. |
... |
Filter expressions using node columns, centrality measures, or global context variables. Centrality measures are computed lazily (only those actually referenced). Available variables:
|
name |
Character vector. Select nodes by name/label. |
index |
Integer vector. Select nodes by index (1-based). |
top |
Integer. Select top N nodes by centrality measure. |
by |
Character. Centrality measure for top selection. Default |
neighbors_of |
Character or integer. Select neighbors of these nodes (by name or index). |
order |
Integer. Neighborhood order (1 = direct neighbors, 2 = neighbors of neighbors, etc.). Default 1. |
component |
Selection mode for connected components:
|
keep_edges |
How to handle edges. One of:
|
keep_format |
Logical. If TRUE, matrix, igraph, statnet network and tna inputs are returned in that format. Default FALSE returns cograph_network. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
.keep_edges |
Deprecated. Use |
Selection criteria are combined with AND logic, so a node is selected only
when it satisfies all of them. The top ranking is applied to the
nodes that pass name, index, component and
neighbors_of, and the filter expressions in ... are applied
afterwards. For example,
select_nodes(x, top = 10, component = "largest") selects the 10
highest-degree nodes within the largest component.
Only the centrality measures referenced in expressions or in by are
computed.
For networks with negative edge weights, betweenness,
closeness and pagerank are undefined and return NA,
with a cograph_negative_weights warning.
A cograph_network object with selected nodes. If keep_format = TRUE,
matrix, igraph, statnet network and tna inputs are converted back to that type.
filter_nodes, select_neighbors,
select_component, select_top
select_nodes(regulation_net, top = 3, by = "pagerank")select_nodes(regulation_net, top = 3, by = "pagerank")
Select the top N nodes ranked by a centrality measure.
select_top( x, n, by = "degree", ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )select_top( x, n, by = "degree", ..., keep_edges = c("internal", "none"), keep_format = FALSE, directed = NULL )
x |
Network input. |
n |
Integer. Number of top nodes to select. |
by |
Character. Centrality measure for ranking:
|
... |
Additional filter expressions, applied after the top |
keep_edges |
How to handle edges. Default "internal". |
keep_format |
Logical. Keep input format? Default FALSE. |
directed |
Logical or NULL. Auto-detect if NULL. |
A cograph_network with the top N nodes.
select_nodes, select_component
select_top(regulation_net, n = 3, by = "pagerank")select_top(regulation_net, n = 3, by = "pagerank")
Select the top N edges ranked by weight or another metric.
select_top_edges( x, n, by = "weight", ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )select_top_edges( x, n, by = "weight", ..., keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input. |
n |
Integer. Number of top edges to select. |
by |
Character. Metric for ranking. One of:
|
... |
Additional filter expressions, applied after the top |
keep_isolates |
Keep nodes that end up with no edges? Default TRUE. |
keep_format |
Keep input format? Default FALSE. |
directed |
Auto-detect if NULL. |
A cograph_network with the top N edges.
select_top_edges(regulation_net, n = 5, keep_isolates = FALSE)select_top_edges(regulation_net, n = 5, keep_isolates = FALSE)
Node shapes are stored in a registry and selected by name through the
node_shape argument of splot and soplot
or the shape argument of sn_nodes.
register_shape() adds a shape given by a drawing function, and
get_shape() returns the drawing function of a registered shape.
list_shapes() returns the names of all registered shapes.
A shape added with register_shape() is a grid shape and is used by
soplot() only. splot() plots its built-in shapes and SVG
shapes.
register_svg_shape() adds a shape defined by an SVG file or an inline
SVG string, list_svg_shapes() returns the names of the registered SVG
shapes, and unregister_svg_shape() removes one. SVG shapes are used
by both splot() and soplot(). Registering an existing name
replaces that shape for the rest of the session.
register_shape(name, draw_fn) get_shape(name) list_shapes() register_svg_shape(name, svg_source) list_svg_shapes() unregister_svg_shape(name)register_shape(name, draw_fn) get_shape(name) list_shapes() register_svg_shape(name, svg_source) list_svg_shapes() unregister_svg_shape(name)
name |
Character. The name of the shape. |
draw_fn |
A function that renders the shape. It receives the arguments
|
svg_source |
Character. A path to an SVG file or an inline SVG string. |
register_shape() and register_svg_shape() return
NULL invisibly. get_shape() returns the drawing function, or
NULL if no shape has that name. list_shapes() and
list_svg_shapes() return a character vector of shape names.
unregister_svg_shape() returns TRUE invisibly if the shape
was removed and FALSE if it was not found.
list_shapes() splot(regulation_net, node_shape = "diamond")list_shapes() splot(regulation_net, node_shape = "diamond")
Computes shortest path distances between nodes in a network. Supports all-pairs, single-source, and point-to-point queries.
shortest_paths(x, from = NULL, to = NULL, weights = NULL, directed = NULL, ...)shortest_paths(x, from = NULL, to = NULL, weights = NULL, directed = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object |
from |
Character or numeric node identifier(s) for the source. If NULL (default), compute distances from all nodes. |
to |
Character or numeric node identifier(s) for the target. If NULL (default), compute distances to all nodes. |
weights |
Edge weight handling: NULL (default) auto-detects from edge attributes, NA forces unweighted distances, or a numeric vector of custom weights. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
... |
Not used. Any argument supplied here raises an
|
Distances are computed with igraph::distances(). For weighted
networks, edge weights are used as distances by default. With
weights = NA, every edge has unit distance.
igraph also exports a shortest_paths() with a different signature and
return value; when both packages are attached, qualify the call as
cograph::shortest_paths().
Depends on the query:
If both from and to are NULL: a full distance matrix
(all pairs)
If from is a single node and to is NULL: a named
numeric vector of distances from that node to all others
If from is multiple nodes and to is NULL: a matrix
with rows for each source
If both from and to are single nodes: a single numeric
value
Otherwise: a matrix of distances between the specified node sets
k_shortest_paths, network_summary
cograph::shortest_paths(regulation_net, from = "Plan")cograph::shortest_paths(regulation_net, from = "Plan")
Convenience wrapper around edge_centrality that returns only
the triangle count per edge, sorted descending.
simmelian_strength(x, top = NULL, directed = NULL, digits = NULL, ...)simmelian_strength(x, top = NULL, directed = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
top |
Integer or NULL. Return only the top N edges. Default NULL. |
directed |
Logical or NULL. Default NULL (auto-detect). |
digits |
Integer or NULL. Round numeric columns. Default NULL. |
... |
Additional arguments passed to |
A data frame sorted by triangles (descending) with columns:
from, to, weight, triangles.
edge_centrality, neighborhood_overlap
cograph::simmelian_strength(regulation_net, top = 5)cograph::simmelian_strength(regulation_net, top = 5)
Removes self-loops and (where representable) merges duplicate
(multi-)edges, similar to igraph::simplify().
simplify(x, remove_loops, remove_multiple, edge_attr_comb, ...) ## S3 method for class 'matrix' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'cograph_network' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'igraph' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'tna' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## Default S3 method: simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... )simplify(x, remove_loops, remove_multiple, edge_attr_comb, ...) ## S3 method for class 'matrix' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'cograph_network' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'igraph' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## S3 method for class 'tna' simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... ) ## Default S3 method: simplify( x, remove_loops = TRUE, remove_multiple = TRUE, edge_attr_comb = "mean", ... )
x |
Network input (matrix, cograph_network, igraph, tna object). |
remove_loops |
Logical. Remove self-loops (diagonal entries)?
Default |
remove_multiple |
Logical. Merge duplicate edges? Default
|
edge_attr_comb |
How to combine weights of duplicate edges:
|
... |
Additional arguments (currently unused). |
The extent of simplification depends on the input representation:
matrix and tna: edges are stored as an n x n weight
matrix. Each cell (i, j) is unique by construction, so duplicate-edge
merging has no effect and remove_multiple and
edge_attr_comb are ignored. Only self-loops (the diagonal) are
removed. Duplicate aggregation requires a cograph_network or
igraph input.
cograph_network: duplicate edges in the edge list are
merged, and their weights are combined with edge_attr_comb.
igraph: delegates to igraph::simplify(). The
weight attribute is combined with edge_attr_comb and
other edge attributes are dropped.
The simplified network, in the same format and class as the input
(matrix in / matrix out, cograph_network in / cograph_network
out, and so on). The default method raises an error for any other class.
filter_edges for conditional edge removal,
centrality which has its own simplify parameter
# igraph also exports simplify(); qualify the call when both are loaded. cograph::simplify(cograph(student_interactions), edge_attr_comb = "sum")# igraph also exports simplify(); qualify the call when both are loaded. cograph::simplify(cograph(student_interactions), edge_attr_comb = "sum")
Stores edge aesthetics in a network object for plotting with
soplot. splot does not read these settings and
takes its edge arguments directly.
sn_edges( network, width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = NULL, edge_cutoff = NULL, cut = NULL, color = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, alpha = NULL, style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, maximum = NULL, width_scale = NULL, labels = NULL, label_size = NULL, label_color = NULL, label_position = NULL, label_offset = NULL, label_bg = NULL, label_bg_padding = NULL, label_fontface = NULL, label_border = NULL, label_border_color = NULL, label_underline = NULL, label_shadow = NULL, label_shadow_color = NULL, label_shadow_offset = NULL, label_shadow_alpha = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, ci = NULL, ci_scale = NULL, ci_alpha = NULL, ci_color = NULL, ci_style = NULL, ci_arrows = NULL, ci_lower = NULL, ci_upper = NULL, label_style = NULL, label_template = NULL, label_digits = NULL, label_ci_format = NULL, label_p = NULL, label_p_digits = NULL, label_p_prefix = NULL, label_stars = NULL )sn_edges( network, width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = NULL, edge_cutoff = NULL, cut = NULL, color = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, alpha = NULL, style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, maximum = NULL, width_scale = NULL, labels = NULL, label_size = NULL, label_color = NULL, label_position = NULL, label_offset = NULL, label_bg = NULL, label_bg_padding = NULL, label_fontface = NULL, label_border = NULL, label_border_color = NULL, label_underline = NULL, label_shadow = NULL, label_shadow_color = NULL, label_shadow_offset = NULL, label_shadow_alpha = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, ci = NULL, ci_scale = NULL, ci_alpha = NULL, ci_color = NULL, ci_style = NULL, ci_arrows = NULL, ci_lower = NULL, ci_upper = NULL, label_style = NULL, label_template = NULL, label_digits = NULL, label_ci_format = NULL, label_p = NULL, label_p_digits = NULL, label_p_prefix = NULL, label_stars = NULL )
network |
A CographNetwork, cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
width |
Edge width. Can be a single value, vector (per-edge), or "weight". |
edge_size |
Maximum edge size for renderer weight scaling. NULL (default) uses the renderer's edge-width range. Larger values give thicker edges overall. |
esize |
Deprecated. Use |
edge_width_range |
Output width range as c(min, max) for weight-based scaling. If NULL (default), the plotting renderer's default range is used. |
edge_scale_mode |
Scaling mode for edge weights: "linear" (default), "log" (for wide weight ranges), "sqrt" (moderate compression), or "rank" (equal visual spacing). |
edge_cutoff |
Optional cutoff for edge emphasis. NULL (default) or 0
disables cutoff handling. The value is stored in the network; the
|
cut |
Deprecated. Use |
color |
Edge color. Can be a single color, vector, or "weight" for automatic coloring based on edge weights. |
edge_positive_color |
Color for positive edge weights. |
positive_color |
Deprecated. Use |
edge_negative_color |
Color for negative edge weights. |
negative_color |
Deprecated. Use |
alpha |
Edge transparency (0-1). |
style |
Line style: "solid", "dashed", "dotted", "longdash", "twodash". |
curvature |
Edge curvature amount (0 = straight). |
arrow_size |
Size of arrow heads for directed networks. |
show_arrows |
Logical. Show arrows? Default TRUE for directed networks. |
maximum |
Maximum edge weight for scaling width. Weights above this are capped. Similar to qgraph's maximum parameter. |
width_scale |
Scale factor for edge widths. Values > 1 make edges thicker, values < 1 make them thinner. Applied after all other width calculations. |
labels |
Edge labels. Can be TRUE (show weights), a vector, or column name. |
label_size |
Edge label text size. |
label_color |
Edge label text color. |
label_position |
Position along edge (0 = source, 0.5 = middle, 1 = target). |
label_offset |
Perpendicular offset from edge line. |
label_bg |
Background color for edge labels (default "white"). Set to NA for transparent. |
label_bg_padding |
Padding around label text as proportion of text size (default 0.3). |
label_fontface |
Font face: "plain", "bold", "italic", "bold.italic" (default "plain"). |
label_border |
Border style: NULL (none), "rect", "rounded", "circle" (default NULL). |
label_border_color |
Border color for label border (default "gray50"). |
label_underline |
Logical. Underline the label text? (default FALSE). |
label_shadow |
Logical. Enable drop shadow for labels? (default FALSE). |
label_shadow_color |
Color for label shadow (default "gray40"). |
label_shadow_offset |
Offset distance for shadow in points (default 0.5). |
label_shadow_alpha |
Transparency for shadow (0-1, default 0.5). |
bidirectional |
Logical. Show arrows at both ends of edges? |
loop_rotation |
Angle in radians for self-loop direction (default: pi/2 = top). |
curve_shape |
Spline tension for curved edges (-1 to 1, default: 0). |
curve_pivot |
Pivot position along edge for curve control point (0-1, default: 0.5). |
curves |
Curve mode: FALSE (straight edges), "mutual" (only curve reciprocal pairs), or "force" (curve all edges). If NULL, the plotting renderer's default is used. |
ci |
Numeric vector of CI widths (0-1 scale). Larger values indicate more uncertainty. |
ci_scale |
Width multiplier for CI underlay thickness. Default 2. |
ci_alpha |
Transparency for CI underlay (0-1). Default 0.15. |
ci_color |
CI underlay color. NA (default) uses main edge color. |
ci_style |
Line type for CI underlay: 1=solid, 2=dashed, 3=dotted. Default 2. |
ci_arrows |
Logical: show arrows on CI underlay? Default FALSE. |
ci_lower |
Numeric vector of lower CI bounds for labels. |
ci_upper |
Numeric vector of upper CI bounds for labels. |
label_style |
Preset style: "none", "estimate", "full", "range", "stars". |
label_template |
Template with placeholders: {est}, {range}, {low}, {up}, {p}, {stars}. |
label_digits |
Decimal places for estimates in template. Default 2. |
label_ci_format |
CI format: "bracket" for |
label_p |
Numeric vector of p-values for edges. |
label_p_digits |
Decimal places for p-values. Default 3. |
label_p_prefix |
Prefix for p-values. Default "p=". |
label_stars |
Stars for labels: character vector, TRUE (compute from p), or numeric (treated as p-values). |
Most aesthetic parameters can be specified as:
A single value is applied to all edges.
A vector gives per-edge values and is recycled to the edge count.
"weight" maps width and color from the edge
weights.
A single string naming an edge column takes the values of that column.
When color = "weight", edges are colored by sign:
Positive weights use edge_positive_color (default: green)
Negative weights use edge_negative_color (default: red)
When width = "weight", edge widths scale linearly with absolute weight
values to the range 0.5 to 3, capped at maximum if set. Explicit
widths take precedence over edge_size, edge_width_range and
edge_scale_mode.
For statistical output (e.g., regression coefficients with CIs), use templates:
label_template = "\{est\}": Show estimate only
label_template = "\{est\} [\{low\}, \{up\}]": Estimate with CI
label_template = "\{est\}\{stars\}": Estimate with significance
Preset styles via label_style:
"estimate": Weight/estimate only
"full": Estimate + CI in brackets
"range": CI range only
"stars": Significance stars
Uncertainty is visualized as a wider, semi-transparent edge plotted behind the main edge.
ci: Vector of CI widths (0-1 scale)
ci_scale: Width multiplier (default 2)
ci_alpha: Transparency (default 0.15)
The input as a cograph_network object with the edge
aesthetics merged into its stored settings, ready to pipe into further
sn_* functions or soplot().
sn_nodes for node customization,
cograph for network creation,
soplot for plotting,
sn_layout for layout algorithms,
sn_theme for visual themes
cograph(regulation_net) |> sn_edges(width = "weight", color = "weight") |> soplot()cograph(regulation_net) |> sn_edges(width = "weight", color = "weight") |> soplot()
Builds a ggplot object of a network that can be modified and combined with
other ggplot2 layers. Nodes are points with labels and edges are straight
segments, with arrows when the network is directed. Edges with positive
weights are green and edges with negative weights are red. The plot uses
fixed default aesthetics and does not apply styling set with the
sn_* functions or a theme.
sn_ggplot(network, title = NULL)sn_ggplot(network, title = NULL)
network |
A |
title |
Optional plot title. |
A ggplot object.
sn_ggplot(regulation_net, title = "Regulation")sn_ggplot(regulation_net, title = "Regulation")
Apply a layout algorithm to compute node positions.
sn_layout(network, layout, seed = 42, ...)sn_layout(network, layout, seed = 42, ...)
network |
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
layout |
Layout algorithm name (see Details), a two-letter or full
igraph layout name, an igraph layout function, a |
seed |
Random seed for deterministic layouts. Default 42. Set NULL for random. |
... |
Additional arguments passed to the layout function. |
"spring"Force-directed layout (Fruchterman-Reingold).
"oval"/"ellipse"
Nodes arranged around an ellipse.
"circle"Nodes arranged in a circle.
"groups"Circular layout with grouped nodes clustered together.
"grid"Nodes in a regular grid.
"random"Random positions.
"star"Central node with others arranged around it.
"bipartite"Two-column layout for bipartite networks.
"gephi"/"gephi_fr"
Gephi-style force-directed layout.
Two-letter codes for igraph layouts: "kk" (Kamada-Kawai), "fr" (Fruchterman-Reingold), "drl", "mds", "ni" (nicely), "tr" (tree), "ci" (circle), etc.
igraph layout functions and full igraph layout names such as
"layout_with_kk" are also accepted.
The cograph_network with node coordinates in the x
and y columns of its node table.
cograph for network creation,
sn_nodes for node customization,
sn_edges for edge customization,
sn_theme for visual themes,
splot and soplot for plotting
cograph(regulation_net) |> sn_layout("circle") |> splot()cograph(regulation_net) |> sn_layout("circle") |> splot()
Sets the visual properties of the nodes in a network plot. Every argument
except network defaults to NULL, which leaves the current setting unchanged; the
defaults stated below are the values used at render time.
sn_nodes( network, size = NULL, shape = NULL, node_svg = NULL, svg_preserve_aspect = NULL, fill = NULL, border_color = NULL, border_width = NULL, alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_fill = NULL, donut_values = NULL, donut_color = NULL, donut_colors = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_shape = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_value_fontface = NULL, donut_value_fontfamily = NULL, donut_value_digits = NULL, donut_value_prefix = NULL, donut_value_suffix = NULL, donut_value_format = NULL, donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = NULL, label_fontface = NULL, label_fontfamily = NULL, label_hjust = NULL, label_vjust = NULL, label_angle = NULL, node_names = NULL )sn_nodes( network, size = NULL, shape = NULL, node_svg = NULL, svg_preserve_aspect = NULL, fill = NULL, border_color = NULL, border_width = NULL, alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_fill = NULL, donut_values = NULL, donut_color = NULL, donut_colors = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_shape = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_value_fontface = NULL, donut_value_fontfamily = NULL, donut_value_digits = NULL, donut_value_prefix = NULL, donut_value_suffix = NULL, donut_value_format = NULL, donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = NULL, label_fontface = NULL, label_fontfamily = NULL, label_hjust = NULL, label_vjust = NULL, label_angle = NULL, node_names = NULL )
network |
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
size |
Node size. Can be a single value, vector (per-node), or column name. |
shape |
Node shape. One of the shapes listed by |
node_svg |
Custom SVG for the node shape: a path to an SVG file or an
inline SVG string. It is registered as a temporary shape and replaces
|
svg_preserve_aspect |
Logical: maintain the SVG aspect ratio? The value is stored with the network, but the renderer always preserves the aspect ratio, so it has no effect at present. |
fill |
Node fill color. Can be a single color, vector, or column name. |
border_color |
Node border color. |
border_width |
Node border width. |
alpha |
Node opacity in [0, 1]. Values outside this range raise an error. |
label_size |
Label text size. |
label_color |
Label text color. |
label_position |
Label position: "center" (render default), "above", "below", "left" or "right". |
show_labels |
Logical. Show node labels? Default TRUE. |
pie_values |
For pie shape: list or matrix of values for pie segments. Each element corresponds to a node and contains values for its segments. |
pie_colors |
For pie shape: colors for pie segments. |
pie_border_width |
Border width for pie chart nodes. |
donut_fill |
For donut shape: numeric value (0-1) specifying fill proportion. A value of 0.5 fills half of the ring and 1 fills the whole ring. Can be a single value (all nodes) or vector (per-node values). |
donut_values |
Deprecated. Use |
donut_color |
For donut shape: fill color(s) for the donut ring. Single color sets fill for all nodes. Two colors set fill and background for all nodes. More than 2 colors set per-node fill colors (recycled to n_nodes). The render default is a "maroon" fill on a "gray90" background. |
donut_colors |
Deprecated. Use |
donut_border_width |
Border width for donut chart nodes. |
donut_inner_ratio |
For donut shape: inner radius ratio (0-1). Default 0.5. |
donut_bg_color |
For donut shape: background color for unfilled portion. |
donut_shape |
For donut: base shape for ring ("circle", "square", "hexagon", "triangle", "diamond", "pentagon"). Default NULL, which inherits the ring shape from the node's own shape (hexagon nodes get hexagon donuts); set it explicitly to override that for every node. |
donut_show_value |
For donut shape: show value in center? Default FALSE. |
donut_value_size |
For donut shape: font size for center value. |
donut_value_color |
For donut shape: color for center value text. |
donut_value_fontface |
For donut shape: font face for center value ("plain", "bold", "italic", "bold.italic"). Default "bold". |
donut_value_fontfamily |
For donut shape: font family for center value ("sans", "serif", "mono"). Default "sans". |
donut_value_digits |
For donut shape: decimal places for value display. Default 2. |
donut_value_prefix |
For donut shape: text before value (e.g., "$"). Default "". |
donut_value_suffix |
For donut shape: text after value (e.g., "%"). Default "". |
donut_value_format |
For donut shape: a function that formats the
center value. It replaces |
donut2_values |
For double donut: list of values for inner donut ring. |
donut2_colors |
For double donut: colors for inner donut ring segments. |
donut2_inner_ratio |
For double donut: inner radius ratio for inner donut ring. Default 0.4. |
label_fontface |
Font face for node labels: "plain", "bold", "italic", "bold.italic". Default "plain". |
label_fontfamily |
Font family for node labels: "sans", "serif", "mono", or system font. Default "sans". |
label_hjust |
Horizontal justification for node labels (0=left, 0.5=center, 1=right). Default 0.5. |
label_vjust |
Vertical justification for node labels (0=bottom, 0.5=center, 1=top). Default 0.5. |
label_angle |
Text rotation angle in degrees for node labels. Default 0. |
node_names |
Alternative names for legend (separate from display labels). |
The arguments size, shape, fill, border_color,
border_width, alpha, label_size, label_color,
label_position and node_names accept a single value, which is
applied to all nodes, or a per-node vector. A vector of another length is
recycled to the number of nodes without a warning. A single string that
matches a column of the node data frame is replaced by that column.
A donut node shows one proportion in [0, 1] per node. donut_fill
sets the proportion, donut_color the ring color, donut_shape
the base shape of the ring, and donut_show_value = TRUE prints the
value in the center.
The input as a cograph_network object, with the supplied
settings merged into its node aesthetics. It can be piped to further
customization or plotting functions.
sn_edges for edge customization,
cograph for network creation,
splot and soplot for plotting,
sn_layout for layout algorithms,
sn_theme for visual themes
cograph(regulation_net) |> sn_nodes(fill = "steelblue", shape = "square") |> splot()cograph(regulation_net) |> sn_nodes(fill = "steelblue", shape = "square") |> splot()
Apply a color palette for node and/or edge coloring.
sn_palette(network, palette, target = "nodes", by = NULL)sn_palette(network, palette, target = "nodes", by = NULL)
network |
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
palette |
Palette name (see |
target |
What to apply the palette to: "nodes" (default), "edges", or "both". For edges, the first two palette colors become the colors of positive and negative edges. |
by |
Name of a node-table column whose values are mapped to palette
colors. When |
Use list_palettes() to see all available palettes. Common options:
"viridis"Perceptually uniform, colorblind-friendly.
"colorblind"Optimized for color vision deficiency.
"pastel"Soft, muted colors.
"blues"Blue sequential palette.
"reds"Red sequential palette.
"diverging"Blue-white-red diverging palette.
The cograph_network with the node fill colors and edge colors
stored in its node_aes and edge_aes elements.
cograph for network creation,
sn_theme for visual themes,
sn_nodes for node customization,
list_palettes to see available palettes,
splot and soplot for plotting
cograph(regulation_net) |> sn_palette("viridis") |> splot()cograph(regulation_net) |> sn_palette("viridis") |> splot()
Save a Cograph network visualization to a file.
sn_save(network, filename, width = 7, height = 7, dpi = 300, title = NULL, ...)sn_save(network, filename, width = 7, height = 7, dpi = 300, title = NULL, ...)
network |
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
filename |
Output filename. Format is detected from the extension;
one of |
width |
Width in inches (default 7). |
height |
Height in inches (default 7). |
dpi |
Resolution for raster formats (default 300). |
title |
Optional plot title. |
... |
Additional arguments passed to the graphics device. |
The output filename, invisibly.
sn_save(cograph(regulation_net), filename = file.path(tempdir(), "network.pdf"))sn_save(cograph(regulation_net), filename = file.path(tempdir(), "network.pdf"))
Save network as a ggplot2 object to file using ggsave.
sn_save_ggplot( network, filename, width = 7, height = 7, dpi = 300, title = NULL, ... )sn_save_ggplot( network, filename, width = 7, height = 7, dpi = 300, title = NULL, ... )
network |
A cograph_network object. |
filename |
Output filename. Format is detected from the extension by
|
width |
Width in inches (default 7). |
height |
Height in inches (default 7). |
dpi |
Resolution for raster formats (default 300). |
title |
Optional plot title. |
... |
Additional arguments passed to ggsave. |
The output filename, invisibly.
sn_save_ggplot(cograph(regulation_net), filename = file.path(tempdir(), "network.pdf"))sn_save_ggplot(cograph(regulation_net), filename = file.path(tempdir(), "network.pdf"))
Apply a visual theme to the network.
sn_theme(network, theme, ...)sn_theme(network, theme, ...)
network |
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted. |
theme |
Theme name (string) or CographTheme object. |
... |
Theme parameters to override, such as |
"classic"White background, blue nodes and gray edges.
"dark"Dark background with bright nodes, for presentations.
"minimal"Subtle styling with thin edges and muted colors.
"colorblind"Optimized for color vision deficiency.
"gray"/"grey"
Black and white theme suitable for print.
"viridis"Perceptually uniform colors.
"nature"Nature-inspired colors.
Use list_themes() to see all available themes.
The cograph_network with the theme stored in its
theme element.
cograph for network creation,
sn_palette for color palettes,
sn_nodes for node customization,
sn_edges for edge customization,
list_themes to see available themes,
splot and soplot for plotting
cograph(regulation_net) |> sn_theme("dark") |> splot()cograph(regulation_net) |> sn_theme("dark") |> splot()
Plots a network with grid graphics. Node and edge aesthetics can be passed
as arguments or set beforehand with sn_nodes and
sn_edges.
soplot( network, title = NULL, title_size = 14, margins = c(0.05, 0.05, 0.1, 0.05), layout_margin = 0.15, newpage = TRUE, background = "white", layout = NULL, theme = NULL, seed = 42, labels = NULL, threshold = NULL, maximum = NULL, node_size = NULL, node_shape = NULL, node_fill = NULL, node_border_color = NULL, node_border_width = NULL, node_alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_values = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_fill = NULL, donut_color = NULL, donut_colors = NULL, donut_shape = "circle", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_width_scale = NULL, edge_color = NULL, edge_alpha = NULL, edge_style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, edge_duplicates = NULL, edge_labels = NULL, edge_label_size = NULL, edge_label_color = NULL, edge_label_position = NULL, edge_label_offset = NULL, edge_label_bg = NULL, edge_label_fontface = NULL, edge_label_border = NULL, edge_label_border_color = NULL, edge_label_underline = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, node_names = NULL, legend = FALSE, legend_position = "topright", scaling = "default", weight_digits = 2 ) sn_render( network, title = NULL, title_size = 14, margins = c(0.05, 0.05, 0.1, 0.05), layout_margin = 0.15, newpage = TRUE, background = "white", layout = NULL, theme = NULL, seed = 42, labels = NULL, threshold = NULL, maximum = NULL, node_size = NULL, node_shape = NULL, node_fill = NULL, node_border_color = NULL, node_border_width = NULL, node_alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_values = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_fill = NULL, donut_color = NULL, donut_colors = NULL, donut_shape = "circle", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_width_scale = NULL, edge_color = NULL, edge_alpha = NULL, edge_style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, edge_duplicates = NULL, edge_labels = NULL, edge_label_size = NULL, edge_label_color = NULL, edge_label_position = NULL, edge_label_offset = NULL, edge_label_bg = NULL, edge_label_fontface = NULL, edge_label_border = NULL, edge_label_border_color = NULL, edge_label_underline = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, node_names = NULL, legend = FALSE, legend_position = "topright", scaling = "default", weight_digits = 2 )soplot( network, title = NULL, title_size = 14, margins = c(0.05, 0.05, 0.1, 0.05), layout_margin = 0.15, newpage = TRUE, background = "white", layout = NULL, theme = NULL, seed = 42, labels = NULL, threshold = NULL, maximum = NULL, node_size = NULL, node_shape = NULL, node_fill = NULL, node_border_color = NULL, node_border_width = NULL, node_alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_values = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_fill = NULL, donut_color = NULL, donut_colors = NULL, donut_shape = "circle", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_width_scale = NULL, edge_color = NULL, edge_alpha = NULL, edge_style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, edge_duplicates = NULL, edge_labels = NULL, edge_label_size = NULL, edge_label_color = NULL, edge_label_position = NULL, edge_label_offset = NULL, edge_label_bg = NULL, edge_label_fontface = NULL, edge_label_border = NULL, edge_label_border_color = NULL, edge_label_underline = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, node_names = NULL, legend = FALSE, legend_position = "topright", scaling = "default", weight_digits = 2 ) sn_render( network, title = NULL, title_size = 14, margins = c(0.05, 0.05, 0.1, 0.05), layout_margin = 0.15, newpage = TRUE, background = "white", layout = NULL, theme = NULL, seed = 42, labels = NULL, threshold = NULL, maximum = NULL, node_size = NULL, node_shape = NULL, node_fill = NULL, node_border_color = NULL, node_border_width = NULL, node_alpha = NULL, label_size = NULL, label_color = NULL, label_position = NULL, show_labels = NULL, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_values = NULL, donut_border_width = NULL, donut_inner_ratio = NULL, donut_bg_color = NULL, donut_show_value = NULL, donut_value_size = NULL, donut_value_color = NULL, donut_fill = NULL, donut_color = NULL, donut_colors = NULL, donut_shape = "circle", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = NULL, edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_width_scale = NULL, edge_color = NULL, edge_alpha = NULL, edge_style = NULL, curvature = NULL, arrow_size = NULL, show_arrows = NULL, edge_positive_color = NULL, positive_color = NULL, edge_negative_color = NULL, negative_color = NULL, edge_duplicates = NULL, edge_labels = NULL, edge_label_size = NULL, edge_label_color = NULL, edge_label_position = NULL, edge_label_offset = NULL, edge_label_bg = NULL, edge_label_fontface = NULL, edge_label_border = NULL, edge_label_border_color = NULL, edge_label_underline = NULL, bidirectional = NULL, loop_rotation = NULL, curve_shape = NULL, curve_pivot = NULL, curves = NULL, node_names = NULL, legend = FALSE, legend_position = "topright", scaling = "default", weight_digits = 2 )
network |
A cograph_network object, matrix, data.frame, igraph or tna
object. Other inputs are converted with |
title |
Optional plot title. |
title_size |
Title font size. |
margins |
Plot margins as c(bottom, left, top, right). |
layout_margin |
Margin around the network layout (proportion of viewport). Default 0.15. |
newpage |
Logical. Start a new graphics page? Default TRUE. |
background |
Background color for the plot. Default "white". |
layout |
Layout algorithm. Built-in: "circle", "spring", "groups", "grid", "random", "star", "bipartite". igraph (2-letter): "kk" (Kamada-Kawai), "fr" (Fruchterman-Reingold), "drl", "mds", "ni" (nicely), "tr" (tree), etc. Can also pass a coordinate matrix or igraph layout function directly. NULL (default) keeps the layout stored in a cograph_network and uses "oval" for inputs without stored coordinates. |
theme |
Theme name: "classic", "dark", "minimal", etc. |
seed |
Random seed for deterministic layouts. Default 42. Set NULL for random. |
labels |
Node labels. Can be a character vector to set custom labels. |
threshold |
Minimum absolute edge weight to display. Edges with abs(weight) < threshold are hidden. Similar to qgraph's threshold. |
maximum |
Maximum edge weight for width scaling. Weights above this are capped. Similar to qgraph's maximum parameter. |
node_size |
Node size. |
node_shape |
Node shape: "circle", "square", "triangle", "diamond", "ellipse", "heart", "star", "pie", "donut", "cross". |
node_fill |
Node fill color. |
node_border_color |
Node border color. |
node_border_width |
Node border width. |
node_alpha |
Node transparency (0-1). |
label_size |
Node label text size. |
label_color |
Node label text color. |
label_position |
Label position: "center", "above", "below", "left", "right". |
show_labels |
Logical. Show node labels? |
pie_values |
For pie/donut/donut_pie nodes: list or matrix of values for segments. For donut with single value (0-1), shows that proportion filled. |
pie_colors |
For pie/donut/donut_pie nodes: colors for pie segments. |
pie_border_width |
Border width for pie chart segments. |
donut_values |
For donut_pie nodes: vector of values (0-1) for outer ring proportion. |
donut_border_width |
Border width for donut ring. |
donut_inner_ratio |
For donut nodes: inner radius ratio (0-1). Default 0.5. |
donut_bg_color |
For donut nodes: background color for unfilled portion. |
donut_show_value |
For donut nodes: show value in center? Default FALSE. |
donut_value_size |
For donut nodes: font size for center value. |
donut_value_color |
For donut nodes: color for center value text. |
donut_fill |
Numeric value (0-1) for donut fill proportion. This is the simplified API for creating donut charts. Can be a single value or vector per node. |
donut_color |
Fill color(s) for the donut ring. Simplified API: single color for fill, or c(fill, background) for both. |
donut_colors |
Deprecated. Use donut_color instead. |
donut_shape |
Base shape for donut: "circle", "square", "hexagon", "triangle",
"diamond", "pentagon". The default "circle" takes the base shape from
|
donut_value_fontface |
Font face for donut center value: "plain", "bold", "italic", "bold.italic". Default "bold". |
donut_value_fontfamily |
Font family for donut center value. Default "sans". |
donut_value_digits |
Decimal places for donut center value. Default 2. |
donut_value_prefix |
Text before donut center value (e.g., "$"). Default "". |
donut_value_suffix |
Text after donut center value (e.g., "%"). Default "". |
donut2_values |
List of values for inner donut ring (for double donut). |
donut2_colors |
List of color vectors for inner donut ring segments. |
donut2_inner_ratio |
Inner radius ratio for inner donut ring. Default 0.4. |
edge_width |
Edge width. If NULL, scales by weight using edge_size and edge_width_range. |
edge_size |
Maximum edge width for weight scaling. It replaces the upper
bound of |
esize |
Deprecated. Use |
edge_width_range |
Output width range as c(min, max) for weight-based scaling. Default c(0.5, 4). Edges are scaled to fit within this range. |
edge_scale_mode |
Scaling mode for edge weights: "linear" (default), "log" (for wide weight ranges), "sqrt" (moderate compression), or "rank" (equal visual spacing). |
edge_cutoff |
Accepted for compatibility with |
cut |
Deprecated. Use |
edge_width_scale |
Scale factor for edge widths. Values > 1 make edges thicker. |
edge_color |
Edge color. |
edge_alpha |
Edge transparency (0-1). |
edge_style |
Line style: "solid", "dashed", "dotted", "longdash", "twodash". |
curvature |
Edge curvature amount. |
arrow_size |
Size of arrow heads. |
show_arrows |
Logical. Show arrows? |
edge_positive_color |
Color for positive edge weights. |
positive_color |
Deprecated. Use |
edge_negative_color |
Color for negative edge weights. |
negative_color |
Deprecated. Use |
edge_duplicates |
How to handle duplicate edges in undirected networks. NULL (default) = stop with error listing duplicates. Options: "sum", "mean", "first", "max", "min", or a custom aggregation function. |
edge_labels |
Edge labels. Can be TRUE to show weights, or a vector. |
edge_label_size |
Edge label text size. |
edge_label_color |
Edge label text color. |
edge_label_position |
Position along edge (0 = source, 0.5 = middle, 1 = target). |
edge_label_offset |
Perpendicular offset from edge line. |
edge_label_bg |
Background color for edge labels (default "white"). Set to NA for transparent. |
edge_label_fontface |
Font face: "plain", "bold", "italic", "bold.italic". |
edge_label_border |
Border style: NULL, "rect", "rounded", "circle". |
edge_label_border_color |
Border color for label border. |
edge_label_underline |
Logical. Underline the label text? |
bidirectional |
Logical. Show arrows at both ends of edges? |
loop_rotation |
Angle in radians for self-loop direction (default: pi/2 = top). |
curve_shape |
Spline tension for curved edges (-1 to 1, default: 0). |
curve_pivot |
Pivot position along edge for curve control point (0-1, default: 0.5). |
curves |
Curve mode. NULL (default) or "mutual" keeps single edges
straight and curves reciprocal edges as two opposing arcs; FALSE plots all
edges straight; "force" curves all edges. |
node_names |
Alternative names for legend (separate from display labels). |
legend |
Logical. Show legend? |
legend_position |
Legend position: "topright", "topleft", "bottomright", "bottomleft". |
scaling |
Scaling mode: "default" for qgraph-matched scaling where node_size=6 looks similar to qgraph vsize=6, or "legacy" for the earlier cograph scaling constants. |
weight_digits |
Number of decimal places to which a matrix input is rounded before conversion, so that entries rounding to zero are not plotted as edges. Other inputs are not rounded. Default 2. Set NULL to disable rounding. |
soplot() uses grid graphics and splot() uses base R graphics.
The two functions share argument names for the common aesthetics, and
splot() has a larger set of arguments.
With the default curves, reciprocal edge pairs (A->B and
B->A) curve in opposite directions and single edges remain straight.
curves = FALSE plots all edges as straight lines, and
curves = "force" curves every edge.
edge_scale_mode sets how edge weights map to widths. "linear"
makes width proportional to weight, "log" compresses weights that
span orders of magnitude, "sqrt" gives moderate compression, and
"rank" spaces widths evenly by weight rank.
Donuts show proportions (0-1) as filled rings around nodes.
donut_fill sets the filled proportion per node, donut_color
sets the fill color (or fill and background), donut_shape sets the
base shape and donut_show_value prints the value in the center.
The updated cograph_network object, invisibly. The function
is called for the plot it produces.
The updated cograph_network object, invisibly. The function
is called for the plot it produces.
splot for base R graphics rendering (alternative engine),
cograph for creating network objects,
sn_nodes for node customization,
sn_edges for edge customization,
sn_layout for layout algorithms,
sn_theme for visual themes,
from_qgraph and from_tna for converting external objects
soplot(regulation_net, layout = "circle")soplot(regulation_net, layout = "circle")
Computes a spanning tree with Prim's algorithm on each connected component,
so a disconnected network yields a spanning forest. A directed network is
symmetrized first, each pair taking the larger of its two arc weights.
Self-loops are ignored. Missing or infinite weights raise a
cograph_bad_selection error.
spanning_tree( x, weights = c("weight", "none"), maximum = FALSE, keep_format = FALSE, directed = NULL )spanning_tree( x, weights = c("weight", "none"), maximum = FALSE, keep_format = FALSE, directed = NULL )
x |
Network input. |
weights |
|
maximum |
Logical. Find the maximum spanning tree instead of the minimum. Default FALSE. Set TRUE when the weights are similarities. |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. The tree itself is undirected. |
An undirected cograph_network holding the spanning tree (or
forest), or the input format when keep_format = TRUE. Every node is
kept.
Prim, R. C. (1957). Shortest connection networks and some generalizations. Bell System Technical Journal, 36(6), 1389–1401.
disparity_filter, threshold_edges
spanning_tree(regulation_net, maximum = TRUE)spanning_tree(regulation_net, maximum = TRUE)
Split a Network into Its Connected Components
split_components(x, min_size = 1L, keep_format = FALSE, directed = NULL)split_components(x, min_size = 1L, keep_format = FALSE, directed = NULL)
x |
Network input. |
min_size |
Integer. Components with fewer nodes are dropped. Default 1 keeps every component, including isolated nodes. |
keep_format |
Logical. If TRUE, each component of a matrix, igraph,
statnet network or tna input is returned in that format. An edge-list
data frame or a qgraph object gives |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A list of cograph_network objects, one per component, ordered
from largest to smallest and named "component_1",
"component_2", and so on. Components are weakly connected, matching
igraph::components(mode = "weak"). A network with no nodes gives an
empty list and a warning.
select_component, remove_isolates
split_components(threshold_edges(regulation_net, minimum = 0.3))split_components(threshold_edges(regulation_net, minimum = 0.3))
Plots a network with base R graphics (polygon(),
lines(), xspline()). splot() uses the same
snake_case argument names as the grid-based soplot().
Result objects of tna, Nestimate and cograph analyses are plotted by the
methods described in Details.
splot.net_bootstrap( x, display = c("styled", "significant", "full"), show_ci = FALSE, show_stars = TRUE, inherit_style = TRUE, ... ) splot.tna_communities(x, ...) splot.cograph_communities(x, ...) splot.net_mlvar(x, type = "temporal", combined = TRUE, ...) splot.netobject(x, ...) splot.boot_glasso( x, use_thresholded = TRUE, show_inclusion = TRUE, inclusion_threshold = NULL, edge_positive_color = "#2E7D32", edge_negative_color = "#C62828", ... ) splot.wtna_mixed(x, type = c("overlay", "group"), ...) splot.net_permutation( x, show_nonsig = FALSE, show_effect = FALSE, edge_positive_color = "#009900", edge_negative_color = "#C62828", edge_nonsig_color = "#888888", edge_nonsig_style = 2L, show_stars = TRUE, ... ) splot( x, layout = "oval", directed = NULL, seed = 42, theme = NULL, node_size = NULL, node_size2 = NULL, scale_nodes_by = NULL, node_size_range = c(2, 8), scale_nodes_scale = 1, node_shape = "circle", node_svg = NULL, svg_preserve_aspect = TRUE, node_fill = NULL, node_border_color = NULL, node_border_width = 1, node_alpha = 1, labels = TRUE, label_abbrev = NULL, label_size = NULL, label_color = "black", label_position = "center", label_fontface = "plain", label_fontfamily = "sans", label_hjust = 0.5, label_vjust = 0.5, label_angle = 0, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_fill = NULL, donut_values = NULL, donut_color = NULL, donut_colors = NULL, donut_border_color = NULL, donut_border_width = NULL, donut_inner_border_color = NULL, donut_inner_border_width = NULL, donut_outer_border_color = NULL, donut_line_type = "solid", donut_border_lty = NULL, donut_inner_ratio = 0.8, donut_bg_color = "gray90", donut_shape = "circle", donut_show_value = FALSE, donut_value_size = 0.8, donut_value_color = "black", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut_empty = TRUE, donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_color = NULL, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = c(0.1, 4), edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_alpha = 0.8, edge_labels = FALSE, edge_label_size = 0.8, edge_label_color = "gray30", edge_label_bg = NA, edge_label_position = 0.5, edge_label_offset = 0, edge_label_fontface = "plain", edge_label_shadow = FALSE, edge_label_shadow_color = "gray40", edge_label_shadow_offset = 0.5, edge_label_shadow_alpha = 0.5, edge_label_halo = TRUE, edge_style = 1, curvature = 0, curve_scale = TRUE, curve_shape = 0, curve_pivot = 0.5, curves = TRUE, arrow_size = 1, arrow_angle = pi/6, show_arrows = TRUE, bidirectional = FALSE, loop_rotation = NULL, show = NULL, edge_start_style = "solid", edge_start_length = 0.15, edge_start_dot_density = "12", edge_ci = NULL, edge_ci_scale = 2, edge_ci_alpha = 0.15, edge_ci_color = NA, edge_ci_style = 2, edge_ci_arrows = FALSE, edge_priority = NULL, edge_label_style = "none", edge_label_template = NULL, edge_label_digits = 2, edge_label_oneline = TRUE, edge_label_ci_format = "bracket", edge_label_leading_zero = TRUE, edge_ci_lower = NULL, edge_ci_upper = NULL, edge_label_p = NULL, edge_label_p_diff = NULL, edge_label_p_digits = 3, edge_label_p_prefix = "p=", edge_label_stars = NULL, weight_digits = 2, threshold = 0, minimum = 0, maximum = NULL, edge_positive_color = "#2E7D32", positive_color = NULL, edge_negative_color = "#C62828", negative_color = NULL, edge_duplicates = NULL, title = NULL, title_size = 1.2, margins = c(0.1, 0.1, 0.1, 0.1), background = "white", rescale = TRUE, layout_scale = 1, layout_margin = 0.15, aspect = TRUE, use_pch = FALSE, usePCH = NULL, scaling = "default", align_panels = FALSE, legend = FALSE, legend_position = "topright", legend_size = 0.8, legend_edge_colors = TRUE, legend_node_sizes = FALSE, groups = NULL, node_names = NULL, tna_styling = NULL, psych_styling = NULL, predictability = NULL, i = NULL, filetype = "default", filename = file.path(tempdir(), "splot"), width = 7, height = 7, res = 600, ... )splot.net_bootstrap( x, display = c("styled", "significant", "full"), show_ci = FALSE, show_stars = TRUE, inherit_style = TRUE, ... ) splot.tna_communities(x, ...) splot.cograph_communities(x, ...) splot.net_mlvar(x, type = "temporal", combined = TRUE, ...) splot.netobject(x, ...) splot.boot_glasso( x, use_thresholded = TRUE, show_inclusion = TRUE, inclusion_threshold = NULL, edge_positive_color = "#2E7D32", edge_negative_color = "#C62828", ... ) splot.wtna_mixed(x, type = c("overlay", "group"), ...) splot.net_permutation( x, show_nonsig = FALSE, show_effect = FALSE, edge_positive_color = "#009900", edge_negative_color = "#C62828", edge_nonsig_color = "#888888", edge_nonsig_style = 2L, show_stars = TRUE, ... ) splot( x, layout = "oval", directed = NULL, seed = 42, theme = NULL, node_size = NULL, node_size2 = NULL, scale_nodes_by = NULL, node_size_range = c(2, 8), scale_nodes_scale = 1, node_shape = "circle", node_svg = NULL, svg_preserve_aspect = TRUE, node_fill = NULL, node_border_color = NULL, node_border_width = 1, node_alpha = 1, labels = TRUE, label_abbrev = NULL, label_size = NULL, label_color = "black", label_position = "center", label_fontface = "plain", label_fontfamily = "sans", label_hjust = 0.5, label_vjust = 0.5, label_angle = 0, pie_values = NULL, pie_colors = NULL, pie_border_width = NULL, donut_fill = NULL, donut_values = NULL, donut_color = NULL, donut_colors = NULL, donut_border_color = NULL, donut_border_width = NULL, donut_inner_border_color = NULL, donut_inner_border_width = NULL, donut_outer_border_color = NULL, donut_line_type = "solid", donut_border_lty = NULL, donut_inner_ratio = 0.8, donut_bg_color = "gray90", donut_shape = "circle", donut_show_value = FALSE, donut_value_size = 0.8, donut_value_color = "black", donut_value_fontface = "bold", donut_value_fontfamily = "sans", donut_value_digits = 2, donut_value_prefix = "", donut_value_suffix = "", donut_empty = TRUE, donut2_values = NULL, donut2_colors = NULL, donut2_inner_ratio = 0.4, edge_color = NULL, edge_width = NULL, edge_size = NULL, esize = NULL, edge_width_range = c(0.1, 4), edge_scale_mode = "linear", edge_cutoff = NULL, cut = NULL, edge_alpha = 0.8, edge_labels = FALSE, edge_label_size = 0.8, edge_label_color = "gray30", edge_label_bg = NA, edge_label_position = 0.5, edge_label_offset = 0, edge_label_fontface = "plain", edge_label_shadow = FALSE, edge_label_shadow_color = "gray40", edge_label_shadow_offset = 0.5, edge_label_shadow_alpha = 0.5, edge_label_halo = TRUE, edge_style = 1, curvature = 0, curve_scale = TRUE, curve_shape = 0, curve_pivot = 0.5, curves = TRUE, arrow_size = 1, arrow_angle = pi/6, show_arrows = TRUE, bidirectional = FALSE, loop_rotation = NULL, show = NULL, edge_start_style = "solid", edge_start_length = 0.15, edge_start_dot_density = "12", edge_ci = NULL, edge_ci_scale = 2, edge_ci_alpha = 0.15, edge_ci_color = NA, edge_ci_style = 2, edge_ci_arrows = FALSE, edge_priority = NULL, edge_label_style = "none", edge_label_template = NULL, edge_label_digits = 2, edge_label_oneline = TRUE, edge_label_ci_format = "bracket", edge_label_leading_zero = TRUE, edge_ci_lower = NULL, edge_ci_upper = NULL, edge_label_p = NULL, edge_label_p_diff = NULL, edge_label_p_digits = 3, edge_label_p_prefix = "p=", edge_label_stars = NULL, weight_digits = 2, threshold = 0, minimum = 0, maximum = NULL, edge_positive_color = "#2E7D32", positive_color = NULL, edge_negative_color = "#C62828", negative_color = NULL, edge_duplicates = NULL, title = NULL, title_size = 1.2, margins = c(0.1, 0.1, 0.1, 0.1), background = "white", rescale = TRUE, layout_scale = 1, layout_margin = 0.15, aspect = TRUE, use_pch = FALSE, usePCH = NULL, scaling = "default", align_panels = FALSE, legend = FALSE, legend_position = "topright", legend_size = 0.8, legend_edge_colors = TRUE, legend_node_sizes = FALSE, groups = NULL, node_names = NULL, tna_styling = NULL, psych_styling = NULL, predictability = NULL, i = NULL, filetype = "default", filename = file.path(tempdir(), "splot"), width = 7, height = 7, res = 600, ... )
x |
Network input. Can be:
|
display |
Display mode of |
show_ci |
Logical. Add the confidence bounds to the edge labels of a
|
show_stars |
Logical. Show significance stars in the edge labels of a
|
inherit_style |
Logical. Take labels, layout and colors from the
original network of a |
... |
For |
type |
For a |
combined |
Logical. With |
use_thresholded |
Logical. Plot |
show_inclusion |
Logical. Map the inclusion probability of each edge
of a |
inclusion_threshold |
Numeric. Minimum inclusion probability of a
plotted |
edge_positive_color |
Color for positive weights. The default is
|
edge_negative_color |
Color for negative weights. Default
|
show_nonsig |
Logical. Show non-significant edges of a
|
show_effect |
Logical. Show the effect size in parentheses in the edge
labels of a |
edge_nonsig_color |
Color of non-significant edges. Default
|
edge_nonsig_style |
Line type of non-significant edges. Default 2. |
layout |
Layout algorithm: "oval" (default), "circle", "spring",
"groups", "target" (qgraph-style focal-node BFS levels; node of interest
via |
directed |
Logical. Force directed interpretation. NULL for auto-detect. |
seed |
Random seed for deterministic layouts. Default 42. |
theme |
Theme name: "classic", "dark", "minimal", "colorblind", etc. |
node_size |
Node size(s). Single value or vector. Default NULL, which resolves to 7 with default scaling. |
node_size2 |
Secondary node size for ellipse/rectangle height. |
scale_nodes_by |
Scale node sizes by a centrality measure. Can be:
When used, node_size is ignored. Use node_size_range to control the min/max size. Default NULL (no centrality scaling). |
node_size_range |
Size range for centrality-based scaling. Numeric vector c(min_size, max_size). Default c(2, 8). |
scale_nodes_scale |
Dampening exponent for centrality-based sizing. Values < 1 compress differences (e.g., 0.5 applies square root), values > 1 exaggerate differences. Default 1 (linear). |
node_shape |
Node shape(s): "circle", "square", "triangle", "diamond", "pentagon", "hexagon", "star", "heart", "ellipse", "cross", or any custom SVG shape registered with register_svg_shape(). |
node_svg |
Custom SVG for nodes: path to SVG file OR inline SVG string. |
svg_preserve_aspect |
Logical: maintain SVG aspect ratio? Default TRUE. |
node_fill |
Node fill color(s). |
node_border_color |
Node border color(s). |
node_border_width |
Node border width(s). |
node_alpha |
Node transparency (0-1). Default 1. |
labels |
Node labels: TRUE (use node names/indices), FALSE (none), or character vector. |
label_abbrev |
Controls label abbreviation in the same way as
|
label_size |
Label character expansion factor. |
label_color |
Label text color. |
label_position |
Label position: "center", "above", "below", "left", "right". |
label_fontface |
Font face for labels: "plain", "bold", "italic", "bold.italic". Default "plain". |
label_fontfamily |
Font family for labels: "sans", "serif", "mono". Default "sans". |
label_hjust |
Horizontal justification (0=left, 0.5=center, 1=right). Default 0.5. |
label_vjust |
Vertical justification (0=bottom, 0.5=center, 1=top). Default 0.5. |
label_angle |
Text rotation angle in degrees. Default 0. |
pie_values |
List of numeric vectors for pie chart nodes. Each element corresponds to a node and contains values for pie segments. If a simple numeric vector with values between 0 and 1 is provided (e.g., centrality scores), it is automatically converted to donut_fill for convenience. |
pie_colors |
List of color vectors for pie segments. |
pie_border_width |
Border width for pie slice dividers. NULL uses node_border_width. |
donut_fill |
Numeric value (0-1) for donut fill proportion. This is the qgraph-style API: 0.1 = 10% filled, 0.5 = 50% filled, 1.0 = fully filled. Can be a single value (all nodes) or vector (per-node values). |
donut_values |
Deprecated. Use donut_fill for simple fill proportion. |
donut_color |
Fill color(s) for the donut ring. Single color sets fill for all nodes. Two colors set fill and background for all nodes. More than 2 colors set per-node fill colors (recycled to n_nodes). Default: "maroon" fill, "gray90" background when node_shape="donut". |
donut_colors |
Deprecated. Use donut_color instead. |
donut_border_color |
Border color for donut rings. NULL uses node_border_color. |
donut_border_width |
Border width for donut rings. NULL uses node_border_width. |
donut_inner_border_color |
Color for the inner boundary (where the
donut meets its hole). NULL (default) uses |
donut_inner_border_width |
Width for the inner boundary border.
NULL (default) uses |
donut_outer_border_color |
Color for outer boundary border (enables double border). NULL (default) shows single border. Set to a color for double border effect. Can be scalar or per-node vector. |
donut_line_type |
Line type for donut borders: "solid", "dashed", "dotted", or numeric (1=solid, 2=dashed, 3=dotted). Can be scalar or per-node vector. |
donut_border_lty |
Deprecated. Use |
donut_inner_ratio |
Inner radius ratio for donut (0-1). Default 0.8. |
donut_bg_color |
Background color for unfilled donut portion. |
donut_shape |
Base shape for donut: "circle", "square", "hexagon", "triangle", "diamond", "pentagon". Can be a single value or per-node vector. Default inherits from node_shape (e.g., hexagon nodes get hexagon donuts). Set explicitly to override (e.g., donut_shape = "hexagon" for hexagon donuts on all nodes regardless of node_shape). |
donut_show_value |
Logical: show value in donut center? Default FALSE. |
donut_value_size |
Font size for donut center value. |
donut_value_color |
Color for donut center value. |
donut_value_fontface |
Font face for donut center value: "plain", "bold", "italic", "bold.italic". Default "bold". |
donut_value_fontfamily |
Font family for donut center value: "sans", "serif", "mono". Default "sans". |
donut_value_digits |
Decimal places for donut center value. Default 2. |
donut_value_prefix |
Text before donut center value (e.g., "$"). Default "". |
donut_value_suffix |
Text after donut center value (e.g., "%"). Default "". |
donut_empty |
Logical: render empty donut rings for NA values? Default TRUE. |
donut2_values |
List of values for inner donut ring (for double donut). |
donut2_colors |
List of color vectors for inner donut ring segments. |
donut2_inner_ratio |
Inner radius ratio for inner donut ring. Default 0.4. |
edge_color |
Edge color(s). If NULL, uses edge_positive_color/edge_negative_color based on weight. |
edge_width |
Edge width(s). If NULL, scales by weight using edge_size and edge_width_range. |
edge_size |
Maximum edge size for weight scaling. NULL (default) uses
the upper bound of |
esize |
Deprecated. Use |
edge_width_range |
Output width range as c(min, max) for weight-based scaling.
Default c(0.1, 4). Edges are scaled to fit within this range unless
|
edge_scale_mode |
Scaling mode for edge weights: "linear" (default, qgraph-style), "log" (logarithmic for wide weight ranges), "sqrt" (moderate compression), or "rank" (equal visual spacing regardless of weight distribution). |
edge_cutoff |
Optional cutoff for edge emphasis. NULL (default) or 0 disables cutoff fading. Positive values fade edges whose absolute weights are below the cutoff; width scaling remains continuous. |
cut |
Deprecated. Use |
edge_alpha |
Edge transparency (0-1). Default 0.8. |
edge_labels |
Edge labels: TRUE (show weights), FALSE (none), or character vector. |
edge_label_size |
Edge label size. |
edge_label_color |
Edge label text color. |
edge_label_bg |
Edge label background color. |
edge_label_position |
Position along edge (0-1). |
edge_label_offset |
Perpendicular offset for edge labels (0 = on line, positive = above). |
edge_label_fontface |
Font face: "plain", "bold", "italic", "bold.italic". |
edge_label_shadow |
Logical: enable drop shadow for edge labels? Default FALSE. |
edge_label_shadow_color |
Color for edge label shadow. Default "gray40". |
edge_label_shadow_offset |
Offset distance for shadow in points. Default 0.5. |
edge_label_shadow_alpha |
Transparency for shadow (0-1). Default 0.5. |
edge_label_halo |
Logical: enable white halo/outline around edge labels for readability over dark edges? Default TRUE. When TRUE, overrides shadow settings. |
edge_style |
Line type(s): 1=solid, 2=dashed, 3=dotted, etc. |
curvature |
Edge curvature. 0 for straight, positive/negative for curves. |
curve_scale |
Not used. |
curve_shape |
Spline tension (-1 to 1). Default 0. |
curve_pivot |
Position along edge for curve control point (0-1). |
curves |
Curve mode: TRUE (default) = single edges straight, reciprocal edges curve as ellipse (two opposing curves); FALSE = all straight; "force" = all curved. |
arrow_size |
Arrow head size. |
arrow_angle |
Arrow head angle in radians. Default pi/6 (30 degrees). |
show_arrows |
Logical or vector: show arrows on directed edges? |
bidirectional |
Logical or vector: show arrows at both ends? |
loop_rotation |
Angle(s) in radians for self-loop direction. |
show |
Dispatch-only placeholder used by method dispatch (e.g.,
|
edge_start_style |
Style for the start segment of edges: "solid" (default), "dashed", or "dotted". Use dashed/dotted to indicate edge direction (source node). |
edge_start_length |
Fraction of edge length for the styled start segment (0-0.5). Default 0.15 (15% of edge). Only applies when edge_start_style is not "solid". |
edge_start_dot_density |
Pattern for dotted start segments. A two-character string where the first digit is dot length and second is gap length (in line width units). Default "12" (1 unit dot, 2 units gap). Use "11" for tighter dots, "13" for more spacing. Only applies when edge_start_style = "dotted". |
edge_ci |
Numeric vector of CI widths (0-1 scale). Larger values = more uncertainty. |
edge_ci_scale |
Width multiplier for underlay thickness. Default 2. |
edge_ci_alpha |
Transparency for underlay (0-1). Default 0.15. |
edge_ci_color |
Underlay color. NA (default) uses main edge color. |
edge_ci_style |
Line type for underlay: 1=solid, 2=dashed, 3=dotted. Default 2. |
edge_ci_arrows |
Logical: show arrows on underlay? Default FALSE. |
edge_priority |
Numeric vector of edge priorities. Higher values render on top. Useful for ensuring significant edges appear above non-significant ones. |
edge_label_style |
Preset style: "none", "estimate", "full", "range", "stars". |
edge_label_template |
Template with placeholders: {est}, {range}, {low}, {up}, {p}, {p_diff}, {stars}. Overrides edge_label_style if provided. |
edge_label_digits |
Decimal places for estimates. Default 2. |
edge_label_oneline |
Logical: single line format? Default TRUE. |
edge_label_ci_format |
CI format: "bracket" for |
edge_label_leading_zero |
Logical: show leading zero for values < 1? Default TRUE. Set to FALSE to display ".5" instead of "0.5". |
edge_ci_lower |
Numeric vector of lower CI bounds for labels. |
edge_ci_upper |
Numeric vector of upper CI bounds for labels. |
edge_label_p |
Numeric vector of p-values for edges. |
edge_label_p_diff |
Probability-of-difference values for the
|
edge_label_p_digits |
Decimal places for p-values. Default 3. |
edge_label_p_prefix |
Prefix for p-values. Default "p=". |
edge_label_stars |
Stars for labels: character vector, TRUE (compute from p), or numeric (treated as p-values). |
weight_digits |
Number of decimal places to which the weights of a
matrix input are rounded before plotting, so edges that round to zero are
removed. Default 2. |
threshold |
Minimum absolute weight to display. |
minimum |
Alias for threshold (qgraph compatibility). Uses max of threshold and minimum. |
maximum |
Maximum weight for scaling. NULL for auto. |
positive_color |
Deprecated. Use |
negative_color |
Deprecated. Use |
edge_duplicates |
How to handle duplicate edges in undirected networks. NULL (default) = stop with error listing duplicates. Options: "sum", "mean", "first", "max", "min", or a custom aggregation function. |
title |
Plot title. |
title_size |
Title font size. |
margins |
Margins as c(bottom, left, top, right). |
background |
Background color. |
rescale |
Logical: rescale layout to -1 to 1 range? |
layout_scale |
Scale factor for layout. >1 expands (spreads nodes apart), <1 contracts (brings nodes closer). Use "auto" to automatically scale based on node count (compact for small networks, expanded for large). Default 1. |
layout_margin |
Margin around the layout as fraction of range. Default 0.15. Set to 0 for no extra margin (tighter fit). Affects white space around nodes. |
aspect |
Logical: maintain aspect ratio? |
use_pch |
Logical: use points() for simple circles (faster). Default FALSE. |
usePCH |
Deprecated. Use |
scaling |
Scaling mode: "default" for qgraph-matched scaling where node_size=6 looks similar to qgraph vsize=6, or "legacy" to preserve pre-v2.0 behavior. |
align_panels |
Logical. If |
legend |
Logical: show legend? |
legend_position |
Position: "topright", "topleft", "bottomright", "bottomleft". |
legend_size |
Legend text size. |
legend_edge_colors |
Logical: show positive/negative edge colors in legend? |
legend_node_sizes |
Logical: show node size scale in legend? |
groups |
Group assignments for node coloring/legend. |
node_names |
Alternative names for legend (separate from labels). |
tna_styling |
Logical or NULL. If |
psych_styling |
Logical or NULL. Undirected counterpart of |
predictability |
Logical or NULL. Draws a per-node predictability ring
(a donut fill) from a |
i |
Group index or name when x is a group_tna object. If NULL (default), plots all groups in a grid. If specified (e.g., i = 1 or i = "Treatment"), plots only that group. |
filetype |
Output format: "default" (screen), "png", "pdf", "svg", "jpeg", "tiff". |
filename |
Output filename (without extension). |
width |
Output width in inches. |
height |
Output height in inches. |
res |
Resolution in DPI for raster outputs (PNG, JPEG, TIFF). Default 600. |
splot.net_bootstrap() plots a net_bootstrap object from the
Nestimate package. It shows the original network, whose weights are taken
from $original$weights, with the edges styled by bootstrap
significance.
splot.tna_communities() plots the tna model stored in
attr(x, "tna") by tna::communities(), with nodes colored by
community. The walktrap assignment is used when present, and the
first algorithm column of x$assignments otherwise.
splot.cograph_communities() plots the network stored in
attr(x, "network") by detect_communities(), with
nodes colored by community.
splot.net_mlvar() plots one or all of the temporal, contemporaneous
and between-subjects networks of a net_mlvar object from
Nestimate::build_mlvar().
splot.netobject() plots a netobject from Nestimate. Networks
estimated by a transition-type method ("relative",
"frequency", "attention", "co_occurrence",
"wtna", "wtna_cooccurrence", "entropy") get
tna_styling = TRUE, and other methods, such as correlation and
partial correlation networks, get psych_styling = TRUE. When the
method is not recorded, directed networks get the TNA styling. Arguments
supplied by the caller override these defaults.
splot.boot_glasso() plots the partial-correlation network of a
boot_glasso object from Nestimate, with the bootstrap inclusion
probability of each edge mapped to its opacity.
splot.wtna_mixed() plots a wtna_mixed object from
Nestimate::wtna(..., method = "both"), either as one overlaid
network or as two panels.
splot.net_permutation() plots the edge differences of a
net_permutation object from Nestimate, with significant
differences highlighted. The direction of the network is taken from
x$x$directed.
Edge curving is controlled by two interacting arguments:
curvesMode for automatic curving. FALSE = all straight,
TRUE (default) = curve only reciprocal edge pairs as an ellipse,
"force" = curve all edges inward toward network center.
curvatureManual curvature amount (0-1 typical). Sets the magnitude of curves. Default 0 uses automatic 0.175 for curved edges. Positive values curve edges; the direction is automatically determined.
For reciprocal edges (A->B and B->A both exist), the edges curve
in opposite directions to form a visual ellipse, making bidirectional
relationships clear.
Controls how edge weights are mapped to visual widths:
"linear" (default)Width proportional to weight. Best when weights are similar in magnitude.
"log"Logarithmic scaling. Best when weights span multiple orders of magnitude (e.g., 0.01 to 100).
"sqrt"Square root scaling. Moderate compression, good for moderately skewed distributions.
"rank"Rank-based scaling. Ignores actual values; uses relative ordering. All edges get equal visual spacing regardless of weight distribution.
Three ways to show additional data on nodes:
donut_fill)Single ring showing a proportion (0-1).
Ideal for completion rates, probabilities, or any single metric per node.
Use donut_color for fill color and donut_bg_color for unfilled portion.
pie_values)Multiple colored segments showing category
breakdown. Ideal for composition data. Values are normalized to sum to 1.
Use pie_colors for segment colors.
donut2_values)Two concentric rings for comparing
two metrics per node. Outer ring uses donut_fill/donut_color,
inner ring uses donut2_values/donut2_colors.
Confidence interval underlays draw a wider, semi-transparent edge behind the main edge to visualize uncertainty:
edge_ciVector of CI widths (0-1 scale). Larger = more uncertainty.
edge_ci_scaleMultiplier for underlay width relative to main edge. Default 2 means underlay is twice as wide as main edge at CI=1.
edge_ci_alphaTransparency of underlay (0-1). Default 0.15.
edge_ci_styleLine type: 1=solid, 2=dashed (default), 3=dotted.
For statistical output, use templates to format complex labels:
edge_label_templateTemplate string with placeholders:
{est} for estimate/weight, {low}/{up} for CI bounds,
{range} for formatted range, {p} for p-value,
{p_diff} for the probability of the difference (Bayesian
comparisons), {stars} for significance stars.
edge_label_stylePreset styles: "estimate" (weight only),
"full" (estimate + CI), "range" (CI only), "stars" (significance).
Packages that create cograph_network-compatible objects can attach a
small plotting contract at x$meta$splot. This lets producer packages
such as Nestimate, lagdynamics, or other modeling packages describe their
preferred cograph rendering without adding a new cograph-side class branch for
every object type.
The contract is optional. Objects without meta$splot follow the normal
splot() path and all existing class-specific dispatch remains in place.
When present, the supported fields are:
rendererCharacter scalar naming the cograph renderer to use.
"network" (also "splot", "default", or "base")
means the object follows the normal splot() path, including any
class-specific method, with the metadata defaults applied. Other values are resolved through a
cograph-maintained whitelist of existing renderers, for example
"difference", "bootstrap", "permutation",
"stability", "mlvar", "netobject",
"netobject_group", "netobject_ml", "boot_glasso",
and "wtna_mixed". Arbitrary function names are never evaluated.
weightOptional character scalar naming the default edge
weight to render. If it names an edge column, that column is copied to
edges$weight for the plot (the producer's edge set is kept, and
the weights matrix is rebuilt to match). If it names a matrix
stored on the object, that matrix becomes the rendered network: it is
copied to weights and the drawn edge set is rebuilt from its
nonzero cells (aligned to the object's node order via dimnames when
present). This is useful when the analytical object stores several edge
quantities (for example counts, probabilities, residuals, effects) but
has one preferred plot view. When the name matches both an edge column
and a stored matrix, the matrix form wins.
defaultsNamed list of splot() or renderer arguments.
These are defaults only: any argument explicitly supplied by the user
wins. Defaults can include regular splot() arguments such as
layout, node_fill, edge_labels,
weight_digits, or renderer-specific arguments such as
display for bootstrap renderers.
The precedence rule is always:
user arguments > x$meta$splot$defaults > cograph defaults
Example producer-side metadata:
x$meta$splot <- list(
renderer = "network",
weight = "adj_res",
defaults = list(
node_fill = "white",
edge_labels = TRUE,
weight_digits = 1
)
)
splot() returns the plotted cograph_network object
invisibly. splot.net_bootstrap(), splot.netobject(),
splot.boot_glasso(), splot.tna_communities() and
splot.cograph_communities() return the cograph_network
built by splot(), and splot.net_permutation() returns it or
NULL when there is no edge to plot. splot.net_mlvar() and
splot.wtna_mixed() return x. All are called for the side
effect of plotting.
soplot for grid graphics rendering (alternative engine),
cograph for creating network objects,
sn_nodes for node customization,
sn_edges for edge customization,
sn_layout for layout algorithms,
sn_theme for visual themes,
from_qgraph and from_tna for converting external objects
splot(regulation_net)splot(regulation_net)
An edge list of observed interactions between 34 students during collaborative learning sessions. Each row represents one observed interaction between two students. The same pair may appear multiple times, reflecting repeated interactions.
student_interactionsstudent_interactions
A data frame with 389 rows and 2 columns:
Character. Anonymized two-letter student code (e.g., "Ac", "Bd")
Character. Anonymized two-letter student code (e.g., "Ce", "Df")
The dataset includes self-loops (34 rows where from == to).
These can be removed with subset(student_interactions, from != to).
The 389 rows contain 226 distinct ordered pairs. Because interactions
repeat, the edge list forms a multigraph when loaded into igraph with
igraph::graph_from_data_frame().
A data frame with 389 rows and 2 columns:
Character. Anonymized two-letter student code.
Character. Anonymized two-letter student code.
Anonymized collaborative learning interaction data.
as_cograph(student_interactions)as_cograph(student_interactions)
Calls motifs(x, named_nodes = TRUE, ...). The result has one row per
node triple and MAN type. At individual level, observed counts the
units in which the triple has that type, so one triple can occupy several
rows. One MAN type can also appear in many rows, each with its own
z and p. Per-triple significance is plotted by
plot(., type = "significance") and plot(., type = "triads").
The per-type plots ("types", "patterns") omit significance
for instance results.
subgraphs(...)subgraphs(...)
... |
Arguments forwarded to |
The "triads" diagram shows a canonical representative of the MAN
isomorphism class of each row. The labels name the participating nodes.
Their positions in the diagram do not encode the observed source and sink
roles of the nodes.
A cograph_motif_result object with named_nodes = TRUE,
described in motifs(), or NULL with a message when no triple
passes the filters. Its results table has the columns triad,
node1, node2, node3, type and
observed, and with significance = TRUE also
expected, z, p and sig. Its
type_summary counts the node triples of each MAN type.
Other motifs:
extract_motifs(),
extract_triads(),
get_edge_list(),
motif_census(),
motifs(),
triad_census()
subgraphs(regulation_net, significance = FALSE, min_count = 1)subgraphs(regulation_net, significance = FALSE, min_count = 1)
Builds a Multi-Cluster Multi-Level (MCML) model from raw transition data
(edge lists or sequences) by recoding node labels to cluster labels and
counting the observed transitions. The macro network is then the Markov
chain over cluster states. Weight matrices are passed to
csum, which aggregates them.
summarize_clusters( x, clusters = NULL, method = c("sum", "mean", "median", "max", "min", "density", "geomean"), type = c("tna", "frequency", "cooccurrence", "semi_markov", "raw"), directed = TRUE, compute_within = TRUE )summarize_clusters( x, clusters = NULL, method = c("sum", "mean", "median", "max", "min", "density", "geomean"), type = c("tna", "frequency", "cooccurrence", "semi_markov", "raw"), directed = TRUE, compute_within = TRUE )
x |
Input data. Accepts multiple formats:
|
clusters |
Cluster/group assignments. Accepts:
|
method |
Aggregation method for combining edge weights: "sum", "mean", "median", "max", "min", "density", "geomean". Default "sum". |
type |
Post-processing: "tna" (row-normalize), "frequency" or "raw" (no normalization), "cooccurrence" (symmetrize), or "semi_markov" (row-normalize, identical to "tna"). Default "tna". |
directed |
Logical. Default |
compute_within |
Logical. Compute within-cluster matrices? Default TRUE. |
Usually an mcml object. Existing mcml or
cluster_summary inputs are returned unchanged. Transition-data
results include meta$source = "transitions" and are compatible with
plot_mcml, as_tna, and splot.
csum for matrix-based aggregation,
as_tna to convert to tna objects,
plot_mcml for visualization
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) summarize_clusters(regulation_net, clusters = clusters, method = "mean")clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) summarize_clusters(regulation_net, clusters = clusters, method = "mean")
Creates a summary network where each cluster becomes a single node. Edge weights are aggregated from the original network using the specified method, without normalization.
summarize_network( x, cluster_list = NULL, method = c("sum", "mean", "max", "min", "median", "density", "geomean"), directed = TRUE ) cnet( x, cluster_list = NULL, method = c("sum", "mean", "max", "min", "median", "density", "geomean"), directed = TRUE )summarize_network( x, cluster_list = NULL, method = c("sum", "mean", "max", "min", "median", "density", "geomean"), directed = TRUE ) cnet( x, cluster_list = NULL, method = c("sum", "mean", "max", "min", "median", "density", "geomean"), directed = TRUE )
x |
A weight matrix, tna object, or cograph_network. |
cluster_list |
Cluster specification:
|
method |
Aggregation method for edge weights: "sum", "mean", "max", "min", "median", "density", "geomean". Default "sum". |
directed |
Logical. Whether the summary network is directed. Default TRUE. |
A cograph_network object with one node per cluster, labelled by
cluster name. The edge weights are the aggregated between-cluster
weights, and the diagonal holds the aggregated within-cluster weights.
The node table has a size column with the number of original
nodes in each cluster.
See summarize_network.
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) summarize_network(regulation_net, cluster_list = clusters)clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) summarize_network(regulation_net, cluster_list = clusters)
Builds the supra-adjacency matrix of a multilayer network. The diagonal blocks hold the intra-layer adjacencies and the off-diagonal blocks the inter-layer coupling.
supra_adjacency( layers, omega = 1, coupling = c("diagonal", "full", "custom"), interlayer_matrices = NULL ) supra( layers, omega = 1, coupling = c("diagonal", "full", "custom"), interlayer_matrices = NULL )supra_adjacency( layers, omega = 1, coupling = c("diagonal", "full", "custom"), interlayer_matrices = NULL ) supra( layers, omega = 1, coupling = c("diagonal", "full", "custom"), interlayer_matrices = NULL )
layers |
List of adjacency matrices (same dimensions) |
omega |
Inter-layer coupling coefficient, a scalar or an L x L matrix.
Default 1. For a matrix, entry |
coupling |
Coupling type. |
interlayer_matrices |
For
The block of layers b and a is the transpose of the block of a and b.
A pair with no matching entry receives the diagonal coupling
|
A supra-adjacency matrix of dimension (NL) x (NL) with class
c("supra_adjacency", "matrix"). Diagonal N x N blocks hold the
intra-layer adjacencies and off-diagonal blocks the inter-layer coupling.
The attributes "n_nodes", "n_layers", "node_names",
"layer_names", "omega" and "coupling" record the
construction and are read back by supra_layer() and
supra_interlayer().
layers <- list(forward = regulation_net, backward = t(regulation_net)) supra_adjacency(layers, omega = 0.5)layers <- list(forward = regulation_net, backward = t(regulation_net)) supra_adjacency(layers, omega = 0.5)
Extract Inter-Layer Block
supra_interlayer(x, from, to) extract_interlayer(x, from, to)supra_interlayer(x, from, to) extract_interlayer(x, from, to)
x |
Supra-adjacency matrix from |
from |
Integer index of the source layer |
to |
Integer index of the target layer |
The N x N inter-layer block, with the supra-matrix labels
("<layer>_<node>") as dimnames. An index outside 1:L
raises an error.
layers <- list(forward = regulation_net, backward = t(regulation_net)) supra <- supra_adjacency(layers, omega = 0.5) supra_interlayer(supra, from = 1, to = 2)layers <- list(forward = regulation_net, backward = t(regulation_net)) supra <- supra_adjacency(layers, omega = 0.5) supra_interlayer(supra, from = 1, to = 2)
Extract Layer from Supra-Adjacency Matrix
supra_layer(x, layer) extract_layer(x, layer)supra_layer(x, layer) extract_layer(x, layer)
x |
Supra-adjacency matrix from |
layer |
Integer index of the layer to extract |
The N x N intra-layer adjacency matrix, with the node names as
dimnames. An index outside 1:L raises an error.
layers <- list(forward = regulation_net, backward = t(regulation_net)) supra <- supra_adjacency(layers, omega = 0.5) supra_layer(supra, layer = 2)layers <- list(forward = regulation_net, backward = t(regulation_net)) supra <- supra_adjacency(layers, omega = 0.5) supra_layer(supra, layer = 2)
Combines each pair of opposite arcs into one undirected edge. The result is an undirected network. Self-loops are kept unchanged.
symmetrize( x, method = c("max", "min", "mean", "sum", "mutual", "upper", "lower"), keep_format = FALSE, directed = NULL )symmetrize( x, method = c("max", "min", "mean", "sum", "mutual", "upper", "lower"), keep_format = FALSE, directed = NULL )
x |
Network input. |
method |
How to combine
|
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. Directedness to read the input with; the result is always undirected. |
"max", "min", "mean" and "sum" combine two
values only where both arcs exist. An unreciprocated edge keeps its own
weight. In a signed network an unreciprocated negative edge is therefore
kept. "mutual" keeps only reciprocated edges.
An undirected cograph_network, or the input format when
keep_format = TRUE. The weight matrix satisfies
isSymmetric(). Zero is how this representation stores "no edge", so
any pair whose combined weight is exactly zero disappears: every
unreciprocated arc under method = "mutual", and a cancelling pair
under "sum". A cograph_edges_dropped warning says how many.
Butts, C. T. (2008). Social network analysis with sna. Journal of Statistical Software, 24(6), 1–51.
to_undirected, normalize_weights
symmetrize(regulation_net, method = "mean")symmetrize(regulation_net, method = "mean")
A theme is a CographTheme object that sets the background, node,
edge and label colors of a plot. Themes are stored in a registry and
selected by name through the theme argument of splot,
soplot and sn_theme. The functions
theme_cograph_*() return the built-in themes:
theme_cograph_classic()Blue nodes and gray edges
("classic").
theme_cograph_colorblind()Colors distinguishable under color
vision deficiency ("colorblind").
theme_cograph_gray()Black and white for print
("gray", also "grey").
theme_cograph_dark()Dark background for presentations
("dark").
theme_cograph_minimal()Thin borders and few colors
("minimal").
theme_cograph_viridis()The viridis palette
("viridis").
theme_cograph_nature()Earth tones ("nature").
register_theme() adds a theme under a new name, get_theme()
returns a registered theme, and list_themes() returns the names of
all registered themes.
register_theme(name, theme) get_theme(name) list_themes() theme_cograph_classic() theme_cograph_colorblind() theme_cograph_gray() theme_cograph_dark() theme_cograph_minimal() theme_cograph_viridis() theme_cograph_nature()register_theme(name, theme) get_theme(name) list_themes() theme_cograph_classic() theme_cograph_colorblind() theme_cograph_gray() theme_cograph_dark() theme_cograph_minimal() theme_cograph_viridis() theme_cograph_nature()
name |
Character. The name of the theme. |
theme |
A |
The theme_cograph_*() functions return a CographTheme
object. register_theme() returns NULL invisibly.
get_theme() returns the theme, or NULL if no theme has that
name. list_themes() returns a character vector of theme names.
splot(regulation_net, theme = "dark")splot(regulation_net, theme = "dark")
Keeps the edges that satisfy every criterion supplied. The operation
corresponds to qgraph's minimum argument and to
tna::prune(). The result is a network that can be analysed and
plotted.
threshold_edges( x, minimum = NULL, maximum = NULL, proportion = NULL, density = NULL, top = NULL, absolute = TRUE, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )threshold_edges( x, minimum = NULL, maximum = NULL, proportion = NULL, density = NULL, top = NULL, absolute = TRUE, keep_isolates = TRUE, keep_format = FALSE, directed = NULL )
x |
Network input: cograph_network, matrix, igraph, network, tna, or an edge-list data frame. |
minimum |
Numeric. Keep edges whose weight is at least this value. |
maximum |
Numeric. Keep edges whose weight is at most this value. |
proportion |
Numeric in (0, 1]. Keep this fraction of the edges, the strongest first. |
density |
Numeric in (0, 1]. Keep as many of the strongest edges as gives this density (edges as a fraction of the possible edges). |
top |
Non-negative integer. Keep this many edges, the strongest first.
|
absolute |
Logical. Compare |
keep_isolates |
Logical. Keep nodes that end up with no edges? Default
TRUE. Set FALSE, or call |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
Several criteria are combined with AND. For example,
threshold_edges(x, minimum = 0.2, top = 20) keeps the twenty
strongest edges among those of weight at least 0.2. When proportion,
density and top are combined, the smallest of the implied
edge counts is used.
Ties at the cut point are all kept, so top = 10 can return more than
ten edges when the tenth and eleventh weights are equal. The result
therefore does not depend on the order in which the edges are stored.
A cograph_network with the surviving edges, or the input
format when keep_format = TRUE. Every node is kept unless
keep_isolates = FALSE; nodes the threshold stranded are reported in
a cograph_isolates_created warning. A non-finite minimum or
maximum, a proportion or density outside (0, 1],
and a negative or fractional top raise a
cograph_bad_selection error.
Epskamp, S., Cramer, A. O. J., Waldorp, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48(4), 1–18.
binarize, filter_edges,
disparity_filter, remove_isolates
threshold_edges(regulation_net, minimum = 0.1)threshold_edges(regulation_net, minimum = 0.1)
Converts a network to an edge list data frame with columns for source, target, and weight.
to_data_frame(x, directed = NULL) to_df(x, directed = NULL)to_data_frame(x, directed = NULL) to_df(x, directed = NULL)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
A base data.frame with one row per edge and exactly three
columns:
from: Source node name/label
to: Target node name/label
weight: Edge weight
Further edge columns, such as session or time from
temporal edge lists, are dropped. get_edges returns the
full edge table. An undirected network contributes one row per unordered
pair.
to_data_frame(regulation_net)to_data_frame(regulation_net)
Convert an Undirected Network to Directed
to_directed( x, mode = c("mutual", "arbitrary"), keep_format = FALSE, directed = NULL )to_directed( x, mode = c("mutual", "arbitrary"), keep_format = FALSE, directed = NULL )
x |
Network input. |
mode |
|
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
A directed cograph_network, or the input format when
keep_format = TRUE.
to_directed(to_undirected(regulation_net))to_directed(to_undirected(regulation_net))
Converts various network representations to an igraph object. Supports matrices, edge-list data frames, igraph objects, network objects, cograph_network, and tna objects.
to_igraph(x, directed = NULL)to_igraph(x, directed = NULL)
x |
Network input. Can be:
|
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
An igraph object.
to_igraph(regulation_net)to_igraph(regulation_net)
Converts any supported network format to an adjacency matrix.
to_matrix(x, directed = NULL)to_matrix(x, directed = NULL)
x |
Network input: matrix, cograph_network, igraph, network, tna, etc. |
directed |
Logical or NULL. If NULL (default), auto-detect from input. |
A square numeric adjacency matrix, preserving row/column names when available.
to_igraph, to_df, as_cograph,
to_network
to_matrix(student_interactions)to_matrix(student_interactions)
Converts any supported network format to a statnet network object.
to_network(x, directed = NULL)to_network(x, directed = NULL)
x |
Network input: matrix, cograph_network, igraph, tna, etc. |
directed |
Logical or NULL. If NULL (default), auto-detect from input. |
A network object from the network package.
to_igraph, to_matrix, to_df,
as_cograph
to_network(regulation_net)to_network(regulation_net)
Collapses each pair of opposite arcs into one undirected edge, as
igraph::as_undirected() and tidygraph's to_undirected() do.
to_undirected( x, method = c("max", "sum", "mean", "min", "mutual"), keep_format = FALSE, directed = NULL )to_undirected( x, method = c("max", "sum", "mean", "min", "mutual"), keep_format = FALSE, directed = NULL )
x |
Network input. |
method |
How to combine |
keep_format |
Logical. If TRUE, a matrix, igraph, statnet network or
tna input is returned in its own format. An edge-list data frame or a
qgraph object is returned as a |
directed |
Logical or NULL. Directedness used to read the input. NULL (default) detects it from the input. |
An undirected cograph_network, or the input format when
keep_format = TRUE. Self-loops keep their weight. A weight of zero
means no edge, so a pair whose combined weight is exactly zero is dropped.
Under method = "mutual" this applies to every unreciprocated arc,
and under "sum" to a pair of opposite weights that cancel. Dropped
edges raise a cograph_edges_dropped warning.
to_undirected(regulation_net, method = "sum")to_undirected(regulation_net, method = "sum")
Counts the 16 types of triads in a directed network using MAN notation. Edge weights are ignored.
triad_census(x)triad_census(x)
x |
A matrix, igraph object, or cograph_network. |
The triad census is defined only for directed networks. Matrix input is read as directed. An undirected igraph or cograph_network input raises an error.
A MAN code gives the number of mutual (reciprocated) dyads, the number of asymmetric dyads and the number of null (absent) dyads of a triad, followed by a letter that separates types with the same counts. The 16 triad types, in the order of the result, are 003, 012, 102, 021D, 021U, 021C, 111D, 111U, 030T, 030C, 201, 120D, 120U, 120C, 210 and 300.
A named numeric vector of length 16 giving the count of each MAN triad type, in the order listed under Details.
motifs() for the unified API, motif_census()
Other motifs:
extract_motifs(),
extract_triads(),
get_edge_list(),
motif_census(),
motifs(),
subgraphs()
cograph::triad_census(regulation_net)cograph::triad_census(regulation_net)
Computes the trophic incoherence parameter , which measures how
vertically ordered a directed network is (Johnson et al. 2014). For each edge
, the trophic difference is where
is the trophic level of node . The trophic incoherence
parameter is the (population) standard deviation of these differences:
trophic_incoherence(x, cannibalism = TRUE)trophic_incoherence(x, cannibalism = TRUE)
x |
Directed network input. |
cannibalism |
Logical. If |
Values near 0 indicate a coherent network, in which every edge rises by
about one level. High values indicate many level-skipping or downward
edges. Johnson et al. (2014) reported that food webs with low are
more stable.
Trophic levels are computed on the binary adjacency matrix, so edge weights are ignored. The levels are defined only for a directed network in which every node can be reached from a basal node (a node with no incoming edges).
Numeric scalar: the trophic incoherence parameter. NA when
the network has no edges or when some node cannot be reached from a basal
node. An undirected network returns NA with a warning.
Johnson, S., Dominguez-Garcia, V., Donetti, L., & Munoz, M. A. (2014). Trophic coherence determines food-web stability. PNAS, 111(50), 17923-17928.
centrality (the trophic_level measure) for
the per-node levels used in the incoherence calculation.
strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) trophic_incoherence(strong)strong <- filter_edges(regulation_net, weight > 0.3, keep_isolates = FALSE) trophic_incoherence(strong)
Compares the macro weights of csum with the result of
contracting the clusters in igraph (igraph::contract() followed by
igraph::simplify()).
verify_with_igraph(x, clusters, method = "sum", type = "raw") verify_igraph(x, clusters, method = "sum", type = "raw")verify_with_igraph(x, clusters, method = "sum", type = "raw") verify_igraph(x, clusters, method = "sum", type = "raw")
x |
Adjacency matrix |
clusters |
Cluster specification (see |
method |
Aggregation method. Default "sum". |
type |
Normalization type passed to |
A list with components our_result (cograph's macro weight
matrix), igraph_result (igraph's
contract() + simplify() matrix, diagonal set to zero),
matches (logical, whether the off-diagonal cells agree to within
1e-10) and difference (the
all.equal() report when they do not, otherwise NULL). Returns
NULL with a message if igraph is not installed.
clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) verify_with_igraph(regulation_net, clusters = clusters)clusters <- list(C1 = c("Explore", "Reflect", "Discuss"), C2 = c("Plan", "Create", "Share"), C3 = c("Monitor", "Adapt", "Synthesize", "Evaluate")) verify_with_igraph(regulation_net, clusters = clusters)
Computes the vulnerability of each node, defined as the relative drop in global efficiency when that node is removed from the network.
vulnerability( x, directed = NULL, normalized = TRUE, weighted = FALSE, invert_weights = TRUE, alpha = 1, digits = NULL, ... )vulnerability( x, directed = NULL, normalized = TRUE, weighted = FALSE, invert_weights = TRUE, alpha = 1, digits = NULL, ... )
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
normalized |
Logical. If TRUE (default), return the proportional drop. If FALSE, return the raw efficiency difference. |
weighted |
Logical. If TRUE, edge weights are used when computing shortest paths (Dijkstra). If FALSE (default), all edges have unit length. |
invert_weights |
Logical. If TRUE (default) and weights are present,
weights are converted to distances |
alpha |
Weight-to-distance exponent (default 1). Used only when
|
digits |
Integer or NULL. Round scores to this many decimal places. Default NULL (no rounding). |
... |
Passed to |
where is the global efficiency of the full network and
is the global efficiency after removing node i
and all its edges.
Global efficiency is defined as:
In a directed network the distances follow the edge directions.
is computed on the reduced graph with the
original denominator, so vulnerability is never negative
(Latora & Marchiori 2007).
Nodes with high vulnerability are critical to the communication efficiency of the network, because their removal causes the greatest drop in global efficiency.
All-pairs shortest paths are computed once for the full graph and once per removed node. A warning is issued for networks with more than 500 nodes.
A data frame of class "cograph_vulnerability" with one row per
node and columns:
Node labels.
Vulnerability score.
Rows are sorted by decreasing vulnerability.
The original input network ("network") and the normalization mode
("normalized") are stored as attributes. Scores are NA for a
network with at most one node, and all zero when the full network already
has zero global efficiency.
Printing the result shows the normalization mode and the node table.
plot() on the result is documented in plot-results.
Latora, V. & Marchiori, M. (2007). A measure of centrality based on network efficiency. New Journal of Physics, 9(6), 188. doi:10.1088/1367-2630/9/6/188
network_global_efficiency, robustness,
centrality
vulnerability(regulation_net)vulnerability(regulation_net)