You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lecturer sort of switched back and forth between saying paths and cycles and didn't emphasize vertices vs edges hard enough, which was kind of annoying and confusingly inconsistent.
4
+
5
+
Basically, a Eulerian (pronounced Oilerian) path visits every EDGE exactly one time, starting and ending anywhere. A Eulerian cycle visits every EDGE exactly one time, starting and ending at the same node.
6
+
7
+
A Hamiltonian path visits every NODE (VERTEX) exactly one time, starting and ending anywhere. A Hamiltonian cycle visits every NODE exactly one time, starting and ending at the same node.
8
+
9
+
### Algo for Eulerian
10
+
11
+
Possible algo for finding Eulerian paths is:
12
+
13
+
1. Start at any vertex and follow edges until you return back to that vertex.
14
+
2. If you haven't yet seen every edge, then do an unseen edge connected to the node you already visited. Do the same thing.
15
+
3. Once you have seen every edge, combine the paths at the nodes that they have in common.
The shortest path in an unweighted graph is just the path with the fewest number of edges. This is a breadth first search, and whichever one you find first is the shortest one.
4
+
5
+
### Dijkstra's Algorithm
6
+
7
+
Example is for a weighted graph.
8
+
9
+
Greedy algorithm that uses a min priority queue to extract the minimum, queue up paths to other nodes with info on how long they take. Node info gets updated with the lowest path if another lower one is found.
10
+
11
+
Adjacency matrix representation of this weighted graph example:
0 commit comments