Advanced maths

Perfect graph recognition calculator with odd hole witnesses

Recognize perfect graphs by exhaustive odd-hole and odd-antihole checks, returning a cycle witness when recognition fails.

Your numbers

Zero-based labels 0 through n−1; all declared vertices remain included.
One row: u v. No loops or duplicate unordered pairs.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Recognize perfect graphs by exhaustive odd-hole and odd-antihole checks, returning a cycle witness when recognition fails.

THE FORMULAG is perfect iff neither G nor its complement has an induced odd cycle of length ≥5.

A worked example

The default five-cycle is an odd hole, so it is not perfect: its clique number is two and its chromatic number is three.

Good to know

Simple undirected graphs on 1–12 vertices. Exhaustive odd induced-subset checks in graph and complement. Returns an ordered odd hole or antihole witness; does not compute all induced-subgraph colorings or claim a fast large-graph algorithm.

Understand the all induced subgraphs condition

A graph is perfect when every induced subgraph has chromatic number equal to its largest clique size. The requirement includes far more than the whole graph. A graph whose own coloring matches its clique number may still fail because deleting some vertices reveals an induced subgraph with a coloring gap.

The strong perfect graph theorem supplies an equivalent forbidden-subgraph test: neither the graph nor its complement may contain an induced odd cycle of length at least five. The calculator uses that criterion directly on a bounded vertex set, avoiding a separate coloring optimization for every induced subgraph.

An induced odd cycle obstructs perfection012345 verticesClique number: 2Colors needed: 3No chords: the cycle is an induced odd hole
Scroll across to see the full diagram.
The five-cycle itself witnesses a strict coloring gap and proves the graph is not perfect.

Compare this with the Chromatic polynomial calculator from a graph edge list. Recognize the all-induced-subgraphs coloring property through odd holes and antiholes,not just one graph's chromatic value.

Enter adjacency and retain all vertices

Declare between one and twelve vertices and provide undirected edges as pairs of zero-based labels. The complement is built over exactly that declared vertex set, including isolates. An absent edge in the original graph becomes present in the complement, while loops never appear in either graph.

Repeated unordered pairs, self loops, weights and out-of-range endpoints are rejected. A disconnected graph is allowed because perfection is an induced-subgraph property and does not require global connectivity. The empty edge list is valid: the original graph and all its induced subgraphs can be colored with their respective clique numbers.

See why the five cycle fails

The default graph is a cycle on five vertices with no extra chords. It is an induced odd cycle of length five, so the graph itself is an odd hole witness. Its largest clique has two vertices, but alternating two colors around the cycle leaves the closing edge with equal endpoint colors.

A third color resolves that conflict, giving chromatic number three against clique number two. This explicit gap proves nonperfection for the example. The theorem generalizes the obstruction beyond five vertices and also requires checking odd antiholes, which are complements of odd induced cycles on the same selected vertices.

Recognize induced cycles by degree and connectivity

For each odd vertex subset of size at least five, the calculator examines its induced graph. Every selected vertex must have induced degree two, and the selected graph must be connected. These two conditions together characterize a single cycle rather than a disjoint union of several smaller cycles.

The same test is performed in the complement. A degree-two test alone would be insufficient because several cycle components could pass it. Requiring a traversal to cover the entire selected subset prevents that false witness. If every eligible subset in both graphs is checked without finding a cycle, recognition is complete.

Interpret hole and antihole witnesses

A failed result includes an ordered cycle and identifies whether it belongs to the original graph or its complement. For an odd hole, consecutive labels including the last-to-first pair must be original edges, and every nonconsecutive pair within the witness must be a missing original edge.

For an odd antihole, reverse those adjacency checks: cycle neighbors are missing original edges and the other witness pairs are present. The witness length must be odd and at least five. Extra vertices outside the witness do not matter because the obstruction uses the induced graph on precisely the listed labels.

Separate perfection from particular colorings

A successful result is a structural recognition answer, not a returned optimal coloring or a list of every induced subgraph. Conversely, a single failed coloring heuristic is not evidence of nonperfection. The finite forbidden-cycle test supplies a mathematically meaningful conclusion without interpreting a heuristic’s choice of colors.

Chordal graphs form one familiar subclass of perfect graphs, but perfection permits induced even cycles. A four-cycle therefore passes this tool while failing a chordal-graph recognizer. Complete graphs and bipartite graphs provide further useful positive examples, whereas chordless odd cycles of length at least five provide clear negative controls.

Keep the exponential scope visible

At twelve vertices the calculator can exhaust the relevant induced subsets directly. This is an exact small-instance implementation of a theorem-based criterion, not the sophisticated polynomial recognition algorithm used for very large graphs. The checked counter records completed candidate tests and may stop early once a valid obstruction is found.

When recognition succeeds, there is no odd hole or antihole in the entered graph under the completed exhaustive search. When it fails, verify the displayed obstruction rather than looking for a global coloring gap. Vertex relabeling may select a different witness, but it cannot change whether the underlying graph is perfect.

A few questions, answered

Is one optimal whole-graph coloring sufficient?

No. Perfection requires the clique-color equality for every induced subgraph.

What is an odd antihole?

The complement of an induced odd cycle of length at least five.

Are induced even cycles forbidden?

No. They do not obstruct perfection, although they obstruct chordality.

Does a positive result include a coloring?

No. It certifies the absence of odd holes and antiholes by bounded exhaustive checks.

Find your calculator

Start typing to explore the library.