Summarize spacing between igraph nodes given a layout

summarize_node_spacing(
  g,
  layout = NULL,
  nodes = NULL,
  node_groups = NULL,
  each_group = FALSE,
  scaled = FALSE,
  dist_type = c("nearest_node", "all_nodes"),
  verbose = FALSE,
  ...
)

Arguments

g

igraph object

layout

passed together with g to get_igraph_layout()

nodes

character with optional node names, or integer index of nodes in g to define a subset of nodes for which statistics are calculated. Useful to focus on a specific subset of nodes, for example one or two Cnet nodesets.

node_groups

list implemented to use nodesets. The intent is to define node groups, then calculate statistics of node spacing across and within node groups.

each_group

logical indicating whether to include each node group when node_groups is also supplied.

scaled

logical indicating whether to report spacing relative to the max x-axis/y-axis range, similar to the min_percent and percent_spacing argument units in other node spacing functions.

dist_type

character string indicating the type of distance to summarize:

  • "nearest_node" only uses the nearest node to each node, which is helpful when trying to ensure all nodes have a minimum distance from other nodes.

  • "all_nodes" uses all node distances from each node, which is helpful when assessing the overall spacing between nodes.

verbose

logical indicating whether to print verbose output.

...

additional arguments are passed to internal functions.

Value

data.frame with summary information about node distances for connected nodes (only where edges connect any two nodes), and unconnected nodes (only where two nodes are not connected by an edge). When node_groups is defined, the summary also includes each individual node group.

Details

This function is a simple wrapper to calculate typical distances between nodes in a given network layout. It is experimental, and intended to provide helpful information when determining an appropriate value for percent_spacing to use for example with apply_nodeset_spacing(). The optimal value depends upon the number of nodes overall, also the number of nodes in each nodeset, and the relative position of each nodeset in layout coordinates.

The node_groups argument is intended to provide summary data for each node group (for example Cnet nodesets) so that individual node groups can be adjusted accordingly.