netkit

netkit is an R toolkit for analyzing and visualizing networks: global topology and per-node centrality, hubs and bottlenecks, community structure and connectivity roles, signal diffusion from seed nodes, and robustness under progressive node removal. It is built on igraph and returns ggplot2 objects rather than drawing them, so every diagnostic can be composed, themed, and dropped straight into a figure.

It is domain-agnostic — anything you can express as nodes and edges. Several of the worked examples lean on molecular interaction networks, where seeding a diffusion with a gene list and asking which other genes light up is a routine question, but nothing in the package assumes biology.

A 120-node network with five communities, drawn by find_modules(); node size maps to degree.

What it does

Analysis functions return a named list with a consistent vocabulary — plot, result, graph, method — which is what lets them chain:

g <- node_metrics(g)$graph        # eleven metrics as vertex attributes
g <- find_hubs(g)$graph           # plus is_hub
g <- find_modules(g)$graph        # plus module
robustness_analysis(g, removal_strategy = "pagerank")

At the console those results print as a summary — what was computed, the head of the table, and the shape of everything else — rather than as a dump of the whole graph. The objects are still plain lists; unclass() restores the default output.

Edge weights

Every function that can use edge weights takes weights and a weight_type declaring whether the values are a strength (confidence scores, correlations — larger means more tightly connected) or a distance (costs, dissimilarities — larger means further apart). netkit ignores edge weights unless asked, and warns when a graph carries a weight attribute it is ignoring.

That is deliberate, and differs from plain igraph, which reads the attribute automatically while giving it opposite meanings in different functions — a cost in betweenness() and distances(), a strength in cluster_louvain(). See vignette("weighted-networks").

Installation

Install the development version from GitHub:

# install.packages("remotes")
# remotes::install_github("agallinat/netkit")
install.packages("netkit", repos = c('https://agallinat.r-universe.dev', 'https://cloud.r-project.org'))

Documentation

Full usage examples and tutorial are available in the package vignettes:

browseVignettes("netkit")

Or online:

Citation

If netkit is useful in work you publish, please cite it:

citation("netkit")

Contributing

Contributions are welcome! If you’d like to report a bug, suggest a feature, or improve documentation, please open an issue or submit a pull request at:

https://github.com/agallinat/netkit/issues

For larger changes, feel free to open a discussion first.