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?
Throwing bricks to attract good news
rand()
generates an integer between0
andRAND_MAX
, thenp*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?