Graph

A graph is a collection of nodes that are connected to each other by edges. Edges can be either directed (one-way) or undirected and they can also have weights (values). A tree can be considered an undirected graph with no cycles.

Operation Big-O
Depth-first search O(N + E)
Breadth-first search O(N + E)
Topological sort O(N + E)

N being number of nodes and E being number of edges

Graph representation

Corner cases

Graph traversal and sorting

References