morphers {tidygraph}R Documentation

Functions to generate alternate representations of graphs

Description

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.

Usage

to_linegraph(graph)

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

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

to_components(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_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)

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

Arguments

graph

A tbl_graph

...

Arguments to pass on to filter() or group_by()

subset_by, split_by

Whether to create subgraphs based on nodes or edges

type

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

loops

Should loops be included. Defaults to FALSE

node

The center of the neighborhood

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.

simplify

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

Value

A list of tbl_graphs

Functions

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

[Package tidygraph version 1.0.0 Index]