These functions reformat manynet-consistent data.

  • to_directed() reformats undirected network data to a directed network.

  • to_undirected() reformats directed network data to an undirected network, so that any pair of nodes with at least one directed edge will be connected by an undirected edge in the new network. By default this is equivalent to the "collapse" mode in {igraph}, but rule offers the other ways of reconciling a pair of ties running in opposite directions, which matters where the network is weighted.

  • to_redirected() formats directed network data by flipping/transposing any existing direction such that senders become receivers and receivers become senders. This essentially has no effect on undirected networks or reciprocated ties.

  • to_reciprocated() reformats directed network data such that every directed tie is reciprocated.

  • to_acyclic() reformats network data to an acyclic graph.

If the format condition is not met, for example to_undirected() is used on a network that is already undirected, the network data is returned unaltered. No warning is given so that these functions can be used to ensure conformance.

Unlike the as_*() group of functions, these functions always return the same class as they are given, only transforming these objects' properties.

to_directed(.data)

to_undirected(
  .data,
  rule = c("collapse", "min", "max", "mean", "sum", "product")
)

to_redirected(.data)

to_reciprocated(.data)

to_acyclic(.data)

Arguments

.data

An object of a {manynet}-consistent class:

  • adjacency or incidence matrix from {base} R

  • edgelist data.frame from {base} R or tbl/tbl_df from {tibble}

  • stocnet stocnet, from the {manynet} package

  • igraph igraph, from the {igraph} package

  • network network, from the {network} package

  • tidygraph tbl_graph, from the {tidygraph} package

rule

How the values of a pair of ties running in opposite directions are reconciled into the single value of an undirected tie:

  • "collapse" (the default) sums them, so that a tie exists wherever a tie existed in either direction. For an unweighted network this is igraph's "collapse" mode, since a tie in either direction gives 1 either way.

  • "sum" is the same operation, named for the arithmetic rather than the intent.

  • "min" takes the smaller of the two values, so that a tie is only as strong as the weaker direction. Use where a relationship needs to be confirmed from both sides, as in a mutual friendship nomination.

  • "max" takes the larger, so that the stronger direction stands for the pair. Use where a single report is taken as sufficient evidence.

  • "mean" averages them, treating the two directions as two readings of one underlying quantity.

  • "product" multiplies them, so that a tie survives only where both directions are non-zero, and strong ties are rewarded disproportionately.

Values missing in one direction are not treated as agreement: they propagate, so that NA in either direction gives NA. Use impute_ties() first to state a different assumption.

Value

An object of the same class as the function was given, modified as explained in the function description, details, or section. Functions that split a network return a list of such objects.

Details

Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:

                data.frame default igraph matrix network stocnet tbl_graph
to_acyclic                       *      *                      *         *
to_directed                      *      *
to_reciprocated                  *      *      *
to_redirected            *       *      *      *
to_undirected            *       *      *      *       *                 *

Examples

to_undirected(ison_networkers)
#> 
#> ── # EIES Networkers ───────────────────────────────────────────────────────────
#> # A labelled, weighted, undirected network of 32 nodes and 266 ties
#> 
#> ── Nodes 
#> # A tibble: 32 × 3
#>   name               Discipline   Citations
#>   <chr>              <chr>            <dbl>
#> 1 Lin Freeman        Sociology           19
#> 2 Doug White         Anthropology         3
#> 3 Ev Rogers          Other              170
#> 4 Richard Alba       Sociology           23
#> 5 Phipps Arabie      Other               16
#> 6 Carol Barner-Barry Other                6
#> # ℹ 26 more rows
#> 
#> ── Ties 
#> # A tibble: 266 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     1     2    852
#> 2     1     3     32
#> 3     2     3     22
#> 4     1     4    117
#> 5     2     4     47
#> 6     1     5     46
#> # ℹ 260 more rows
#> 
to_undirected(ison_networkers, rule = "min")
#> # A labelled, weighted, undirected network of 32 nodes and 174 ties
#> 
#> ── Nodes 
#> # A tibble: 32 × 3
#>   name               Discipline   Citations
#>   <chr>              <chr>            <dbl>
#> 1 Lin Freeman        Sociology           19
#> 2 Doug White         Anthropology         3
#> 3 Ev Rogers          Other              170
#> 4 Richard Alba       Sociology           23
#> 5 Phipps Arabie      Other               16
#> 6 Carol Barner-Barry Other                6
#> # ℹ 26 more rows
#> 
#> ── Ties 
#> # A tibble: 174 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     1     2    364
#> 2     1     3      4
#> 3     1     4     52
#> 4     1     5     20
#> 5     1     6     65
#> 6     1     7     14
#> # ℹ 168 more rows
#>