static void set_ordinals_in_plausible_commit_order(Map<String, Set<String>> graph,
                                                       OrdinalMapper ordinals) {

        // Make a list of all  parent to child edges.
        // Each edge represents the constraint "the ordinal of this parent is less
        // than the ordinal of this child".
        List<GraphEdge> edges = new ArrayList<GraphEdge>();
        Set<String> leaf_nodes = new HashSet<String>();
        for (Map.Entry<String, Set<String>> entry : graph.entrySet()) {
            String child = entry.getKey();
            Set<String> parents = entry.getValue();
            if (parents.size() == 0) {
                leaf_nodes.add(child);
                continue;
            }

            for (String parent : parents) {
                edges.add(new GraphEdge(parent, child));
            }
        }

        while (!edges.isEmpty()) {
            // Find edges to vertices that no other edges reference.
            Set<String> candidates = new HashSet<String>();
            Set<String> referenced = new HashSet<String>();
            for (GraphEdge edge : edges) {
                candidates.add(edge.mFrom);
                referenced.add(edge.mTo);
            }
            // i.e. "the parents which no remaining children reference."
            // Implies must have lower ordinals than all unprocessed children.
            candidates.removeAll(referenced);
            assert_(candidates.size() > 0);

            List<String> sorted = new ArrayList<String>(candidates);
            Collections.sort(sorted);
            for (String candidate : sorted) {
                // Set the ordinal.
                ordinals.ordinal(candidate);
                // Remove any unreferenced edges from the list.
                 // LATER: fix crappy code. do in one pass outside loop.
                remove_edges(edges, candidate);
            }
        }

        // Tweak here to order by date? or some other metric?
        // Set the ordinals for nodes which have no children.
        List<String> sorted_leaf_nodes = new ArrayList<String>(leaf_nodes);
        Collections.sort(sorted_leaf_nodes);
        for (String leaf_node : sorted_leaf_nodes) {
            ordinals.ordinal(leaf_node);
        }
    }