Lecture 24 — Graphs as Models

Position in the course

This is lecture 24 of 32. It belongs to the course arc described in the course outline and uses the standard interactive case method: display, attempt (5 minutes), discuss, reveal, name the technique.

Learning objectives

By the end of this lecture students can do all three under time pressure, which is what the four cases exercise.

Prerequisite knowledge

Before this lecture: Lectures 13 and 17 — dictionaries and scans

Assumed fluencies:

Preparation task: Draw your close friends as a 'knows' map; count connection hops to a classmate.

Detailed topic outline

Core (mandatory):

  1. graphs as relationships made explicit
  2. vertices, edges, degree
  3. BFS: levels are distances
  4. topological order for dependencies

Extension (optional enrichment):

  1. modelling choices: what becomes a node
  2. BFS simulation on infection timelines

Case sequence

CaseTitleDifficulty
cs-093The Friend CircleBeginner
cs-094The Campus WalkFoundational
cs-095The Prerequisite ChainIntermediate
cs-096The Epidemic AlarmAdvanced
cs-136The Timetable CollisionAdvanced

Display each case full-screen from the student page (cases cs-093–cs-096); instructor pages cs-093–cs-096 under case-studies/instructor/ hold the full solutions, reveal guides, and discussion prompts. Applied additions cs-136 extend the session as optional extra attempts or homework; they share the lecture's theme but teach an applied, real-world angle.

Timing plan (120 minutes)

MinutesSegment
0–10Framing: where this fits; recall of the previous lecture
10–30Case 1 (cs-093): 5-minute attempt, then discussion and reveal
30–50Case 2 (cs-094): same rhythm
50–70Case 3 (cs-095): same rhythm, harder case
70–75Break
75–100Case 4 (cs-096): same rhythm, hardest case
100–115Synthesis: name the techniques; misconceptions check
115–120Exit questions, homework, next-lecture preview

Timing flexes with the room: if a case ignites the class, let the discussion run and compress the synthesis; if the attempts stall, harvest partial attempts rather than extending the clock.

Worked examples

Instructor demonstration to open the lecture: Friend circle (cs-093) mapped from the room itself: each student names two acquaintances; BFS colours the components live.

Classroom activities

#ActivityMinutesFormat and prompt
1Campus graph build8Rooms and corridors become a graph on the board; shortest paths argued before BFS runs.
2BFS wave simulation7Students as nodes; rumours spread in waves; each wave number is a distance.
3Cycle or order5cs-095's dependency map checked for cycles by hand; the vote precedes the algorithm.

Board plan

Instructor explanation notes

Reading the room. Graphs are sold as the honest model of relationships, not as a new data structure to memorise. Modelling choices (what is a node?) get more airtime than BFS code.

Running the reveal. cs-096 ties simulation and BFS together; it is the Block III synthesis and the direct bridge to Block IV's simulation lecture.

Lecture focus. One sentence to repeat verbatim: Model relationships explicitly; levels are distances.

Common misconceptions

Each case's instructor page lists the specific wrong turn to expect; the reveal should address it by name.

Student practice exercises

Core:

  1. Model cs-093's friend data as an adjacency map; count components by BFS by hand.
  2. Compute the BFS levels for cs-094's campus map from the library.
  3. Check cs-095's prerequisite map for a cycle; produce a valid order if none exists.

Enrichment (optional):

Formative assessment

Exit questions (choose one; answer on a card in 60 seconds):

  1. What is a node in the campus model, and why? Expected: junctions/rooms — decisions and meetings happen there
  1. What does BFS level number mean? Expected: minimum number of steps from the source
  1. When is there no valid ordering in cs-095? Expected: exactly when the prerequisite graph has a cycle

Cards are skimmed before the next lecture; three answers become the framing. Persistent wrong answers route students to the review stations of lecture 16 or to office hours.

Homework and preparation

Learning-outcome mapping

Differentiation