Exemplo n.º 1
0
 public static Digraph randomizeAcyclic(
     Digraph digraph, int order, int incomingSize, int outgoingSize, Random randomizer) {
   Random random = randomizer;
   int arc = 1;
   for (int i = 1; i <= order; i++) {
     Integer destination = new Integer(i);
     digraph.addVertex(destination);
     for (int j = 0; j < incomingSize; j++) {
       int org = random.nextInt(i);
       if (org == 0) continue;
       Integer origin = new Integer(org);
       if (digraph.outgoingSize(origin) >= outgoingSize) continue;
       digraph.putArc(origin, destination, new Integer(arc++));
     }
   }
   return digraph;
 }