Advanced maths

Strong orientation calculator for a bridgeless undirected graph

Assign a direction to every edge while keeping every vertex reachable from every other vertex.

Your numbers

Vertices are labeled consecutively from 1 through this number, including isolates.
One u,v row per edge; unordered pairs must be unique.

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

Assign a direction to every edge while keeping every vertex reachable from every other vertex. For connected bridgeless graphs, the calculator constructs a strong orientation. Otherwise it reports a disconnection or bridge obstruction, explaining why orienting the existing edges alone cannot meet the requirement.

THE FORMULAStrong orientation exists iff G is connected and has no bridges; orient DFS tree arcs down and ancestor back arcs up.

A worked example

Orient C4 as 1→2→3→4→1. All ordered vertex pairs are reachable and every original edge has exactly one direction.

Good to know

Simple undirected graph, 1–100 vertices. Global strong orientation requires connected and bridgeless input; n=1 has trivial success. No shortest-diameter objective or multigraphs.

Reachability in both directions

A strongly connected digraph permits a directed path from u to v for every ordered pair of vertices. Paths can use several arcs, so it is unnecessary to have a direct arc in both directions between neighboring vertices.

Each input edge receives exactly one direction. Adding a reverse copy would change the network into a different graph and bypass the orientation problem, so the output contains exactly one arc for each original unordered pair.

Strong orientation calculator for a bridgeless undirected graph worked exampleOrient a bridgeless cycle1234Every vertex can reach every other vertex
Orient C4 as 1→2→3→4→1. All ordered vertex pairs are reachable and every original edge has exactly one direction.

Compare this with the Dominator tree calculator for a directed graph and start vertex. Dominator analysis inspects existing directed paths and does not construct a strong orientation.

Why a bridge blocks an orientation

Deleting a bridge separates a connected graph into two parts. Any orientation of that edge points from one part to the other and leaves no alternative crossing path, so return travel across the split becomes impossible.

Disconnection is a separate obstruction: directions cannot create missing connections. Robbins' theorem states that a connected undirected graph admits a strong orientation precisely when it has no bridge, giving both a necessity test and a constructive target.

Orienting a depth-first traversal

The construction directs depth-first tree edges away from the root. Non-tree edges connect descendants to ancestors and are oriented upward, providing return routes from explored regions rather than creating a second outward-only tree.

A low-link calculation checks whether each subtree has an edge reaching its ancestors. In the bridgeless case those return opportunities combine with the outward tree paths to give mutual reachability throughout the graph.

Following the four-cycle example

The default square has no bridges: removing any one of its four edges leaves a path connecting all four vertices. Orienting it as 1 to 2 to 3 to 4 to 1 gives a directed cycle.

From any vertex, following the cycle eventually reaches each other vertex. This verifies strong connectivity directly, while the four displayed arcs show that no extra edge or duplicated reverse direction was needed.

Inspecting an obstruction certificate

When a bridge is reported, remove that pair conceptually and examine the resulting separation. Its endpoints lie in different components, and the original graph has no other edge crossing between those parts; any orientation will allow only one crossing direction.

When the graph is disconnected, the unreachable vertices provide an immediate obstruction to a global strong orientation. A bridgeless component may be orientable on its own, but componentwise success is not the same as a strongly connected whole.

Understanding the input convention

The supported model is a simple undirected graph on one through one hundred vertices. Enter unordered pairs once, with no self-loops or parallel edges. A single declared vertex has a valid trivial orientation and no edge to direct.

Parallel edges can eliminate bridge obstructions in multigraphs, but they are intentionally outside this grammar. Do not merge or invent parallel links to obtain a desired answer without first choosing a model that preserves those distinct connections.

What a strong orientation guarantees

The output guarantees mutual reachability using the entered links. It does not minimize route length, balance traffic, limit in-degree or out-degree, or find an orientation of minimum diameter; these are additional optimization objectives.

Different depth-first tie breaks can produce different valid arc sets. The exact arc list is one construction rather than a unique design, so compare the reachability property and edge preservation instead of expecting identical arrows from every implementation.

A few questions, answered

Is connected input sufficient?

No. A connected graph with a bridge has no global strong orientation.

Can a tree be strongly oriented?

Only the one-vertex tree under the trivial convention. Every edge of a larger tree is a bridge.

Will the result minimize directed distances?

No. It constructs mutual reachability without optimizing path lengths or diameter.

What does an empty one-vertex input return?

A valid trivial strong orientation with no arcs.

Find your calculator

Start typing to explore the library.