Model relationships as nodes and edges; traverse with DFS/BFS and union-find.
A graph models relationships as nodes and edges, which can be directed or undirected, weighted or not. Most graph problems come down to choosing the right traversal — DFS, BFS, or union-find — for what you're trying to find.
Blind 75 (6):
More from Blind 150 (7):