These functions are meant to be passed into morph() to create a temporary alternate representation of the input graph. They are thus not meant to be called directly. See below for detail of each morpher.

to_linegraph(graph)

to_subgraph(graph, ..., subset_by = NULL)

to_subcomponent(graph, node)

to_split(graph, ..., split_by = NULL)

to_components(graph, type = "weak", min_order = 1)

to_largest_component(graph, type = "weak")

to_complement(graph, loops = FALSE)

to_local_neighborhood(graph, node, order = 1, mode = "all")

to_dominator_tree(graph, root, mode = "out")

to_minimum_spanning_tree(graph, weights = NULL)

to_random_spanning_tree(graph)

to_shortest_path(graph, from, to, mode = "out", weights = NULL)

to_bfs_tree(graph, root, mode = "out", unreachable = FALSE)

to_dfs_tree(graph, root, mode = "out", unreachable = FALSE)

to_simple(graph, remove_multiples = TRUE, remove_loops = TRUE)

to_contracted(graph, ..., simplify = TRUE)

to_unfolded_tree(graph, root, mode = "out")

to_directed(graph)

to_undirected(graph)

to_hierarchical_clusters(graph, method = "walktrap", weights = NULL, ...)

Arguments

graph

A tbl_graph

...

Arguments to pass on to filter(), group_by(), or the cluster algorithm (see igraph::cluster_walktrap(), igraph::cluster_leading_eigen(), and igraph::cluster_edge_betweenness())

subset_by, split_by

Whether to create subgraphs based on nodes or edges

node

The center of the neighborhood for to_local_neighborhood() and the node to that should be included in the component for to_subcomponent()

type

The type of component to split into. Either 'weak' or 'strong'

min_order

The minimum order (number of vertices) of the component. Components below this will not be created

loops

Should loops be included. Defaults to FALSE

order

The radius of the neighborhood

mode

How should edges be followed? 'out' only follows outbound edges, 'in' only follows inbound edges, and 'all' follows all edges. This parameter is ignored for undirected graphs.

root

The root of the tree

weights

Optional edge weights for the calculations

from, to

The start and end node of the path

unreachable

Should the search jump to a node in a new component when stuck.

remove_multiples

Should edges that run between the same nodes be reduced to one

remove_loops

Should edges that start and end at the same node be removed

simplify

Should edges in the contracted graph be simplified? Defaults to TRUE

method

The clustering method to use. Either 'walktrap', 'leading_eigen', or 'edge_betweenness'

Value

A list of tbl_graphs

Functions

  • to_linegraph(): Convert a graph to its line graph. When unmorphing node data will be merged back into the original edge data. Edge data will be ignored.

  • to_subgraph(): Convert a graph to a single subgraph. ... is evaluated in the same manner as filter. When unmorphing all data in the subgraph will get merged back.

  • to_subcomponent(): Convert a graph to a single component containing the specified node

  • to_split(): Convert a graph into a list of separate subgraphs. ... is evaluated in the same manner as group_by. When unmorphing all data in the subgraphs will get merged back, but in the case of split_by = 'edges' only the first instance of node data will be used (as the same node can be present in multiple subgraphs).

  • to_components(): Split a graph into its separate components. When unmorphing all data in the subgraphs will get merged back.

  • to_largest_component(): Create a new graph only consisting of it's largest component. If multiple largest components exists, the one with containing the node with the lowest index is chosen.

  • to_complement(): Convert a graph into its complement. When unmorphing only node data will get merged back.

  • to_local_neighborhood(): Convert a graph into the local neighborhood around a single node. When unmorphing all data will be merged back.

  • to_dominator_tree(): Convert a graph into its dominator tree based on a specific root. When unmorphing only node data will get merged back.

  • to_minimum_spanning_tree(): Convert a graph into its minimum spanning tree/forest. When unmorphing all data will get merged back.

  • to_random_spanning_tree(): Convert a graph into a random spanning tree/forest. When unmorphing all data will get merged back

  • to_shortest_path(): Limit a graph to the shortest path between two nodes. When unmorphing all data is merged back.

  • to_bfs_tree(): Convert a graph into a breath-first search tree based on a specific root. When unmorphing only node data is merged back.

  • to_dfs_tree(): Convert a graph into a depth-first search tree based on a specific root. When unmorphing only node data is merged back.

  • to_simple(): Collapse parallel edges and remove loops in a graph. When unmorphing all data will get merged back

  • to_contracted(): Combine multiple nodes into one. ... is evaluated in the same manner as group_by. When unmorphing all data will get merged back.

  • to_unfolded_tree(): Unfold a graph to a tree or forest starting from multiple roots (or one), potentially duplicating nodes and edges.

  • to_directed(): Make a graph directed in the direction given by from and to

  • to_undirected(): Make a graph undirected

  • to_hierarchical_clusters(): Convert a graph into a hierarchical clustering based on a grouping

Examples

# Compute only on a subgraph of every even node
create_notable('meredith') %>%
  morph(to_subgraph, seq_len(graph_order()) %% 2 == 0) %>%
  mutate(neighbour_count = centrality_degree()) %>%
  unmorph()
#> Subsetting by nodes
#> # A tbl_graph: 70 nodes and 140 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Node Data: 70 × 1 (active)
#>    neighbour_count
#>              <dbl>
#>  1              NA
#>  2               2
#>  3              NA
#>  4               2
#>  5              NA
#>  6               2
#>  7              NA
#>  8               2
#>  9              NA
#> 10               3
#> # ℹ 60 more rows
#> #
#> # Edge Data: 140 × 2
#>    from    to
#>   <int> <int>
#> 1     1     5
#> 2     1     6
#> 3     1     7
#> # ℹ 137 more rows