All lessons

Graphs

9 min · PHP examples

Represent nodes and edges with an adjacency list, then traverse to explore connections.

PHP · Graphs0/5 cleared

Enemy 1 of 5

A graph is a set of nodes (vertices) and edges between them. An adjacency list maps each node to its neighbors, perfect for sparse graphs and interview problems.

Once you have adjacency, BFS and DFS from a start node count reachable nodes, detect cycles, or find paths.

You
Memory-Leak Rat
Loading editor…
Sign up to fightThis one runs on our servers, so it needs a free account.

Stuck? Ask Rena

Your AI tutor that gives assistance.

Asking Rena in lessons is on Ultimate.