3.5.1 · D5Graphs

Question bank — Graph definitions — directed, undirected, weighted, unweighted, simple, multigraph

1,465 words7 min readBack to topic

Vocabulary recap before you start (so no symbol is unexplained):

Recall The symbols used on this page
  • = the set of vertices (dots). = how many dots.
  • = the set of edges (lines). = how many lines.
  • = an undirected edge (a plain line, both ways).
  • = a directed edge / arc (an arrow pointing only).
  • = degree = number of edge-ends touching vertex (a self-loop adds ).
  • = "number of ways to pick dots out of ".

True or false — justify

Directed graphs always have twice as many edges as the same undirected graph.
False in general. Modelling one undirected edge as two arcs does double the count, but a directed graph is defined independently — it can have any number of arcs, including just one, so no fixed "twice" rule holds.
An undirected edge and the pair of arcs are the same object.
False. They are the same connectivity but not the same object: the undirected version is one edge, the directed pair is two edges, so differs and your adjacency list stores different counts.
A simple graph must have few edges.
False. "Simple" is a rule (no self-loops, no parallel edges), not a size. A simple graph can be the dense complete graph $K_n$ with edges — the maximum possible.
Every multigraph is also a valid graph.
True. A multigraph just relaxes two rules (allows parallel edges and self-loops); it is still a set of vertices and edges, so it satisfies the general definition .
Every simple graph is also a multigraph.
True. "Multigraph" permits parallel edges and self-loops but does not require them, so a simple graph is the special case where none happen to occur.
Unweighted graphs cannot be used for shortest-path problems.
False. An unweighted graph is a weighted graph with every weight ; plain BFS finds shortest paths on it, and faster than Dijkstra because all edges cost the same.
In an undirected graph, can be larger than .
True only if the graph is not simple. In a simple undirected graph the max degree is (connect to every other vertex), but self-loops or parallel edges push a multigraph's degree higher.
The handshaking lemma holds only for connected graphs.
False. It holds for every undirected graph, connected or not, because it counts edge-ends and each edge contributes exactly ends regardless of connectivity.
A graph with an odd number of odd-degree vertices can exist.
False. Since is even, the odd-degree contributions must sum to something even, which forces the count of odd-degree vertices to be even.
Weighted edges must be positive numbers.
False. Weights can be zero or negative (e.g. money gained). The definition allows any number; only specific algorithms (like Dijkstra) additionally require non-negative weights.
Adding a self-loop to a simple graph keeps it simple.
False. A self-loop is exactly one of the two things "simple" forbids, so the graph immediately becomes a multigraph.
A directed graph can have both and and still be simple.
True. Simple only bans duplicate identical edges and self-loops; and are two different ordered pairs, so both may coexist in a simple directed graph.

Spot the error

", edges and ; this is a simple graph with ."
Two errors: the repeated is a parallel edge, so it is a multigraph, not simple; and because both edges count.
"Max edges of a simple undirected graph on vertices is ."
That is the directed count. Undirected pairs and are the same edge, so you divide by : .
"A self-loop adds to the vertex's degree."
It adds . Both ends of the loop attach to the same vertex, and degree counts edge-ends, so a self-loop contributes (keeping the handshaking lemma exact).
"This road map has two roads between towns and ; I'll store just one to keep it simple."
Dropping the second road discards real information (different lengths/costs). The correct model is a multigraph that keeps both parallel edges; "simple" is not a goal to force here.
"Topological sort works on any graph."
It only works on directed graphs (and specifically ones with no directed cycles). See Topological sort — an undirected edge has no "before/after", so ordering is undefined.
"In a directed graph, is a single well-defined number."
Ambiguous/wrong. Directed vertices have two degrees: in-degree (arrows in) and out-degree (arrows out); a single is not defined without saying which.

Why questions

Why do we divide by for undirected max edges but not for directed?
Because an undirected edge is an unordered pair, so and are counted twice among ordered choices and must be halved; directed arcs are genuinely distinct, so no halving.
Why is direction the switch that decides whether topological sort even exists?
Topological sort orders vertices so every edge points "forward"; that only makes sense when edges have a forward direction. Undirected edges carry no order, so no such ordering exists.
Why can we always convert an unweighted graph into a weighted one but treating a general weighted graph as unweighted loses information?
Setting all weights to is a valid, information-preserving special case; but flattening distinct weights to erases the costs the algorithm needed, so "cheapest path" collapses into "fewest hops".
Why does the abstraction let one algorithm solve thousands of problems?
It keeps only "who connects to whom" and throws away domain specifics, so friendships, roads, and web links all become the same structure that BFS or Dijkstra can process.
Why does storing an undirected graph as an adjacency list give entries, not ?
Each undirected edge is listed in both 's neighbours and 's neighbours, so every edge appears twice across the adjacency list.
Why is a tree guaranteed to be simple?
A tree is connected and acyclic; a self-loop or a parallel edge would create a cycle, contradicting acyclicity, so neither can appear.

Edge cases

What is when or ?
Both give edges. With or vertex there is no distinct pair to connect, so the maximum (and only) edge count is zero.
Is a single vertex with no edges a valid graph?
Yes. is a legal graph with ; graphs are allowed to have an empty edge set.
Is a graph with vertices but zero edges connected?
Only if it has at most one vertex. With two or more isolated vertices and no edges, no path links them, so it is disconnected — but it is still a perfectly valid graph.
Can a weighted graph have two edges of the same weight between different vertex pairs?
Yes. Weights are just labels on edges; distinct edges may freely share a value, and this does not make them parallel (parallel means same endpoints).
What is the sum of degrees in a graph with ?
Exactly , since . Every vertex is isolated with degree .
Can a directed graph have in-degree and out-degree both zero for a vertex?
Yes — an isolated vertex with no arrows in or out. It still belongs to and is a legitimate part of the directed graph.