Learn R Programming

migraph (version 0.9.3)

to: Tools for reformatting networks, graphs, and matrices

Description

These functions offer tools for transforming certain properties of migraph-consistent objects (that is, matrices, igraph, tidygraph, or network objects). Unlike the as_*() group of functions, these functions always return the same object type as they are given, only transforming these objects' properties.

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

to_ edgelists matrices igraph tidygraph network
unweighted X X X X X
undirected X X X X
unsigned X X X X
uniplex X X
unnamed X X X X X
named X X X X X
simplex X X X
main_component X X X
onemode X X
multilevel X X X
mode1 X X X
mode2 X X X

Usage

to_uniplex(object, edge)

to_main_component(object)

to_undirected(object)

to_unweighted(object, threshold = 1)

to_unsigned(object, keep = c("positive", "negative"))

to_unnamed(object)

to_named(object, names = NULL)

to_simplex(object)

to_mode1(object)

to_mode2(object)

to_onemode(object)

to_multilevel(object)

to_edges(object)

to_subgraph(object, ...)

Arguments

object

An object of a migraph-consistent class:

  • matrix, 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

edge

Character string naming an edge attribute to retain from a graph.

threshold

For a matrix, the threshold to binarise/dichotomise at.

keep

In the case of a signed network, whether to retain the "positive" or "negative" ties.

names

Character vector of the node names. NULL by default.

...

Arguments passed on to dplyr::filter

Value

All to_ functions return an object of the same class as that provided. So passing it an igraph object will return an igraph object and passing it a network object will return a network object, with certain modifications as outlined for each function.

Functions

  • to_uniplex: Returns an object that includes only a single type of tie

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

  • to_undirected: Returns an object that has any edge direction removed, so that any pair of nodes with at least one directed edge will be connected by an undirected edge in the new network. This is equivalent to the "collapse" mode in {igraph}.

  • to_unweighted: Returns an object that has all edge weights removed

  • to_unsigned: Returns a network with either just the "positive" ties or just the "negative" ties

  • to_unnamed: Returns an object with all vertex names removed

  • to_named: Returns an object that has random vertex names added

  • to_simplex: Returns an object that has all loops or self-ties removed

  • 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_onemode: Returns an object that has any type/mode attributes removed, but otherwise includes all the same nodes and ties. Note that this is not the same as to_mode1() or to_mode2(), which return only some of the nodes and new ties established by coincidence.

  • to_multilevel: Returns a network that is not divided into two mode types but embeds two or more modes into a multimodal network structure.

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

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

See Also

Other manipulation: add, coercion, is()

Examples

Run this code
# NOT RUN {
autographr(ison_algebra)
a <- to_uniplex(ison_algebra, "friend_tie")
autographr(a)
a <- to_main_component(a)
autographr(a)
a <- to_undirected(a)
autographr(a)
a <- to_unweighted(a)
autographr(a)
a <- to_named(a)
autographr(a)
autographr(to_unsigned(ison_marvel_relationships, "positive")) /
autographr(to_unsigned(ison_marvel_relationships, "negative"))
autographr(ison_southern_women) /
(autographr(to_mode1(ison_southern_women)) |
autographr(to_mode2(ison_southern_women)))
autographr(ison_adolescents) +  
autographr(to_edges(ison_adolescents))
# }

Run the code above in your browser using DataLab