Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Graphs Lab
Graphs
Concept shape
Core
Definition
A graph models relationships between nodes using edges.
Step 1 / 5
Concept shape
Graphs Core
Graphs
Welcome to the Graphs concept lab. A graph represents things as nodes and relationships as edges. The same idea can model friends in a social network, cities connected by roads, web pages connected by links, or dependencies between services. Graph problems usually start by choosing a representation, then carefully tracking visited nodes so traversal does not loop forever. The must know points are: Graphs can be directed or undirected. Edges can be weighted or unweighted. Visited tracking prevents loops. The common operations are: add node, add edge, traverse neighbors. The complexity shape is Traversal O(V + E). Watch out for these pitfalls: Not marking visited. Confusing directed and undirected edges. Related algorithms include BFS, DFS, Dijkstra Shortest Path.
Concept details
A graph represents things as nodes and relationships as edges.
The same idea can model friends in a social network, cities connected by roads, web pages connected by links, or dependencies between services.
Graph problems usually start by choosing a representation, then carefully tracking visited nodes so traversal does not loop forever.
Must know
- Graphs can be directed or undirected.
- Edges can be weighted or unweighted.
- Visited tracking prevents loops.
Complexity
Traversal O(V + E)
1.0x