src/main/java/org/thegalactic/dgraph/DGraphFactory.java
public ConcreteDGraph<Integer, ?> random(final int size, final double threshold) {
        final ConcreteDGraph<Integer, ?> graph = new ConcreteDGraph<Integer, Object>();
        // addition of nodes
        for (int i = 1; i <= size; i++) {
            final Node<Integer> node = new Node<Integer>(i);
            graph.addNode(node);
        }
        // addition of edges
        for (final Node<Integer> source : graph.getNodes()) {
            for (final Node<Integer> target : graph.getNodes()) {
                if (Math.random() < threshold) {
                    graph.addEdge(source, target);
                }
            }
        }
        return graph;
    }
/**
     * Generates a random directed graph of size nodes.
     *
     * @param size      the number of nodes of the generated graph
     * @param threshold the threshold to generate an edge
     *
     * @return a random graph
     */
Generates a random directed graph of size nodes.
@param size      the number of nodes of the generated graph
@param threshold the threshold to generate an edge

@return a random graph
Generates a random directed graph of size nodes . @param size the number of nodes of the generated graph @param threshold the threshold to generate an edge @return a random graph
public ConcreteDGraph<Integer, ?> random(final int size, final double threshold) {
        final ConcreteDGraph<Integer, ?> graph = new ConcreteDGraph<Integer, Object>();
        for (int i = 1; i <= size; i++) {
            final Node<Integer> node = new Node<Integer>(i);
            graph.addNode(node);
        }
        for (final Node<Integer> source : graph.getNodes()) {
            for (final Node<Integer> target : graph.getNodes()) {
                if (Math.random() < threshold) {
                    graph.addEdge(source, target);
                }
            }
        }
        return graph;
    }
public ConcreteDGraph < Integer , ? > random ( final int size , final double threshold ) { final ConcreteDGraph < Integer , ? > graph = new ConcreteDGraph < Integer , Object > ( ) ; for ( int i = 1 ; i <= size ; i ++ ) { final Node < Integer > node = new Node < Integer > ( i ) ; graph . addNode ( node ) ; } for ( final Node < Integer > source : graph . getNodes ( ) ) { for ( final Node < Integer > target : graph . getNodes ( ) ) { if ( Math . random ( ) < threshold ) { graph . addEdge ( source , target ) ; } } } return graph ; }
Generates a random directed graph of size nodes.
Generates a random directed graph of size nodes .
// addition of nodes // addition of edges