is-acyclic.js 232 B

123456789101112131415
  1. var topsort = require('./topsort')
  2. module.exports = isAcyclic
  3. function isAcyclic (g) {
  4. try {
  5. topsort(g)
  6. } catch (e) {
  7. if (e instanceof topsort.CycleException) {
  8. return false
  9. }
  10. throw e
  11. }
  12. return true
  13. }