Learn R Programming

migraph

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?

Works with your current network analysis workflow

The package is offered as a complement to existing R packages for network analysis and thus tries to work well with whatever format network objects you are already working with. All {migraph} measures and models work with data in base formats:

  • adjacency and incidence matrices
  • one-mode and two-mode data frame edgelists

as well as with objects constructed from the following packages:

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

Manipulation

Regardless of which class object you are working with, the same syntax can be used to work with and manipulate your data.

{migraph}’s is_*() functions offer fast logical tests of network properties, e.g.:

  • is_acyclic(), is_bipartite(), is_complex(), is_connected(), is_directed(), is_edgelist(), is_graph(), is_labelled(), is_migraph(), is_multiplex(), is_signed(), is_twomode(), is_uniplex(), is_weighted()

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

  • to_blocks(), to_edges(), to_giant(), to_main_component(), to_matching(), to_mode1(), to_mode2(), to_multilevel(), to_named(), to_onemode(), to_redirected(), to_simplex(), to_subgraph(), to_ties(), to_twomode(), to_undirected(), to_uniplex(), to_unnamed(), to_unsigned(), to_unweighted()

Making

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

  • create_complete(), create_components(), create_core(), create_empty(), create_lattice(), create_ring(), create_star(), create_tree()

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

  • generate_permutation(), generate_random(), generate_scalefree(), generate_smallworld()

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

  • mpn_bristol, mpn_cow_igo, mpn_cow_trade, mpn_DE_1990, mpn_DE_2008, mpn_DemSxP, mpn_elite_mex, mpn_elite_usa_advice, mpn_elite_usa_money, mpn_IT_1990, mpn_IT_2008, mpn_OverSxP, mpn_RepSxP, mpn_ryanair, mpn_UK_1990, mpn_UK_2008
  • ison_adolescents, ison_algebra, ison_bb, ison_bm, ison_brandes, ison_brandes2, ison_karateka, ison_marvel_relationships, ison_marvel_teams, ison_mb, ison_mm, ison_networkers, ison_southern_women

{migraph} can also import and export to Excel edgelists and nodelists, UCINET and Pajek files, e.g.:

  • read_edgelist(), read_nodelist(), read_pajek(), read_ucinet()
  • write_edgelist(), write_nodelist(), write_pajek(), write_ucinet()

Extends your current network analysis workflow

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

Measures

  • Centrality: node_degree(), node_closeness(), node_betweenness(), and node_eigenvector()
  • Centralization: network_degree(), network_closeness(), network_betweenness(), and network_eigenvector()
  • Cohesion: network_density(), network_reciprocity(), network_transitivity(), network_equivalency(), and network_congruency()
  • Connectedness: network_components(), network_cohesion(), network_adhesion(), network_diameter(), network_length()
  • Diversity: network_diversity(), network_homophily(), network_assortativity()
  • Structural holes: e.g. node_redundancy(), node_effsize(), node_efficiency(), node_constraint(), node_hierarchy()
  • Topological features: e.g. network_core(), network_factions(), network_modularity(), network_smallworld(), network_balance()

Motifs

  • Censuses: node_path_census(), node_quad_census(), node_tie_census(), node_triad_census(), network_dyad_census(), network_mixed_census(), network_triad_census()

Models

  • Blockmodelling: node_automorphic_equivalence(), node_equivalence(), node_regular_equivalence(), node_structural_equivalence()
  • Testing (via CUG/QAP): test_permutation(), test_random()
  • Linear and logistic regression for networks (via MRQAP): network_reg()

Visualization

  • autographr() for one-line plotting graphs with sensible defaults based on their properties
  • New layouts for snapping a layout to a grid or for visualizing partitions:
  • Class-based plots: e.g. plot.matrix(), plot.members(), plot.node_measure()

Please explore the list of functions to find out more.

Installation

Stable

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

install.packages('migraph')

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

library(migraph)

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

Development

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:

  • For Windows: install.packages("~/Downloads/migraph_winOS.zip", repos = NULL)
  • For Mac: install.packages("~/Downloads/migraph_macOS.tgz", repos = NULL)
  • For Unix: install.packages("~/Downloads/migraph_linuxOS.tar.gz", repos = NULL)

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

  • For latest stable version: remotes::install_github("snlab-ch/migraph")
  • For latest development version: remotes::install_github("snlab-ch/migraph@develop")

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.

Copy Link

Version

Install

install.packages('migraph')

Monthly Downloads

914

Version

0.12.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

James Hollway

Last Published

October 4th, 2022

Functions in migraph (0.12.1)

ggevolution

Plot the evolution of a network
core-periphery

Core-periphery clustering algorithms
create

Make networks with defined structures
grab

Grab various node or edge attributes from a network
generate

Make networks with a stochastic element
gglineage

Plot lineage graph
equivalence

Equivalence clustering algorithms
diversity

Measures of network diversity
defunct

Functions that have been renamed, superseded, or are no longer working
features

Measures of network topological features
ison_algebra

Multiplex graph object of friends, social, and task ties (McFarland 2001)
ison_marvel

Multilevel two-mode affiliation, signed one-mode networks of Marvel comic book characters (Yüksel 2017)
ison_brandes

One-mode and two-mode centrality demonstration networks
ison_karateka

One-mode karateka network (Zachary 1977)
holes

Measures of structural holes
grid_layouts

Layouts for snapping layouts to a grid
mpn_elite_usa

Two-mode and three-mode American power elite database (Domhoff 2016)
is

Marking networks based on their properties
mpn_elite_mex

One-mode Mexican power elite database (Knoke 1990)
mpn_evs

Two-mode European Values Survey, 1990 and 2008 (EVS 2020)
mpn_cow

One-mode interstate trade relations and two-mode state membership in IGOs (COW)
ison_adolescents

One-mode subset (8 individuals) of the adolescent society (Coleman 1961).
mark_ties

Marking ties based on their properties
ison_networkers

One-mode EIES dataset (Freeman and Freeman 1979)
mark_nodes

Marking nodes based on their properties
ison_projection

Two-mode projection examples (Hollway 2021)
mpn_bristol

Multimodal (3) Bristol protest events, 1990-2002 (Diani and Bison 2004)
ison_southern_women

Two-mode southern women (Davis, Gardner and Gardner 1941)
mpn_ryanair

One-mode EU policy influence network, June 2004 (Christopoulos 2006)
mpn_senate112

Two-mode 112th Congress Senate Voting (Knoke et al. 2021)
tie_centrality

Measures of tie centrality
transform

Tools for transforming networks, graphs, and matrices
reformat

Tools for reformatting networks, graphs, and matrices
reexports

Objects exported from other packages
partition_layouts

Layout algorithms based on bi- or other partitions
read

Make networks from/to external formats
node_census

Censuses of nodes' motifs
network_census

Censuses of graphs' motifs
tests

Conditional uniform graph and permutation tests
regression

Linear and logistic regression for network data
autographr

Quickly graph networks with sensible defaults
centrality

Measures of node and tie centrality
cohesion

Measures of network cohesion or connectedness
cluster

Methods for equivalence clustering
community

Community graph partitioning algorithms
closure

Measures of network closure
as

Coercion between migraph-compatible object classes
add

Adding and copying attributes from one graph to another
centralisation

Measures of network centralisation
components

Component partitioning algorithms