简化随机生成DAG(有向无环图)

根据python随机生成DAG(有向无环图)一文,并且对其代码进行简化.

n= 1000;m = min(5000,n**2); MAXL = 100000;
node = shuffle(range(1000));
while m>0; m -- {
	p1 = ranint(1,n-1);
	p2 = ranint(p1,n);
	x = node[p1-1];
	y = node[p2-1];
	l = ranint(MAXL);
	w = ranint(1,1000);
}
//以下是随机生成的数据格式.
 x   y    l    w
 -----------------
 |   |    |    |
 x1  y1   l1  w1
 ......
 ......
 ......
 xm  ym   lm  wm //m是长度.
 ---------------------------------------------
   q
 -----
   |
   q1  //ranint(1,1000)
   q2  //ranint(1,1000)
   ...
   ...
   qk  //k <= ranint(1000)k是长度.
 -----
 

你可能感兴趣的:(简化随机生成DAG(有向无环图))