src/main/java/com/infilos/DAGraph.java
/**
     * Whether an edge can be successfully added(source -> target) need to determine whether the DAG has cycle
     *
     * @param source     node of origin
     * @param target     node of destination
     * @param createable whether to create a node
     *
     * @return true if added
     */
Whether an edge can be successfully added(source -> target) need to determine whether the DAG has cycle
@param source     node of origin
@param target     node of destination
@param createable whether to create a node

@return true if added
Whether an edge can be successfully added ( source - > target ) need to determine whether the DAG has cycle @param source node of origin @param target node of destination @param createable whether to create a node @return true if added
private boolean isLegalAddEdge(Node source, Node target, boolean createable) {
        if (source.equals(target)) {
            logger.error("edge source({}) can't equals target({})", source, target);
            return false;
        }
        if (!createable) {
            if (!containsNode(source) || !containsNode(target)) {
                logger.error("edge source({}) or target({}) is not in vertices map", source, target);
                return false;
            }
        }
        int verticesCount = getNodesCount();
        Queue<Node> queue = new LinkedList<Node>() {{
            add(target);
        }};
        while (!queue.isEmpty() && (--verticesCount > 0)) {
            Node key = queue.poll();
            for (Node subsenquentNode : getSubsequentNodes(key)) {
                if (subsenquentNode.equals(source)) {
                    return false;
                }
                queue.add(subsenquentNode);
            }
        }
        return true;
    }
private boolean isLegalAddEdge ( Node source , Node target , boolean createable ) { if ( source . equals ( target ) ) { logger . error ( "edge source({}) can't equals target({})" , source , target ) ; return false ; } if ( ! createable ) { if ( ! containsNode ( source ) || ! containsNode ( target ) ) { logger . error ( "edge source({}) or target({}) is not in vertices map" , source , target ) ; return false ; } } int verticesCount = getNodesCount ( ) ; Queue < Node > queue = new LinkedList < Node > ( ) { { add ( target ) ; } } ; while ( ! queue . isEmpty ( ) && ( -- verticesCount > 0 ) ) { Node key = queue . poll ( ) ; for ( Node subsenquentNode : getSubsequentNodes ( key ) ) { if ( subsenquentNode . equals ( source ) ) { return false ; } queue . add ( subsenquentNode ) ; } } return true ; }
Whether an edge can be successfully added(source -> target) need to determine whether the DAG has cycle
 @param source     node of origin
 @param target     node of destination
 @param createable whether to create a node
Whether an edge can be successfully added ( source - > target ) need to determine whether the DAG has cycle @param source node of origin @param target node of destination @param createable whether to create a node
// whether an egde can be sucessfully added(from-to), need determine whether the DAG has cycle. // if DAG doesn't find source, it's not has cycle