Graph ML: Graph Algorithms

Part 0.5: Traditional Graph Algorithms
AI
Engineering
Graphs
GraphML
Algorithms
Author

Gurpreet Johl

Published

May 8, 2024

The following are standard graph algorithms.

2. Shortest Path Algorithms

We are trying to find the shortest path between two nodes.

2.1. Dijkstra’s Algorithm

Dijkstra’s algorithm maintains

  1. A hash map shortest_distances containing shortest known distances from the starting node to each node visited.
  2. A hash map shortest_path_previous_node tracking the previous node visited on the shortest knonw path to a node.

A nice bonus is that it ends up finding the shortest path from the source node to all other nodes, not just the target node we care about.

Steps:

  1. Initialise: Start at the source node and make it the current_node.
  2. Check the immediate neighbours: If the distance to a neighbor from the source node is shorter than the current known shortest_distances, then update shortest_distances and shortest_path_previous_node.
  3. Visit the new node closest to source: Visit whichever unvisited node has the shortest known distance. Make it the current_node and repeat Step 2.

3. Minimum Spanning Tree

3.1. Kruskal’s Algorithm

3.2. Prim’s Algorithm

4. Further Topics in Graph Theory

  • Tarjan’s strongly connected components algorithm
  • Topological sort
  • Floyd-Warshall algorithms
  • Bellman-Ford algorithm
  • Graph coloring
  • Min-cut max-flow
Back to top