Skip to content

Commit 52b4475

Browse files
committed
fixes. up to ring graph
1 parent 21da0bb commit 52b4475

13 files changed

+76
-50
lines changed

docs/algorithms.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ When stuck at:
658658

659659
Basically, "*Calling a function inside of itself*"
660660

661-
<img src="images/Pasted image 20220324205607.png" alt="Pasted image 20220324205607">
661+
![Recursive Serpinski triangle](images/Pasted image 20220324205607.png){width=200}
662662

663663
Requirements:
664664

@@ -740,7 +740,7 @@ Where:
740740
741741
Also, another geometric time complexity is a decision tree, where it expands in $2^n$ time
742742
743-
<img src="images/Pasted image 20220803103031.png" alt="Pasted image 20220803103031">
743+
<img src="images/Pasted image 20220803103031.png" alt="Pasted image 20220803103031" width=300px>
744744
745745
Another example is $T(n) = T(n/3) + T(2n/3) + n$. I just need to note that:
746746
- Asymptotic height of tree is longest term -> $T(2n/3)$
@@ -763,6 +763,12 @@ $${PR(A)={\frac {PR(B)}{2}}+{\frac {PR(C)}{1}}+{\frac {PR(D)}{3}}}$$
763763
764764
!!! info
765765
766+
Cool historical and general technical explanation. Only a few minutes:
767+
768+
<iframe width="560" height="315" src="https://www.youtube.com/embed/KZeIEiBrT_w?si=9LRXiCsQumdq3cWe&amp;start=1147" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
769+
770+
Technical video:
771+
766772
<iframe width="560" height="315" src="https://www.youtube.com/embed/qxEkY8OScYY?si=rg-kzamjXyxP05DI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
767773
768774
##### Damping factor
@@ -842,7 +848,7 @@ State the proposition, say "the proof is by contradiction", then contradict your
842848
843849
### Axioms
844850
845-
<img src="images/Pasted image 20220905092544.png" alt="Pasted image 20220905092544">
851+
<img src="images/Pasted image 20220905092544.png" alt="Pasted image 20220905092544" width=300px>
846852
847853
- As classically conceived, an axiom is a premise so evident as to be accepted as true without controversy
848854
@@ -1202,11 +1208,11 @@ Examples:
12021208
<img src="images/Pasted image 20220820151008.png" alt="Pasted image 20220820151008" width="300">
12031209
12041210
- Better algorithms are still possible
1205-
- Better algorithms will not provide an improvement detectable by Big O
1211+
- Better algorithms will not provide an improvement detectable by "Big O"
12061212
12071213
### Bisection solve
12081214
1209-
<img src="images/Pasted image 20220713093654.png" alt="Pasted image 20220713093654">
1215+
<img src="images/Pasted image 20220713093654.png" alt="Pasted image 20220713093654" width=400px>
12101216
12111217
Given lower bound $a$ and upper bound $b$, calculate the mid (average) value $c$ and sub into $f(x)$. Then adjust the bounds $a, b$ to move closer to the value closer to $0$.
12121218
@@ -1454,7 +1460,7 @@ As you can see, they are also very sensitive to input 😢
14541460

14551461
Forward propagation is the initial phase of data processing in a neural network. Here, input data is fed into the network and passed through various layers. Each neuron in these layers processes the input and passes it to the next layer, ultimately leading to the output layer. This process is linear and straightforward, moving in one direction: from input to output.
14561462

1457-
<img src="images/Pasted image 20240910154731.png" alt="Pasted image 20240910154731">
1463+
<img src="images/Pasted image 20240910154731.png" alt="Pasted image 20240910154731" width=400px>
14581464

14591465
[source](https://stackademic.com/blog/the-difference-between-back-propagation-and-forward-propagation-in-deep-learning-2b2248e6d00c)
14601466

docs/graphs.md

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ The neighbourhood of a vertex $v$ is the set of vertices adjacent to $v$.
5252

5353
#### Order
5454

55-
Number of [vertices](#nodes) a graph has
55+
The number of [vertices](#nodes) in a graph.
5656

5757
### Edges
5858

59-
Edges are the lines in-between [Nodes](#nodes) that display a connection between nodes.
59+
Edges are the lines in-between [nodes](#nodes) that display a connection between nodes.
6060
Edges represent connections, relations or any logical path.
6161

6262
- We denote the edge set of a graph $G$ by $E(G)$
@@ -77,7 +77,7 @@ If the vertex $u$ is connected to $e$; $e$ is an edge incident to $u$
7777

7878
A loop is an edge that has the same starting and ending [node](#nodes). See node 1 below:
7979

80-
<img src="images/Pasted image 20220222181219.png" alt="Pasted image 20220222181219">
80+
<img src="images/Pasted image 20220222181219.png" alt="Pasted image 20220222181219" width=300px>
8181

8282
### Paths
8383

@@ -89,27 +89,28 @@ A path can contain many edges, or a single. it depends on what nodes are being s
8989

9090
!!! note
9191

92-
- [Euler paths](#euler-path) and [Euler circuits](#euler-circuit):
93-
- Can pass through [nodes](#nodes) more than once.
94-
- Don't exist if a graph has more than two vertices of odd degree.
95-
- Exists if all vertices of a graph have even degree.
96-
- Exists if a connected graph has exactly two odd vertices. The starting point must be one of the odd vertices and the ending point will be the other of the odd vertices.
97-
98-
- [Hamiltonian Paths](#hamiltonian-path)
99-
- Don't have to traverse every [edge](#edges)
92+
- Check out [Euler paths](#euler-path) and [Euler circuits](#euler-circuit):
93+
- Check out [Hamiltonian Paths](#hamiltonian-path)
10094

10195

10296
#### Euler Path
10397

10498
A [path](#paths) that uses each [edge](#edges) once only without returning to starting [vertex](#nodes) is an Euler path.
10599

106-
- Uses each **edge** once
100+
![euler path](images/euler-path.png)
101+
107102
- Doesn't return to starting vertex
103+
- Can pass through [nodes](#nodes) more than once.
104+
- Don't exist if a graph has more than two vertices of odd degree.
105+
- Exists if all vertices of a graph have even degree.
106+
- Exists if a connected graph has exactly two odd vertices. The starting point must be one of the odd vertices and the ending point will be the other of the odd vertices.
108107

109108
#### Euler circuit
110109

111110
A [path](#paths) that uses each [edge](#edges) once only and returns to starting [vertex](#nodes) is an Euler circuit.
112111

112+
![euler circuit](images/euler-circuit.png)
113+
113114
If an undirected graph $G$ is connected and every vertex (not isolated) in $G$ has an even degree, then $G$ has an Euler circuit.
114115

115116
- Uses each **edge** once
@@ -119,15 +120,24 @@ If an undirected graph $G$ is connected and every vertex (not isolated) in $G$
119120

120121
A [path](#paths) that passes every [vertex](#nodes) exactly once without returning to starting [vertex](#nodes) is an Hamiltonian path.
121122

123+
![hamiltonian path](images/hamiltonian-path.png)
124+
122125
- Uses every **node** once
123126
- Doesn't return to starting node
127+
- Don't have to traverse every [edge](#edges)
124128

125129
#### Hamiltonian Circuit
126130

127131
!!! note
128132

129133
This is used very often in this course. See [Travelling salesmen problem](algorithms.md#travelling-salesmen-problem)
130134

135+
!!! important
136+
137+
A [cycle](#cycle) and a [circuit](#circuit) are different. But the properties of both Hamiltonian cycles and Hamiltonian circuits are the same. Hence they reffer to the same thing.
138+
139+
![Hamiltonian circuit](images/hamiltonian-circuit.png){width=300px}
140+
131141
A [path](#paths) that passes every [vertex](#nodes) exactly once and returns to the starting [vertex](#nodes) is an Hamiltonian path.
132142

133143
- Uses every **node** once
@@ -145,16 +155,28 @@ Is there a path from $A$ to $B$ ?
145155

146156
The transitive closure of a graph is a graph which contains an edge between $A$ and $B$ whenever there is a directed path from $A$ to $B$. In other words, to generate the transitive closure every path in the graph is directly added as an additional edge.
147157

148-
<img src="images/Pasted image 20220321094104.png" alt="Pasted image 20220321094104">
158+
<img src="images/Pasted image 20220321094104.png" alt="Pasted image 20220321094104" width=300px>
149159

150160
A graph $G^*$ which is the transitive closure of $G$ will have a directed edge to every node it can traverse to.
151161

162+
163+
### Undirected Graphs
164+
165+
![undirected graph](images/undirected-graph.png){width=200}
166+
167+
Undirected graphs have [edges](#edges) that can be travelled along in any direction.
168+
152169
### Directed Graph
153170

154171
Also known as a digraph.
155-
A digraph is an ordered pair [G = (V, E)](#graph) of [edges](#edges) $(x,y)$ of arrows "from $x$ to $y$".
172+
173+
![directed graph](images/directed-graph.png){width=200}
174+
175+
Bassically just the same as a regular [undirected graph](#undirected-graphs), but the edges have arrows (direction).
176+
Formally, a digraph is an ordered pair [G = (V, E)](#graph) of [edges](#edges) $(x,y)$ of arrows "from $x$ to $y$".
156177

157178
Where:
179+
158180
- $x$:
159181
- Is the tail
160182
- Is the direct predecessor of $y$
@@ -168,11 +190,7 @@ If a [path](#paths) leads from $x$ to $y$, then $y$ is said to be a successor of
168190

169191
A directed graph $G$ is strongly connected if there is a directed path from every vertex to every other vertex in $G$.
170192

171-
<img src="images/Pasted image 20220222220031.png" alt="Pasted image 20220222220031">
172-
173-
### Undirected Graphs
174-
175-
Undirected graphs have [edges](#edges) that can be travelled along in any direction.
193+
<img src="images/Pasted image 20220222220031.png" alt="Pasted image 20220222220031" width=500px>
176194

177195
### Dag / DAGS
178196

@@ -232,7 +250,7 @@ Similarity = 0 if $X \neq Y$
232250

233251
!!! warning
234252

235-
writing this in 2025. Never seen cosine simularity anywhere. dw about it
253+
I have never seen cosine simularity anywhere. Don't worry too much about it
236254

237255
Best example in the world:
238256

@@ -248,7 +266,7 @@ For unweighted graphs, each edge has a nominal distance of 1.
248266

249267
#### Euclidian distance
250268

251-
Is also known as simply distance
269+
The most commonly understood distance metric
252270

253271
Euclidean Distance is the straight line distance between two entities. Which is worked out using **Pythagoras Theorem**
254272

@@ -262,7 +280,8 @@ In a simple way of saying it is the total sum of the difference between the x-co
262280

263281
The [heuristic function](#heuristic-functions) for distance calculation
264282

265-
$$f(n) = |\text{cell}_{row} – \text{goal}_{row}| + |\text{cell}_{col} – \text{goal}_{col}|$$
283+
{# idk why but the latex didn't render for this. So just rasterized it instead #}
284+
![distance-heuristic](images/distance-heuristic.png)
266285

267286
Which is the absolute cell distance in the $x$ direction plus the absolute cell distance in the $y$ direction. The absolute value is always positive.
268287

@@ -279,9 +298,9 @@ Also known as a topological ordering
279298

280299
In computer science a **topological sort** or **topological ordering** of a [Directed Graph](#directed-graph) is a linear ordering of its [vertices](#nodes) such that for every directed edge _uv_ from vertex _u_ to vertex _v_, _u_ comes before _v_ in the ordering.
281300

282-
A topological ordering is possible iff the graph has no directed cycles, that is, if it is a directed acyclic graph ([Dag DAGS](#dag-dags)).
301+
A topological ordering is possible iff the graph has no directed cycles, that is, if it is a directed acyclic graph ([Dag - DAGS](#dag-dags)).
283302

284-
<img src="images/Pasted image 20220310113016.png" alt="Pasted image 20220310113016">
303+
<img src="images/Pasted image 20220310113016.png" alt="Pasted image 20220310113016" width=400px>
285304

286305
The graph shown above has many valid topological sorts, including:
287306

@@ -302,7 +321,7 @@ This can be calculated through [Kahn's Algorithm](#kahns-algorithm)
302321

303322
A [Topological sort](#topological-sort) algorithm, first described by **Kahn** (1962), works by choosing vertices in the same order as the eventual topological sort. First, find a list of "start nodes" which have no incoming edges and insert them into a set $S$; at least one such node must exist in a non-empty acyclic graph. Then:
304323

305-
```js
324+
```js title="Kahn's Algorithm in psuedocode"
306325
L ← Empty list that will contain the sorted elements
307326
SSet of all nodes with no incoming edges
308327

@@ -319,11 +338,13 @@ else
319338
return L (a topologically sorted order)
320339
```
321340

322-
### Graph Diameter
341+
### Graph Diameter and radius
323342

324343
!!! note
325344

326-
Note that the **diameter** is the max graph ecentricity. The radius of the graoh requires a center point to be defined
345+
Note that the **diameter** is the max graph ecentricity. The radius of the graph requires a center point to be defined
346+
347+
![graph radius and diameter example](images/radius-diamater-example1.png)
327348

328349
The longest shortest path between any two nodes counted by edge and weights.
329350

@@ -337,11 +358,12 @@ The examples below have a diameter of 2 (2 edges to traverse to get from a to b)
337358

338359
<img src="images/Pasted image 20220303114136.png" alt="Pasted image 20220303114136">
339360

340-
<img src="images/Pasted image 20220919214414.png" alt="Pasted image 20220919214414">
361+
Example:
362+
363+
<img src="images/Pasted image 20220919214414.png" alt="Pasted image 20220919214414" width=400px>
341364

342365
*Note that the radius and diameter is counted by the number of edges
343366

344-
---
345367

346368
## Network graphs
347369

@@ -374,13 +396,13 @@ We can then obtain $H$ from $G$ by deleting edges and or vertices from $G$.
374396

375397
#### Simple graph
376398

377-
A simple graph, also called a strict graph is **an unweighted, undirected graph containing no graph loops or multiple edges**.
399+
A simple graph, also called a strict graph is **an unweighted, [undirected graph](#undirected-graphs) containing no graph [loops](#loops) or multiple edges**.
378400

379-
A simple graph may be either connected or disconnected. Unless stated otherwise, the unqualified term "graph" usually refers to a simple graph.
401+
A simple graph may be either connected or [disconnected](#disconnected-graph). Unless stated otherwise, the unqualified term "graph" usually refers to a simple graph.
380402

381403
<img src="images/Pasted image 20220222144711.png" alt="Pasted image 20220222144711">
382404

383-
For simple [**connected graphs**](#connected-graph) the amount of edges you can have are striclty bounded by:
405+
For simple [**connected graphs**](#connected-graph) the amount of edges you can have are striclty bounded. The number of edges will always be between the arrangement of a [tree](#trees) or a [complete graph](#complete-graphs):
384406

385407
$$
386408
\overset{\text{(trees)}}{(|V|-1)}
@@ -391,20 +413,24 @@ $$
391413

392414
#### Multigraph
393415

416+
![multigraph](images/multigraph.png){width=300px}
417+
394418
A graph that can have multiple edges between the same pair of nodes. In a road network this could, for example, be used to represent different routes with the same start and end point.
395419

396420
#### Connected Graph
397421

422+
![connected vs disconnected graphs](images/connected-vs-disconnected-graphs.png){width=500px}
423+
398424
A graph where all [nodes](#nodes) are connected
399425

400426
##### Ring Graph
401427

402-
Also known as a Cycle Graph
428+
Also known as a [Cycle](#cycle) Graph
403429
A graph that forms a ring
404430

405-
- All nodes have a degree of 2
431+
- All nodes have a [degree](#degree) of 2
406432

407-
<img src="images/Pasted image 20220222220633.png" alt="Pasted image 20220222220633">
433+
<img src="images/Pasted image 20220222220633.png" alt="Pasted image 20220222220633" width=300px>
408434

409435
#### Disconnected Graph
410436

63.6 KB
Loading

docs/images/directed-graph.png

8.6 KB
Loading

docs/images/distance-heuristic.png

2.14 KB
Loading

docs/images/euler-circuit.png

90.9 KB
Loading

docs/images/euler-path.png

91.4 KB
Loading
24.1 KB
Loading

docs/images/hamiltonian-path.png

84.8 KB
Loading

docs/images/multigraph.png

139 KB
Loading

0 commit comments

Comments
 (0)