summary.iknn_graphs: Summarize an iknn_graphs Object

View source: R/iknn_graphs.R

summary.iknn_graphsR Documentation

Summarize an iknn_graphs Object

Description

Provides a detailed summary of an iknn_graphs object created by the create.iknn.graphs() function. The summary includes statistics for each intersection kNN graph in the sequence, displaying information about the connectivity and structure of the graphs for different k values.

Usage

## S3 method for class 'iknn_graphs'
summary(object, use.isize.pruned = FALSE, ...)

Arguments

object

An object of class 'iknn_graphs', typically the output of create.iknn.graphs().

use.isize.pruned

Logical. If TRUE, computes and displays statistics for the intersection-size pruned graphs (isize_pruned_graphs). If FALSE (default), computes statistics for the geometrically pruned graphs (geom_pruned_graphs).

...

Additional arguments passed to or from other methods (not currently used).

Details

The summary function extracts and presents key statistics about the structure of each intersection kNN graph in the iknn_graphs object. All graphs share the same number of vertices (equal to the number of rows in the input data matrix), but they differ in the number of edges due to varying k values and the pruning methods applied during graph creation.

The function displays general information about the graph sequence, including the number of vertices, the range of k values, and the pruning parameters used. It then presents a tabular summary of statistics for each individual graph, showing how the graph structure changes as k increases.

For each intersection kNN graph, the following metrics are calculated:

  • Number of edges: Total number of connections in the graph

  • Mean degree: Average number of connections per vertex

  • Min/Max degree: Range of vertex connectivity

  • Density: Proportion of potential connections that are actually present

  • Sparsity: 1 - density, measuring the proportion of missing connections

Value

Invisibly returns a data frame containing statistics for each graph. The data frame has the following columns:

idx

The index of the given k value

k

The k value for the intersection kNN graph

n_ccomp

Number of connected components of the graph

edges

Number of edges in the graph

mean_degree

Average number of connections per vertex

min_degree

Minimum vertex degree (least connected vertex)

max_degree

Maximum vertex degree (most connected vertex)

sparsity

Graph sparsity, calculated as 1 - density. It measures how many (proportion) potential connections are missing.

See Also

create.iknn.graphs for creating intersection kNN graphs.

Examples

# Create sample data
set.seed(123)
x <- matrix(rnorm(1000), ncol = 5)

# Generate intersection kNN graphs
iknn.res <- create.iknn.graphs(
  x,
  kmin = 3,
  kmax = 10,
  n.cores = 1,
  with.isize.pruning = TRUE
)

# Summarize the geometrically pruned graphs
summary(iknn.res)

# Summarize the intersection-size pruned graphs
summary(iknn.res, use.isize.pruned = TRUE)


dgraphs documentation built on Aug. 21, 2026, 1:08 a.m.