c++ - if(rand()<p*RAND_MAX) 是在做什么筛选?
PHP中文网
PHP中文网 2017-04-17 15:02:57
0
2
1079
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
左手右手慢动作

Throwing bricks to attract good news

rand() generates an integer between 0 and RAND_MAX, then p*RAMD_MAX is equivalent to a threshold. When the "dice roll" is lower than the threshold, the two points currently iterated to are connected. .

小葫芦

The relationship between the number of edges and the number of points in the complete graph is: E = V (V-1) / 2, that is, each point has edges connected to the remaining V-1 points, and p is the probability, satisfying Linear (the larger the required number of edges, the greater the probability, the more likely there is an edge connecting two points, and the closer the graph is to a complete graph). Assuming that rand() returns between [0, RAND_MAX], then p=0 when E is 0, and p=1 when E is V(V-1)/2. Determine whether the current (i, j) is directly connected based on the randomly generated rand. But is this a directed graph?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template