Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Graph Algorithms – Shortest Paths and Network Search Cheat Sheet

Graph Algorithms – Shortest Paths and Network Search Cheat Sheet

Back to Mathematics and Algorithms
Updated 2026-05-19
Next Topic: Graph Theory Cheat Sheet

Graph algorithms form the backbone of countless real-world systems β€” from GPS navigation and social networks to compiler design and circuit layout. This cheat sheet covers the full spectrum: graph representations, traversals, shortest-path algorithms (single-source and all-pairs), minimum spanning trees, union-find, topological ordering, cycle detection, strongly connected components, and advanced heuristic search. Entries are ordered from foundational to specialized, and within each table from most-used to most-obscure.

What This Cheat Sheet Covers

This topic spans 12 focused tables and 48 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Graph RepresentationsTable 2: Core Graph TraversalTable 3: Single-Source Shortest PathsTable 4: All-Pairs Shortest PathsTable 5: Minimum Spanning TreesTable 6: Union-Find (Disjoint Set Union)Table 7: Topological OrderingTable 8: Cycle DetectionTable 9: Strongly Connected ComponentsTable 10: Structural Graph AnalysisTable 11: Heuristic and Advanced SearchTable 12: Algorithm Complexity Quick Reference

Table 1: Graph Representations

Before choosing an algorithm, the right data structure determines time and space efficiency. Adjacency lists are the default for sparse graphs; matrices suit dense graphs or when O(1) edge lookup is needed; edge lists are the input format for many sorting-based algorithms like Kruskal's.

RepresentationExampleDescription
Adjacency List
graph = [[] for _ in range(V))
graph[u].append((v, w))
Array of lists where graph[u] stores (neighbor, weight) pairs. Space O(V+E) β€” optimal for sparse graphs. Standard choice for BFS, DFS, Dijkstra, and most traversal algorithms.
Adjacency Matrix
dist = [[INF]*V for _ in range(V)]
dist[u][v] = w
V \times V matrix where dist[u][v] = edge weight or \infty. Space O(V^2) β€” O(1) edge lookup; required for Floyd-Warshall. Wasteful for sparse graphs.

More in Mathematics and Algorithms

  • Geometry Cheat Sheet
  • Graph Theory Cheat Sheet
  • Algebra Cheat Sheet
  • Combinatorics Cheat Sheet
  • Graphs Cheat Sheet
  • Number Theory Cheat Sheet
View all 37 topics in Mathematics and Algorithms