Graph Fundamentals & Terminology Resource - aloalgo

Graph Fundamentals & Terminology

A graph is a collection of nodes (vertices) connected by edges. Graphs model relationships: social networks, maps, dependencies, and more.

Basic Terminology

TermDefinition
Vertex (Node)A point in the graph
EdgeA connection between two vertices
NeighborA vertex directly connected by an edge
DegreeNumber of edges connected to a vertex
PathA sequence of vertices connected by edges
CycleA path that starts and ends at the same vertex

Types of Graphs

Directed vs Undirected

Weighted vs Unweighted

Cyclic vs Acyclic

Connected vs Disconnected

Common Graph Types

TypeDescriptionExample
TreeConnected, acyclic graphFile system, org chart
DAGDirected acyclic graphTask dependencies
BipartiteVertices split into two setsMatching problems
CompleteEvery vertex connected to all othersTournament brackets

Graphs in Interviews

Many problems are graphs in disguise:
  • 2D grids: Each cell is a vertex, adjacent cells are neighbors
  • Word transformations: Each word is a vertex, edges connect words that differ by one letter
  • State machines: Each state is a vertex, transitions are edges
  • Social networks: People are vertices, friendships are edges

Key Questions to Ask

When you see a graph problem, ask:
  1. Directed or undirected? Can you go both ways?
  2. Weighted or unweighted? Do edges have costs?
  3. Can there be cycles? Or is it a DAG/tree?
  4. Is it connected? Or multiple components?
Was this helpful?
© 2026 aloalgo. All rights reserved.