Advanced maths

Minimum graph fill in calculator with an optimal chordal completion

Find the fewest missing edges that turn a small undirected graph into a chordal graph, with an elimination-order certificate.

Your numbers

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

Find the fewest missing edges that turn a small undirected graph into a chordal graph, with an elimination-order certificate.

THE FORMULAfill(G)=min{|F|: F⊆nonedges(G), G+F is chordal}. A perfect elimination ordering makes every later-neighbor set a clique.

A worked example

The five-cycle has minimum fill2. Adding diagonals(0,2) and(0,3) produces a chordal graph; one added diagonal still leaves an induced cycle of length four.

Good to know

Simple graphs on 2–8 vertices with at most16 missing edges. Exhaustively enumerate missing-edge subsets in increasing cardinality, recognize chordality exactly, and verify a perfect elimination ordering. State-cap failures return unresolved; minimum is different from inclusion-minimal fill.

Fill edges solve a completion problem

A chordal graph has no induced cycle longer than three. An induced cycle uses exactly the edges around that cycle, with no shortcut between its nonconsecutive vertices. Completion keeps every original edge and adds some previously absent ones. The goal is to add as few edges as possible, rather than delete troublesome vertices or simply draw a graph without crossings.

This distinction matters in sparse elimination and graphical models. A completion describes additional adjacencies introduced to obtain a chordal structure. Planarity is unrelated: a graph can be chordal and nonplanar, or planar and nonchordal. The calculator returns a combinatorial completion and a verifiable ordering, without pretending that its graph sketch is a matrix factorization or a statistical model fit.

A five-cycle becomes chordal after two diagonals01234Five-cycle: two fill edgesAdded: (0,2), (0,3)Eliminate: 1, 2, 0, 3, 4Minimum fill = 2
Scroll across to see the full diagram.
The five-cycle has minimum fill2. Adding diagonals(0,2) and(0,3) produces a chordal graph; one added diagonal still leaves an induced cycle of length four.

Compare this with the Chordal graph clique tree calculator with running intersection certificate. Add the fewest missing edges to make an arbitrary graph chordal, with a minimum-cardinality completion and a perfect elimination certificate. The existing page recognizes/decomposes an already chordal graph; it does not optimize edge additions. This is not minimum treewidth or clique editing.

Describe vertices and allowable additions

Enter the declared vertex count and undirected endpoint pairs using zero-based labels. Every vertex belongs to the graph, including an isolate. Each pair represents one edge; reversed duplicates and loops should be rejected. All missing pairs are potential fill edges. Supplying an edge accidentally does more than affect a picture because that edge becomes compulsory in every candidate completion.

The exhaustive search is deliberately restricted to small graphs and a bounded number of missing edges. A computation cap is a limit on resolving the optimization, not proof that no completion exists: the complete graph always supplies a completion. Large sparse instances can have too many missing pairs even when their optimal fill count is small, so check the displayed supported domain before entering them.

Minimum is stronger than inclusion minimal

A fill set is inclusion-minimal when none of its individual edges can be removed while keeping that completed graph chordal. This local property does not prove the set has the fewest edges among all possible completions. Different inclusion-minimal triangulations of the same graph can have different sizes. The word optimal on this page therefore requires a completed cardinality search.

One exact bounded method considers subsets of missing edges in increasing size and tests chordality for each resulting graph. The first successful size proves a minimum because all smaller sizes have been exhausted. Search order may choose one of several tied minimum completions. It should not change the optimum value, and a resource cutoff must not silently promote the best completion found so far to an exact answer.

Read the elimination certificate

A perfect elimination ordering removes vertices one at a time so that the neighbors remaining after each removal form a clique. For a proposed ordering, inspect each vertex and every pair among its later neighbors. Each such pair must already be an edge in the completed graph. This direct certificate is easy to check independently of the algorithm that found the completion.

The ordering certifies chordality of the returned supergraph. It does not by itself certify that the fill set is minimum. Optimality also depends on the completed search over smaller sets, or a separate lower-bound proof. Keeping these certificates separate prevents an excellent elimination ordering from being mistaken for evidence that no better completion exists.

Work through a five cycle

The default graph has cycle edges01,12,23,34 and40. Its induced five-cycle is not chordal. Add02 and03. Vertex1 then has later neighbors0 and2, which are adjacent through02; vertex2 can follow with later neighbors0 and3, adjacent through03. The remaining three vertices form a triangle, giving a valid perfect elimination ordering.

Why are two additions necessary? Any single diagonal of the five-cycle divides it into a triangle and a four-cycle. That four-cycle still has no chord because there are no other added edges. Consequently, no one-edge completion is chordal. The two displayed diagonals attain the lower bound, so the reported minimum is two rather than merely the size of a convenient construction.

Separate fill from neighboring objectives

Minimum treewidth also involves chordal completions, but it minimizes the size of a largest clique minus one, not the number of added edges. A completion with fewer edges need not be best for that clique-size objective. Likewise, cluster editing seeks disjoint cliques and may permit deletions. Neither result can be substituted for a minimum-fill answer without changing the mathematical problem.

For a graph already known to be chordal, a clique-tree calculation explains its existing structure without adding edges. Use this completion page when the question is which missing adjacencies must be introduced. If numerical matrix elimination is the intended application, matrix ordering, symmetry conventions and the distinction between structural and accidental numerical zeros still need to be handled outside this graph-only model.

Check the result before reusing it

Verify that the original edge set is contained in the returned completion, that every reported fill pair was originally absent, and that its size matches the summary. Then replay the perfect elimination ordering. Relabeling the input vertices should preserve the optimum, although the chosen fill pairs and tie-breaking order will be relabeled or may select a different tied witness.

The solver reports an exact optimum only within its supported graph domain and completed search budget. It does not provide a general polynomial-time algorithm, a random-graph estimate or a guarantee about factorization speed on a computer. Treat an unresolved message as a request to reduce or reformulate the instance, while retaining the distinction between a feasible completion and a proven minimum.

A few questions, answered

Does a planar graph need zero fill?

No. A planar cycle of length four or more is not chordal and needs added diagonals.

Can there be several optimum completions?

Yes. Different fill sets can have the same minimum size; one certified witness is sufficient.

Is a minimal triangulation necessarily minimum?

No. Inclusion-minimality prevents redundant edges in one solution but does not compare every completion size.

Does a search cutoff mean completion is impossible?

No. A complete supergraph always exists; a cutoff means that the minimum was not resolved.

Find your calculator

Start typing to explore the library.