Graph

Context: FIT1058_MOC · an abstract model of a network · a set of vertices plus edges · adjacency is a relation on vertices · FIT2004_MOC · the W5 data structure everything else reduces to — see Graph Representations, Uninformed Search (BFS and DFS), Dijkstra’s Algorithm

Quick Revision

  • 🎯 Objective: : vertices + edges ➔ models which pairs interact; add direction and weight and it models cost, order and flow.
  • 📦 Core Components: adjacency () ➔ incidence ➔ isolated/leaf vertices ➔ and the sparse/dense split.
  • ⚡ Key Constraint: adjacency is a symmetric irreflexive Binary Relation in the undirected case only; specify both and , and say whether the graph is directed and weighted before quoting any bound.

📝 Core

1. The Graph, Adjacency and Incidence

  • Definition ➔ ; vertices, edges (unordered pairs of distinct vertices) — models the structure of interactions, discarding all else.
  • Adjacent ➔ iff (vertex–vertex) · incident ➔ vertex is an endpoint of an edge (vertex–edge).
  • Special vertices ➔ isolated = in no edge (degree ) · leaf = in exactly one edge (degree ).

2. FIT2004 Formal Definitions (W5)

  • Edge ➔ ; directed ⟹ the edge runs from to ; weighted ⟹ and the graph is written .
  • Simple graph ➔ no self-edges and no multi-edges — the default assumption in every FIT2004 algorithm (Types of Graphs).
  • Vertex node, edge link ➔ both naming pairs appear in the slides; treat them as synonyms.
  • Everything reduces to a graph ➔ a Tree is a graph, a database is a graph, and problems such as longest common subsequence are solved by building a DAG — the transferable move is modelling the problem as , not memorising an algorithm (LO1).
  • A Tree as a graph ➔ the root is the single vertex with no incoming edge; a binary tree caps out-degree at ; and there is no cycle.

3. Size Properties and the Sparse/Dense Split

  • Notation ➔ vertices, edges; bounds are written in and with the bars dropped.
  • Maximum edges ➔ directed · undirected — the halving is a constant factor, so both are .
  • Sparse ➔ (typically ) · dense ➔ .
  • Why it matters ➔ this one classification decides the representation, collapses into for Dijkstra’s Algorithm, and decides whether a Fibonacci heap is worth its constants.
  • Worked example ➔ the World Wide Web: pages are vertices, hyperlinks edges, PageRank a traversal propagating authority — a huge, extremely sparse graph.

⚖️ Core Decision Matrix

TermRelatesExample
adjacency vertex–vertex
incidencevertex–edge in
isolateddegree 0
leafdegree 1

When It Flips: adjacency is a symmetric, irreflexive Binary Relation on — the bridge to relation theory; Connectivity turns the walk relation into an Equivalence Relation. Graphs here are simple unless stated (Types of Graphs). Direction breaks the symmetry; weight breaks the "one hop one unit" assumption that BFS rests on.

📊 Exam Execution Trace

Manual Execution Trace

:

Step / StateQueryAnswer
0 (Init)——
1neighbours of
2edges incident with
3classify isolated

Applied Exercise

Problem: a simple undirected graph has vertices and edges. Sparse or dense, and what follows?

Final Extracted Output: sparse () ➔ store it as an adjacency list at rather than a matrix at , and quote Dijkstra as rather than collapsing to .

⚠️ Common Mistakes

  • 💡 Must give both and ➔ an isolated vertex leaves no trace in the edge list; in the undirected case edges are sets, so no vertex is adjacent to itself.
  • 💡 Treating as “dense means directed” ➔ directed and undirected maxima differ only by ; density is about how many possible edges are actually present.

🧠 Active Recall