Advanced maths

Line graph recognition and root reconstruction calculator

Decide whether a small simple graph is the line graph of another simple graph, then reconstruct and verify one root with an explicit mapping from input vertices to root edges.

Your numbers

Vertices are labeled 0 through n−1, including isolated vertices.
One edge per line: u,v. No loops or duplicate pairs. Blank means no edges.

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

Decide whether a small simple graph is the line graph of another simple graph, then reconstruct and verify one root with an explicit mapping from input vertices to root edges.

THE FORMULAG=L(H) iff G admits an edge partition into cliques such that every vertex belongs to at most two cliques (Krausz characterization). Root edges meet exactly when their line vertices are adjacent.

A worked example

The default triangle is a line graph. One returned root is a three-edge star: its three edges all share the center, so their line graph is a triangle. A triangle root also has the same line graph; the root is therefore not unique in this case.

Good to know

Simple undirected inputs with 1–10 vertices and at most 25 edges. Exact bounded clique-partition search, capped at 1000000 states with explicit unfinished error. Disconnected inputs and isolated input vertices retained. Returns one simple root, omitting arbitrary root isolates.

Turn adjacency back into incidence

A line graph has one vertex for each edge of a root graph. Two line vertices are adjacent exactly when their corresponding root edges share an endpoint. Recognition asks whether the entered adjacency pattern can arise this way, while reconstruction supplies an actual root and the correspondence.

This is more specific than finding any graph with a similar drawing or degree sequence. The mapping must reproduce every input adjacency and every missing adjacency. The calculator checks those pairwise conditions after reconstruction, so a visually plausible root is insufficient unless its edge-incidence relationships agree exactly.

Every pair of star edges meets at the centerInput line graph012One root: three-edge starcabd012Root edge labels ↔ input vertices
Scroll across to see the full diagram.
The default triangle is a line graph. One returned root is a three-edge star: its three edges all share the center, so their line graph is a triangle. A triangle root also has the same line graph; the root is therefore not unique in this case.

Compare this with the Graph square root calculator with a reconstruction certificate. Recognize adjacency between original edges and reconstruct a root graph; this inverts the line-graph operation,not distance-two adjacency.

Enter the graph to recognize

The vertex count refers to the proposed line graph, not to the unknown root. Labels run from zero to n−1, and each edge row gives an unordered pair of these input labels. The root can have more vertices than the input, since its edges become the input vertices.

Loops, duplicate unordered pairs, weighted rows and invalid labels are rejected. Disconnected input is allowed. An isolated input vertex still represents an edge in the root; it cannot simply disappear. Correct invalid rows and rerun the full recognition instead of interpreting an incomplete partition as a negative answer.

Understand the triangle ambiguity

For the default triangle, the input vertices 0, 1 and 2 are all adjacent. A three-edge star is a valid root because every pair of its edges meets at the center. The returned mapping associates each input vertex with one of those star edges.

A root triangle is also valid: each pair of its three edges shares one endpoint. These roots are not isomorphic, illustrating the classical triangle and claw ambiguity of line-graph inversion. This does not mean a claw input is a line graph; the claw is one of the alternative roots of a triangle input.

Search clique incidence certificates

At each root vertex, its incident edges form a clique in the line graph. Every line-graph edge is explained by exactly one shared endpoint because the root is simple. Each line vertex belongs to at most two such cliques, corresponding to its root edge’s two endpoints.

The bounded implementation enumerates cliques and searches edge partitions satisfying those membership limits. It selects an uncovered input edge and tries every eligible clique that covers it without reusing a previously explained edge. This is an exact characterization-based search, distinct from the faster Roussopoulos implementation described in the reference.

Build and verify the root

Each selected clique becomes one root vertex. An input vertex appearing in two cliques becomes the root edge between their vertices. If it appears in only one clique, a private leaf endpoint completes its root edge. If it appears in no clique, two private endpoints form an isolated root edge.

After construction, the program verifies that two root edges share an endpoint exactly when their input vertices are adjacent. It also rejects repeated root edges. The rootEdges array is indexed by original line-vertex label, and the mapping repeats that correspondence explicitly for easier inspection and independent reconstruction.

Disconnectedness and nonuniqueness

Components can be reconstructed without forcing connections between their roots. In particular, an isolated input vertex becomes an isolated two-vertex root component. Arbitrary isolated root vertices cannot be recovered from any line graph, because they contribute no root edges and hence no line vertices; this page omits them.

A completed failed partition search proves that no simple root exists under the stated model. A successful search returns one root, not all roots or a unique canonical root. Vertex naming and clique tie breaking can change the displayed structure while preserving the same verified line graph.

Search limits and interpretation

The input is bounded at ten vertices and twenty-five edges. Clique enumeration examines at most 1023 nonempty vertex subsets, while the subsequent partition search can branch substantially. A one-million-state limit throws an unfinished-recognition error rather than declaring that the graph is not a line graph.

The reference’s production algorithm and this calculator share the same simple-graph inversion task, but have different implementations and performance characteristics. The calculator does not recognize line graphs of multigraphs, directed line graphs or weighted incidence systems. A rejection in this model says nothing about those broader reconstruction problems.

A few questions, answered

Why can a triangle have two different roots?

Both a triangle and a three-edge star have three pairwise incident edges, giving the same line graph.

What happens to an isolated input vertex?

It becomes a separate root edge with two private endpoints.

Are arbitrary isolated root vertices recovered?

No. They produce no line-graph vertices and cannot be inferred.

Does a resource-limit error mean the graph is not a line graph?

No. It means recognition did not finish; only a completed failed search proves rejection.

Find your calculator

Start typing to explore the library.