src/main/java/org/thegalactic/dgraph/ConcreteDGraph.java
private ArrayList<Node<N>>[] depthFirstSearch(Node<N> source, TreeSet<Node<N>> visited, ArrayList<Node<N>> sort) {
        ArrayList<Node<N>> first = new ArrayList<Node<N>>();
        ArrayList<Node<N>> last = new ArrayList<Node<N>>();
        first.add(source);
        visited.add(source);
        ArrayList<Node<N>>[] arrayVisited = new ArrayList[2];
        if (sort != null) {
            // search according to a sort
            for (Node<N> node : sort) {
                if (this.getSuccessorNodes(source).contains(node) && !visited.contains(node)) {
                    arrayVisited = this.depthFirstSearch(node, visited, sort);
                    visited.addAll(arrayVisited[0]);
                    first.addAll(arrayVisited[0]);
                    last.addAll(arrayVisited[1]);
                }
            }
        } else {
            // classical search
            for (Node<N> node : this.getSuccessorNodes(source)) {
                if (!visited.contains(node)) {
                    arrayVisited = this.depthFirstSearch(node, visited, sort);
                    visited.addAll(arrayVisited[0]);
                    first.addAll(arrayVisited[0]);
                    last.addAll(arrayVisited[1]);
                }
            }
        }
        last.add(source);
        arrayVisited[0] = first;
        arrayVisited[1] = last;
        return arrayVisited;
    }
/**
     * Returns a two cells array containing the first visited sort on the nodes,
     * and the last visited sort on the nodes, by a depth first traverse issued
     * source the specified node.
     *
     * @param source  The source node
     * @param visited The visited nodes
     * @param sort    The sort parameter
     *
     * @return The array
     *
     * @todo Do we change that to iterators? Change to private and add a method
     * that return an iterator
     */
Returns a two cells array containing the first visited sort on the nodes,
and the last visited sort on the nodes, by a depth first traverse issued
source the specified node.

@param source  The source node
@param visited The visited nodes
@param sort    The sort parameter

@return The array

@todo Do we change that to iterators. Change to private and add a method
that return an iterator
Returns a two cells array containing the first visited sort on the nodes and the last visited sort on the nodes by a depth first traverse issued source the specified node . @param source The source node @param visited The visited nodes @param sort The sort parameter @return The array @todo Do we change that to iterators . Change to private and add a method that return an iterator
private ArrayList<Node<N>>[] depthFirstSearch(Node<N> source, TreeSet<Node<N>> visited, ArrayList<Node<N>> sort) {
        ArrayList<Node<N>> first = new ArrayList<Node<N>>();
        ArrayList<Node<N>> last = new ArrayList<Node<N>>();
        first.add(source);
        visited.add(source);
        ArrayList<Node<N>>[] arrayVisited = new ArrayList[2];
        if (sort != null) {
            for (Node<N> node : sort) {
                if (this.getSuccessorNodes(source).contains(node) && !visited.contains(node)) {
                    arrayVisited = this.depthFirstSearch(node, visited, sort);
                    visited.addAll(arrayVisited[0]);
                    first.addAll(arrayVisited[0]);
                    last.addAll(arrayVisited[1]);
                }
            }
        } else {
            for (Node<N> node : this.getSuccessorNodes(source)) {
                if (!visited.contains(node)) {
                    arrayVisited = this.depthFirstSearch(node, visited, sort);
                    visited.addAll(arrayVisited[0]);
                    first.addAll(arrayVisited[0]);
                    last.addAll(arrayVisited[1]);
                }
            }
        }
        last.add(source);
        arrayVisited[0] = first;
        arrayVisited[1] = last;
        return arrayVisited;
    }
private ArrayList < Node < N > > [ ] depthFirstSearch ( Node < N > source , TreeSet < Node < N > > visited , ArrayList < Node < N > > sort ) { ArrayList < Node < N > > first = new ArrayList < Node < N > > ( ) ; ArrayList < Node < N > > last = new ArrayList < Node < N > > ( ) ; first . add ( source ) ; visited . add ( source ) ; ArrayList < Node < N > > [ ] arrayVisited = new ArrayList [ 2 ] ; if ( sort != null ) { for ( Node < N > node : sort ) { if ( this . getSuccessorNodes ( source ) . contains ( node ) && ! visited . contains ( node ) ) { arrayVisited = this . depthFirstSearch ( node , visited , sort ) ; visited . addAll ( arrayVisited [ 0 ] ) ; first . addAll ( arrayVisited [ 0 ] ) ; last . addAll ( arrayVisited [ 1 ] ) ; } } } else { for ( Node < N > node : this . getSuccessorNodes ( source ) ) { if ( ! visited . contains ( node ) ) { arrayVisited = this . depthFirstSearch ( node , visited , sort ) ; visited . addAll ( arrayVisited [ 0 ] ) ; first . addAll ( arrayVisited [ 0 ] ) ; last . addAll ( arrayVisited [ 1 ] ) ; } } } last . add ( source ) ; arrayVisited [ 0 ] = first ; arrayVisited [ 1 ] = last ; return arrayVisited ; }
Returns a two cells array containing the first visited sort on the nodes,
 and the last visited sort on the nodes, by a depth first traverse issued
 source the specified node.
Returns a two cells array containing the first visited sort on the nodes and the last visited sort on the nodes by a depth first traverse issued source the specified node .
// search according to a sort // classical search