src/main/java/org/thegalactic/dgraph/ConcreteDGraph.java
public List<Node<N>> topologicalSort() {
        TreeSet<Node<N>> sinks = new TreeSet<Node<N>>(this.getSinks());
        // initialise a map with the number of predecessors (value) for each node (key);
        TreeMap<Node<N>, Integer> size = new TreeMap<Node<N>, Integer>();
        for (Node<N> node : this.nodes) {
            size.put(node, Integer.valueOf(this.getPredecessorNodes(node).size()));
        }
        List<Node<N>> sort = new ArrayList<Node<N>>();
        while (!sinks.isEmpty()) {
            Node<N> node = sinks.pollFirst();
            sort.add(node);
            // updating of the set min by considering the successors of node
            for (Node<N> successor : this.getSuccessorNodes(node)) {
                int newSize = size.get(successor).intValue() - 1;
                size.put(successor, Integer.valueOf(newSize));
                if (newSize == 0) {
                    sinks.add(successor);
                }
            }
        }
        return sort;
    }
/**
     * Returns a topological sort of the node of this component.
     *
     * This topological sort is a sort on all the nodes according to their
     * successors. If the graph is not acyclic, some nodes don't belong to the
     * sort. This treatment is performed in O(n+m), where n corresponds to the
     * number of nodes, and m corresponds to the number of edges.
     *
     * @return the nodes
     */
Returns a topological sort of the node of this component.
This topological sort is a sort on all the nodes according to their
successors. If the graph is not acyclic, some nodes don't belong to the
sort. This treatment is performed in O(n+m), where n corresponds to the
number of nodes, and m corresponds to the number of edges.

@return the nodes
Returns a topological sort of the node of this component . This topological sort is a sort on all the nodes according to their successors . If the graph is not acyclic some nodes don ' t belong to the sort . This treatment is performed in O ( n + m ) where n corresponds to the number of nodes and m corresponds to the number of edges . @return the nodes
public List<Node<N>> topologicalSort() {
        TreeSet<Node<N>> sinks = new TreeSet<Node<N>>(this.getSinks());
        TreeMap<Node<N>, Integer> size = new TreeMap<Node<N>, Integer>();
        for (Node<N> node : this.nodes) {
            size.put(node, Integer.valueOf(this.getPredecessorNodes(node).size()));
        }
        List<Node<N>> sort = new ArrayList<Node<N>>();
        while (!sinks.isEmpty()) {
            Node<N> node = sinks.pollFirst();
            sort.add(node);
            for (Node<N> successor : this.getSuccessorNodes(node)) {
                int newSize = size.get(successor).intValue() - 1;
                size.put(successor, Integer.valueOf(newSize));
                if (newSize == 0) {
                    sinks.add(successor);
                }
            }
        }
        return sort;
    }
public List < Node < N > > topologicalSort ( ) { TreeSet < Node < N > > sinks = new TreeSet < Node < N > > ( this . getSinks ( ) ) ; TreeMap < Node < N > , Integer > size = new TreeMap < Node < N > , Integer > ( ) ; for ( Node < N > node : this . nodes ) { size . put ( node , Integer . valueOf ( this . getPredecessorNodes ( node ) . size ( ) ) ) ; } List < Node < N > > sort = new ArrayList < Node < N > > ( ) ; while ( ! sinks . isEmpty ( ) ) { Node < N > node = sinks . pollFirst ( ) ; sort . add ( node ) ; for ( Node < N > successor : this . getSuccessorNodes ( node ) ) { int newSize = size . get ( successor ) . intValue ( ) - 1 ; size . put ( successor , Integer . valueOf ( newSize ) ) ; if ( newSize == 0 ) { sinks . add ( successor ) ; } } } return sort ; }
Returns a topological sort of the node of this component.
Returns a topological sort of the node of this component .
// initialise a map with the number of predecessors (value) for each node (key); // updating of the set min by considering the successors of node