Lifecycle: maturing CRAN/METACRAN GitHub release (latest by date) GitHub Release Date Codecov test coverage CodeFactor CII Best Practices DOI

About the package

{migraph} works with and extends existing network analysis packages for analysing multimodal networks. It provides a common, standard syntax for working with and analysing both one-mode and two-mode networks.

The package is intended as a software companion to the book:

David Knoke, Mario Diani, James Hollway, and Dimitris Christopoulos (2021) Multimodal Political Networks. Cambridge University Press: Cambridge.

Most datasets used in the book are included in this package, and the package implements most methods discussed in the book. Since many of theses datasets and routines are discussed and analysed more there, if you like the package please check out the book, and vice versa.

How does migraph help?

{migraph} can help with many network analytic tasks, including Making and Manipulating network data, Marking and Measuring nodes, ties, and networks, calculating Motifs and identifying Memberships, as well as Modelling and Mapping.

Making network data

Including network data

{migraph} includes a number of prominent network datasets, especially multimodal and multiplex examples for demonstrating more advanced methods.

Importing network data

If that’s not enough, {migraph} offers a number of options for importing network data found in other repositories. {migraph} can import and export to Excel edgelists and nodelists, UCINET, Pajek, and DynetML files, e.g.:

Inventing network data

{migraph} includes algorithms for making networks with particular properties. The create_* group of functions create networks with a particular structure, e.g.:

The generate_* group of functions generate networks from particular generative mechanisms, e.g.:

Note that all these functions work to create two-mode networks as well as one-mode versions.

Manipulating network data

In addition to functions that help add elements to or extract elements from a network, {migraph} also includes functions for coercing and changing network data.

Coercing network data

Once network data is in R, {migraph}’s as_*() functions can be used to translate objects from one of the above classes into any other, and include:

These functions are designed to be as intuitive and lossless as possible, outperforming many other class-coercion packages.

We use these functions internally in every {migraph} function to (1) allow them to be run on any compatible network format and (2) use the most efficient algorithm available. This makes {migraph} compatible with your existing workflow, whether you use base R matrices or edgelists as data frames, {igraph}, {network}, or {tidygraph}, and extensible by developments in those other packages too.

Changing network data

{migraph}’s to_*() functions can be used on any class object to reformat, transform, or split networks into networks with other properties, e.g.:

Reformatting means changing the format of the network, e.g. from directed to undirected via to_undirected(). Transforming means changing the dimensions of the network, e.g. from a two-mode network to a one-mode projection via to_mode1(). Splitting means separating a network, e.g. from a whole network to the various ego networks via to_egos(). Those functions that split a network into a list of networks are distinguishable as those to_*() functions that are named in the plural.

Marks and Measures

{migraph} offers a range of measures and models with sensible defaults. Many wrap existing functions in common packages for use with one-mode networks, but extend these to treat and/or normalise for two-mode (and sometimes three-mode) networks correctly. Functions are given intuitive and succinct names that avoid conflicts with existing function names wherever possible.

Marking networks

{migraph}’s *is_*() functions offer fast logical tests of various properties. Whereas is_*() returns a single logical value for the network, node_is_*() returns a logical vector the length of the number of nodes in the network, and tie_is_*() returns a logical vector the length of the number of ties in the network.

The *is_max() and *is_min() functions are used to identify the maximum or minimum, respectively, node or tie according to some measure (see below).

Measuring networks

{migraph} offers a large and growing smorgasbord of measures that can be used at the node, tie, and network level. Each recognises whether the network is directed or undirected, weighted or unweighted, one-mode or two-mode. All return normalized values wherever possible, though this can be overrided. Here are some examples:

Please explore the list of functions to find out more.

Motifs and Memberships

The package also include functions for returning various censuses at the network or node level, e.g.:

These can be analysed alone, or used as a profile for establishing equivalence. {migraph} offers both HCA and CONCOR algorithms, as well as elbow, silhouette, and strict methods for k-cluster selection.

{migraph} also includes functions for establishing membership on other bases, such as typical community detection algorithms, as well as component and core-periphery partitioning algorithms.


All measures can be tested against conditional uniform graph (CUG) or quadratic assignment procedure (QAP) distributions using:

Hypotheses can also be tested within multivariate models via multiple (linear or logistic) regression QAP:

{migraph} is the only package that offers these testing frameworks for two-mode networks as well as one-mode networks.

Lastly, {migraph} also includes functions for simulating diffusion or learning processes over a given network:

The diffusion models include not only SI and threshold models, but also SIS, SIR, SIRS, SIER, and SIERS.

Plot methods for all outputs assist with interpretation and communication.


Besides intuitive plot() methods for most of the above outputs, {migraph} also includes autographr() for one-line plotting graphs with sensible defaults based on their properties. {migraph} uses the excellent {ggraph} package (and thus {ggplot2}) as a plotting engine. This also makes extending and theming default output easy, and {patchwork} is used to help arrange individual plots together.

In addition, {migraph} offers some additional layout algorithms for snapping layouts to a grid or visualising partitions horizontally, vertically, or concentrically. The following figures illustrate the difference in results over {igraph}:



The easiest way to install the latest stable version of {migraph} is via CRAN. Simply open the R console and enter:


You can then begin to use {migraph} by loading the package:


This will load any required packages and make the data contained within the package available. The version from CRAN also has all the vignettes built and included. You can check them out with:

vignettes(package = "migraph")


For the latest development version, for slightly earlier access to new features or for testing, you may wish to download and install the binaries from Github or install from source locally.

The latest binary releases for all major OSes – Windows, Mac, and Linux – can be found here. Download the appropriate binary for your operating system, and install using an adapted version of the following commands:

To install from source the latest main version of {migraph} from Github, please install the {remotes} or {devtools} package from CRAN and then:


This package has recently moved away from the use of vignettes, in favour of smaller and more interactive {learnr} tutorials. Since version 0.12.3, many of the previous vignettes are instead available as tutorials, more will be converted soon, and those that have been converted will continue to be updated and enriched.

To access the tutorials, you will need to have the additional package {learnr} installed: install.packages("learnr"). Then we would first suggest that you check to see which vignettes are currently available:

#> Available tutorials:
#> * migraph
#>   - tutorial2 : "Visualisation"
#>   - tutorial3 : "Centrality"
#>   - tutorial4 : "Community"
#>   - tutorial5 : "Equivalence"
#>   - tutorial6 : "Topology"
#>   - tutorial7 : "Diffusion"
#>   - tutorial8 : "Regression"

You can then choose to begin a tutorial using the following command: e.g. learnr::run_tutorial("tutorial2", "migraph"). For more details on the {learnr} package, see here.

Relationship to other packages

It draws together, updates, and builds upon many functions currently available in other excellent R packages such as {bipartite}, {multinet}, and {tnet}, and implements many additional features currently only available outside the R ecosystem in packages such as UCINET.

Funding details

Subsequent work on this package has been funded by the Swiss National Science Foundation (SNSF) Grant Number 188976: “Power and Networks and the Rate of Change in Institutional Complexes” (PANARCHIC).