Graph Representations

Context: FIT1058_MOC Β· symbolic ways to store a Graph in memory Β· edge list, adjacency matrix, adjacency list, incidence matrix Β· trade space against access

Quick Revision

  • 🎯 Objective: store a Graph symbolically for algorithms βž” four standard encodings.
  • πŸ“¦ Core Components: edge list βž” adjacency matrix βž” adjacency list βž” incidence matrix.
  • ⚑ Key Constraint: matrix = bits, test; list = compact for sparse graphs.

πŸ“ Core

1. The Four Representations

  • Edge list βž” set of edges (+ , else isolated vertices vanish).
  • Adjacency matrix βž” bit array, iff ; symmetric, zero diagonal.
  • Adjacency list βž” per vertex, its neighbours (; empty).
  • Incidence matrix βž” bit array, iff vertex is an endpoint; each column has two s.

2. What the Structure Encodes

βš–οΈ Core Decision Matrix

RepresentationSpaceAdjacency testBest for
adjacency matrixdense
adjacency listsparse
edge list + scancompact
incidence matrixβ€”proofs

When It Flips: the adjacency matrix is the Binary Relation's matrix over ; row/column sums are degrees, total s . Sparse real graphs favour the list; the incidence matrix is mostly theoretical.

πŸ“Š Exam Execution Trace

Manual Execution Trace

Rows for (order –):

Step / StateVertexRowDegree
0 (Init)β€”β€”β€”
12
23
30

⚠️ Common Mistakes

  • πŸ’‘ Edge list needs βž” isolated vertices () have no edges; matrix is bits regardless, list stores only actual edges.

🧠 Active Recall