topo_sort_kahn: Return a sorted vector of nodes id

View source: R/graph.R

topo_sort_kahnR Documentation

Return a sorted vector of nodes id

Description

Return a sorted vector of nodes id

Usage

topo_sort_kahn(g, random = FALSE)

Arguments

g

An igraph object of a DAG

random

Boolean, whether the order of selected nodes is randomised in the process

Value

A data frame with two columns: "id" is the names of nodes in g, and "id_num" is the topological ordering

Examples

df0 <- data.frame(from = c("a", "b"), to = c("b", "c"), stringsAsFactors = FALSE)
g0 <- igraph::graph_from_data_frame(df0, directed = TRUE)
topo_sort_kahn(g0)

clement-lee/rackage documentation built on March 28, 2024, 7:05 p.m.