Demonstrations for Discrete Mathematics

Why Characterization Matters in Computer Science

Characterization → Efficient Decision Procedure → Efficient Algorithm

Compare Eulerian Circuit and Hamiltonian Cycle: two graph problems whose definitions differ by a few words, yet whose computational behavior is dramatically different.

Eulerian Circuit Can we start at a vertex, traverse every EDGE exactly once, and return to the starting vertex?
Hamiltonian Cycle Can we start at a vertex, visit every VERTEX exactly once, and return to the starting vertex?

Section 1

Side-by-side interactive graph

Every edge exactly once

Eulerian Circuit

Edges used0 / 0

Ready to inspect edges.

Every vertex exactly once

Hamiltonian Cycle

Vertices visited0 / 0

Ready to search vertices.

Section 2

The Power of Characterization

A connected undirected graph has an Eulerian circuit if and only if every vertex has even degree.

Section 3

Can We Do the Same for Hamiltonian Cycle?

Observable properties

No matching simple shortcut is known

There are useful necessary conditions and useful sufficient conditions, but no similarly simple efficiently checkable necessary and sufficient characterization is known that solves the general problem in polynomial time.

Complexity status

Hamiltonian Cycle is NP-complete. The backtracking solver here is an educational visualization, not a claim about the best possible Hamiltonian algorithm.

Section 4

Search versus Characterization

  1. 1Inspect structure
  2. 2Check connectivity
  3. 3Check vertex degrees
  4. 4Construct circuit using Hierholzer's algorithm
  5. OComplexity: O(V + E)
  1. 1Try possible choices of vertices
  2. 2Backtrack when a route fails
  3. 3Explore alternative possibilities
  4. 4Continue until found or exhausted
  5. NPGeneral decision problem: NP-complete

Section 5

Visualize Computational Explosion

Similar looking problem statements do not imply similar computational complexity.

Eulerian characterization work

Degree checks0
Edges processed0

Hamiltonian backtracking work

Search states explored0
Backtracking steps0
Candidate paths attempted0

Eulerian
Hamiltonian

The Eulerian side is driven by structural checks. The Hamiltonian side can be pulled into many alternative vertex orders before it can rule a graph out.