Skip to content

justinmchase/deno-dag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno DAG 🦕

A Directed Asyclic Graph (DAG) resolver for Deno

Based on Kahn's algorithm for topographical sorting.

Setup

import { topographicalSort } from "https://deno.land/x/dag/mod.ts";

//         A
//        / \
//       B   C
//        \ /
//         D
const targets = [
  { name: "D" },
  { name: "A", dependencies: ["B", "C"] },
  { name: "C", dependencies: ["D"] },
  { name: "B", dependencies: ["D"] },
];

const sorted = topographicalSort(targets);
console.log(sorted.map(({ name }) => name)); // A,B,C,D

About

A Directed Asyclic Graph (DAG) resolver for Deno

Resources

License

Stars

Watchers

Forks

Packages

No packages published