/*
Given a Digraph **g** this function returns `true` if the graph has no
cycles and returns `false` if it does. This algorithm returns as soon as it
detects the first cycle.

Use [alg.findCycles][] if you need the actual list of cycles in a graph.

[alg.findCycles]: findCycles.js.html#findCycles

@param {Digraph} g the graph to test for cycles
function isAcyclic(g) {
  try {
    topsort(g);
  } catch (e) {
    if (e instanceof topsort.CycleException) return false;
    throw e;
  }
  return true;
}