Graph definitions — directed, undirected, weighted, unweighted, simple, multigraph
WHAT is a graph?
WHY this abstraction? Because relationships are everywhere: friends on a social network, cities linked by roads, web pages linked by hyperlinks, tasks that depend on other tasks. A graph strips away the specifics and keeps only "who is connected to whom", so one set of algorithms (BFS, Dijkstra, ...) solves thousands of different real problems.

The four independent "switches"
Think of a graph type as four on/off switches. They are independent — you can mix them freely (e.g. a directed weighted multigraph).
Switch 1 — Directed vs Undirected
WHY it matters: a Facebook friendship is mutual → undirected. A Twitter "follow" is one-way → directed. On a directed graph you can be able to go but not .
Switch 2 — Weighted vs Unweighted
WHY: "How many hops to my friend?" ignores weight (unweighted, BFS). "Cheapest flight route?" needs weight (Dijkstra). Treating an unweighted graph as weighted is fine — just set every weight .
Switch 3 — Self-loops allowed?
Switch 4 — Parallel edges allowed?
WHY a multigraph? Two cities can genuinely have two different roads between them, each with its own length. A simple graph would force you to keep only one — losing information.
HOW MANY edges can a graph have? (Derivation, not memorisation)
Simple undirected graph — max edges
Derive it from scratch — WHY:
- An edge is an unordered pair of distinct vertices (no self-loops → distinct; simple → at most one).
- So counting max edges = counting how many ways to choose 2 vertices out of .
- Number of ways to pick the first vertex: . The second (different): . That gives ordered pairs.
- But and are the same undirected edge → we double-counted. Divide by 2.
- Result: . ∎
Simple directed graph — max edges
WHY: now , so we don't divide by 2. Each of vertices can point to each of the other vertices → .
Sum-of-degrees (Handshake Lemma)
Derive — WHY: when you add up degrees over all vertices, each edge is counted twice — once at and once at . So the total is exactly twice the number of edges. ∎ (Corollary: the number of odd-degree vertices is always even.)
Recall Feynman: explain to a 12-year-old
Imagine dots that are your friends, and you draw a line whenever two of them know each other. That whole drawing is a graph.
- If "knowing" goes both ways (friends), draw a plain line — undirected.
- If it's one-way ("I follow her, she doesn't follow me"), draw an arrow — directed.
- If some friendships are stronger, write a number on the line — weighted.
- Simple means: no friend is friends with themselves (no self-loop), and you never draw two lines between the same pair. If you do draw two lines (maybe two different roads between two towns), it's a multigraph. That's it — the rest of "graph theory" is just clever ways to walk along these lines.
Flashcards
What two sets define a graph ?
Difference between a directed and an undirected edge?
What is a weighted graph?
Define a self-loop.
What are parallel edges?
Define a simple graph.
Define a multigraph.
Max edges in a simple undirected graph on vertices?
Why divide by 2 for undirected max edges?
Max edges in a simple directed graph (no self-loops)?
State the Handshaking Lemma.
Corollary of the handshake lemma about odd degrees?
How do you model one undirected edge with directed edges?
What is ?
For directed graphs, what replaces degree?
Connections
- Graph representations — adjacency list vs matrix (how these definitions are stored)
- BFS — breadth first search (shortest path on unweighted graphs)
- Dijkstra's algorithm (shortest path on weighted, non-negative graphs)
- Topological sort (only on directed acyclic graphs)
- Complete graph $K_n$ and dense vs sparse graphs
- Handshaking lemma and degree sequences
- Trees as special graphs (connected, acyclic, )
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Graph ka matlab simple hai: dots aur unko jodne wali lines. Dots ko hum vertices (nodes) bolte hain aur lines ko edges. Bas itna hi base hai — baaki saare fancy words sirf yeh batate hain ki line kaisi behave karti hai. Yaad rakho formula , jahan vertices ka set hai aur edges ka set.
Char "switches" se graph ka type decide hota hai (mnemonic DWSP). Direction: line plain hai (undirected, dono taraf chalti hai jaise Facebook friend) ya arrow wali (directed, ek taraf jaise Twitter follow). Weight: line par koi number likha hai (weighted — cost, distance) ya nahi (unweighted, sab edges barabar). Self-loop: koi vertex apne aap se juda hai kya? Parallel edges: ek hi pair ke beech do lines? Agar self-loop aur parallel dono nahi hain to graph simple hai; agar parallel allowed hain to multigraph.
Max edges samajhna important hai. Simple undirected mein — divide by 2 isliye kyunki edge aur ek hi cheez hai (ek handshake do logon ka, par count ek). Directed mein divide nahi karte, , kyunki aur alag arrows hain. Aur handshaking lemma: sab degrees ka sum , kyunki har edge apne dono endpoints par ek-ek baar count hota hai.
Yeh definitions kyun zaroori? Kyunki real problems — Google Maps roads, social networks, task dependencies — sab graphs hain. Agar tumne type galat samajh liya (jaise undirected ko directed treat kiya, ya weights ignore kiye), to tum galat algorithm lagaoge: BFS unweighted ke liye, Dijkstra weighted ke liye, topological sort sirf directed acyclic ke liye. Toh pehle type pehchano, phir algorithm chuno.