Skip to contents

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).

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.

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

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, k.values = seq.int(3, 10),
    with.isize.pruning = TRUE)
#> 	Running single-threaded.
#> Processing k values from 3 to 10 for 200 vertices
#> Requested parallel.mode: auto
#> Parallel mode: serial
#> Starting graph processing
#> [compute_knn] running...
[compute_knn] 0.001s
#> [graph_build/geometric_prune/isize_prune] running...
[graph_build/geometric_prune/isize_prune] 0.252s
#> Graph processing completed (0.253)
#> [compute_knn] 0.001s
#> [graph_build] 0.005s
#> [geometric_prune] 0.227s
#> [isize_prune] 0.020s
#> Creating return list objects ... DONE (0.001)
#> Total elapsed time (0.254)

# Summarize the geometrically pruned graphs
summary(iknn.res)
#> Summary of iknn_graphs object
#> ----------------------------
#> Number of vertices: 200 
#> k range: 3 to 10 
#> Max path-edge ratio deviation threshold: 0.1 
#> Path-edge ratio percentile: 0.5 
#> Graph type: geometrically pruned 
#> 
#>  idx  k n_ccomp edges mean_degree min_degree max_degree sparsity
#>    1  3       1   549        5.49          3         16  0.97241
#>    2  4       1   826        8.26          4         25  0.95849
#>    3  5       1  1127       11.27          5         32  0.94337
#>    4  6       1  1477       14.77          5         47  0.92578
#>    5  7       1  1872       18.72          6         55  0.90593
#>    6  8       1  2269       22.69          7         65  0.88598
#>    7  9       1  2665       26.65          8         75  0.86608
#>    8 10       1  3089       30.89          9         84  0.84477

# Summarize the intersection-size pruned graphs
summary(iknn.res, use.isize.pruned = TRUE)
#> Summary of iknn_graphs object
#> ----------------------------
#> Number of vertices: 200 
#> k range: 3 to 10 
#> Max path-edge ratio deviation threshold: 0.1 
#> Path-edge ratio percentile: 0.5 
#> Graph type: intersection-size pruned 
#> 
#>  idx  k n_ccomp edges mean_degree min_degree max_degree sparsity
#>    1  3       1   713        7.13          2         14  0.96417
#>    2  4       1   836        8.36          3         19  0.95799
#>    3  5       1   839        8.39          3         19  0.95784
#>    4  6       1   776        7.76          3         18  0.96101
#>    5  7       1   753        7.53          3         16  0.96216
#>    6  8       1   631        6.31          2         16  0.96829
#>    7  9       1   593        5.93          2         14  0.97020
#>    8 10       1   571        5.71          2         12  0.97131