Learn R Programming

migraph (version 0.10.6)

transform: Tools for transforming networks, graphs, and matrices

Description

These functions offer tools for transforming migraph-consistent objects (matrices, igraph, tidygraph, or network objects). Transforming means that the returned object may have different dimensions than the original object.

Usage

to_mode1(object)

to_mode2(object)

to_main_component(object)

to_subgraph(object, ...)

to_ties(object)

to_blocks(object, membership, FUN = mean)

Arguments

object

An object of a migraph-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

...

Arguments passed on to dplyr::filter

membership

A vector of partition memberships

FUN

A function for summarising block content. By default mean. Other recommended options include median, sum, min or max.

Functions

  • to_mode1: Results in a weighted one-mode object that retains the row nodes from a two-mode object, and weights the ties between them on the basis of their joint ties to nodes in the second mode (columns)

  • to_mode2: Results in a weighted one-mode object that retains the column nodes from a two-mode object, and weights the ties between them on the basis of their joint ties to nodes in the first mode (rows).

  • to_main_component: Returns an object that includes only the main component without any smaller components or isolates

  • to_subgraph: Returns a network subgraph filtered on the basis of some node-related logical statement.

  • to_ties: Returns a matrix (named if possible) where the edges are the nodes

  • to_blocks: Returns a reduced graph from a given partition membership vector

Details

Since some modifications are easier to implement for some objects than others, here are the currently implemented modifications:

to_edgelistsmatricesigraphtidygraphnetwork
mode1XXX
mode2XXX
main_componentXXX
subgraphXXXXX
tiesXXXXX
blocksXXXXX

Note that to_subgraph() returns a 'tidygraph' object, to_ties() returns an 'igraph' object, and to_blocks() returns a 'matrix' object.

See Also

Other manipulations: add, as(), grab, reformat

Examples

Run this code
autographr(ison_southern_women) /
(autographr(to_mode1(ison_southern_women)) |
autographr(to_mode2(ison_southern_women)))
autographr(ison_adolescents) +  
autographr(to_ties(ison_adolescents))
(adolblock <- to_blocks(ison_adolescents, 
  node_regular_equivalence(ison_adolescents, k = 3)))
autographr(adolblock)

Run the code above in your browser using DataLab