These functions calculate properties that are dependent on the overall topology of the graph.
node_dominator(root, mode = "out")
node_topo_order(mode = "out")
The node to start the dominator search from
How should edges be followed. Either 'in'
or 'out'
A vector of the same length as the number of nodes in the graph
node_dominator()
: Get the immediate dominator of each node. Wraps igraph::dominator_tree()
.
node_topo_order()
: Get the topological order of nodes in a DAG. Wraps igraph::topo_sort()
.
# Sort a graph based on its topological order
create_tree(10, 2) %>%
arrange(sample(graph_order())) %>%
mutate(old_ind = seq_len(graph_order())) %>%
arrange(node_topo_order())
#> # A tbl_graph: 10 nodes and 9 edges
#> #
#> # A rooted tree
#> #
#> # Node Data: 10 × 1 (active)
#> old_ind
#> <int>
#> 1 4
#> 2 5
#> 3 9
#> 4 7
#> 5 8
#> 6 1
#> 7 10
#> 8 3
#> 9 2
#> 10 6
#> #
#> # Edge Data: 9 × 2
#> from to
#> <int> <int>
#> 1 1 3
#> 2 1 2
#> 3 3 7
#> # ℹ 6 more rows