javascript kata for *simple* directed acyclic graph