Skip to content

Commit 59bcb0e

Browse files
committed
Fixed more mathematical expressions...
1 parent 3beac8c commit 59bcb0e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/randgraph.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ $$N = \binom{n}{2} = \frac{n!}{2!(n-2)!} = \frac{(n-1)n}{2}$$
2020

2121
and that explains line 2 in the pseudo code.
2222

23-
Then a double for loop starts which produces virtually all the edges in pairs of vertices **(i, j)** in lexicographical order. Before the loops, we define the local variable **t** in line 3, with initial value 0. Every time an iterated edge is selected to be added to the graph, it is written in **E[t]** and then the variable **t** increases by 1.
23+
Then a double for loop starts which produces virtually all the edges in pairs of vertices $(i, j)$ in lexicographical order. Before the loops, we define the local variable $t$ in line 3, with initial value 0. Every time an iterated edge is selected to be added to the graph, it is written in $E_t$ and then the variable $t$ increases by 1.
2424

2525
To decide whether or not to include a node in the graph, do the following
2626
procedure:
2727

28-
first call the rand function to generate a random value from **[0, 1)** and store it in **U**. Then check if **U** is less than **k/N** (see image below).
28+
first call the rand function to generate a random value from $[0, 1)$ and store it in $U$. Then check if $U$ is less than $k/N$ (see image below).
2929

3030
<img src="https://user-images.githubusercontent.com/61196956/162618459-449f9c4d-435e-4c82-9fae-64f918b5cf92.png" width="250">
3131

32-
The probability that **U** is in the interval **[0, k/N]** is **k/N**. Then **E[t]** gets the edge **(i, j)**, **k** is reduced by 1 (because the elements that remain to be filled are reduced by 1) and **t** increases by 1 (as explained before).
32+
The probability that $U$ is in the interval $[0, k/N]$ is $k/N$. Then $E_t$ gets the edge $(i, j)$, $k$ is reduced by 1 (because the elements that remain to be filled are reduced by 1) and $t$ increases by 1 (as explained before).
3333

34-
Then **N** decreases by 1, regardless of whether or not the condition was satisfied, which means that there are 1 less edges to select from.
34+
Then $N$ decreases by 1, regardless of whether or not the condition was satisfied, which means that there are 1 less edges to select from.
3535

36-
Once k becomes 0, the algorithm stops (returns E immediately). There is a case,that at some point N becomes equal to k. When this equality is valid, in the if statement of line 7, we will essentially have **U < 1**, and this is always true, which means that the edge will always be selected.
36+
Once k becomes 0, the algorithm stops (returns E immediately). There is a case,that at some point N becomes equal to k. When this equality is valid, in the if statement of line 7, we will essentially have $U < 1$, and this is always true, which means that the edge will always be selected.
3737

3838
In practice this means that if the remaining edges are equal in number to
3939
the edges that must be contained in E, then all must be chosen necessarily.
@@ -42,7 +42,7 @@ This ensures that the algorithm always provides a valid solution.
4242

4343
### The implementation
4444

45-
The above algorithm is located in the file **src/randgraph.py**. The **createRandomGraph** function contains the actual algorithm. Notice that **E** is not actually global. This was done to make the code easier to be imported into another **.py** script.
45+
The above algorithm is located in the file **src/randgraph.py**. The **createRandomGraph** function contains the actual algorithm. Notice that $E$ is not actually global. This was done to make the code easier to be imported into another **.py** script.
4646

4747
At the end of the file there is block comment with an example. Feel free to uncomment it and test it yourself. Here is an example output:
4848

0 commit comments

Comments
 (0)