R functions for directed acyclic graphs