public final void analyze() {
        if (isAcyclic()) {
            System.out.println("This graph is acyclic.");

            int[] order = sort();
            System.out.print("Sorted order: ");
            for (int id : order)
                System.out.print(lookupNode(id).getName() + " ");
            System.out.println("");
        } else
            System.out.println("This graph is cyclic.");
    }