Advanced maths

Weighted maximum cut calculator without a balance constraint

Find an exhaustive maximum-weight cut of a small undirected graph without requiring balanced class sizes.

Your numbers

Zero-based labels 0 through n−1, including isolated vertices.
One row: u v weight.

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 an exhaustive maximum-weight cut of a small undirected graph without requiring balanced class sizes.

THE FORMULAmax_{S⊆V} Σ_{uv∈E}w_uv·1[(u∈S)≠(v∈S)].

A worked example

For triangle weights w01=2, w12=3 and w02=4, isolating vertex 2 crosses weights 3 and 4. The optimum is 7 and uncut weight is 2.

Good to know

Simple undirected graphs on 1–20 vertices, at most 190 edges, finite nonnegative weights up to 1,000,000. All 2^(n−1) complement-distinct cuts evaluated by direct weight sums. One optimum, no tie count. Decimal arithmetic is floating point; no terminals, balance, negative weights or assignment constraints. Empty classes permitted.

Maximize the weight crossing a partition

A cut divides the vertices into two classes and keeps the edges whose endpoints lie in different classes. The maximum-cut objective adds their supplied weights and seeks the largest total. There is no requirement that the two classes have equal or nearly equal sizes.

This is different from minimum bisection, which imposes a size balance and minimizes crossing cost, and from a source-to-sink minimum cut. No terminals are singled out here. A highly unbalanced partition may be the correct maximizing answer when one vertex carries most of the incident weight.

For triangle weights w01=2, w12=3 and w02=4, isolating vertex 2 crosses weights 3 and 4243012Isolate vertex 2Crossing: 3 + 4Maximum = 7Uncut weight = 2
Scroll across to see the full diagram.
For triangle weights w01=2, w12=3 and w02=4, isolating vertex 2 crosses weights 3 and 4. The optimum is 7 and uncut weight is 2.

Compare this with the Minimum weighted graph bisection calculator with a balanced partition. Maximize crossing edge weight over unrestricted bipartitions, rather than minimize it under equal-size constraints.

Weights describe the actual objective

Every input edge row contains two zero-based endpoint labels followed by one finite nonnegative weight. An absent edge contributes nothing. Zero-weight edges are accepted, but they do not affect which partitions maximize the scalar objective and may create additional equally good solutions.

Parallel edges are rejected rather than silently merged. If several relationships between one pair are genuinely additive, combine their weights yourself before entering that pair once. Directed effects, negative weights and mandatory membership constraints are outside this page's model; changing those conventions changes the optimization problem being certified.

Exhaust all complement-distinct cuts

Swapping the names of the two cut classes leaves the crossing edge set unchanged. The calculator fixes vertex zero on one side and enumerates every assignment of the other vertices, eliminating only this complement symmetry. For n vertices, that means two to the power n minus one evaluated partitions.

For each assignment, the crossing total is computed directly from the edge rows. It is not estimated by a random heuristic or by a semidefinite approximation. At most twenty vertices are accepted, which keeps complete enumeration finite; the supported size is a deliberate bound rather than an assumption that maximum cut is easy in general.

The weighted triangle has optimum seven

The default triangle assigns weight two to edge 0–1, weight three to 1–2 and weight four to 0–2. A cut of a triangle can cross two edges, but cannot cross all three because the two classes cannot separate every pair simultaneously.

Isolating vertex two crosses the edges of weights three and four, for a total of seven. The remaining weight-two edge stays uncut. Isolating vertex zero gives six, while isolating vertex one gives five. Thus seven is optimal, and the returned crossing-edge list provides a short witness for that value.

Check both sides and both weight totals

Every declared vertex appears in exactly one returned class, even if it has no incident edges. The crossing-edge list should contain precisely those original rows whose endpoints lie on opposite sides. Summing that list independently reproduces the reported cut weight.

The uncut weight is the original total edge weight minus the crossing total. For the default, nine minus seven equals two. On an edgeless graph, all partitions have weight zero; this implementation can return an empty class under its unrestricted partition convention. That boundary case does not imply a missing vertex or a failed calculation.

Floating inputs and equal optima

Integer weights in the supported range are represented exactly by ordinary browser numbers, and the bounded sum stays within the safe integer range. Decimal weights use floating-point arithmetic, so extremely close candidate totals should be interpreted at the precision of the entered data.

The calculator returns one maximizing partition and does not enumerate or count every tie. A different label ordering can select another equally good witness. Small numerical differences in rounded decimal inputs can also break a mathematical tie, so a chosen class assignment should not be treated as a uniquely established classification unless uniqueness is checked separately.

Use the cut as a model-specific baseline

A large cut weight means the entered objective rewards separating those pairs. Whether that represents incompatible tasks, preferred distinctions or another real relationship depends on how the weights were constructed. The calculator does not infer that interpretation from the graph alone.

If the application also limits class sizes or fixes particular vertices together, those constraints must be modeled explicitly in a different optimization. Applying them after obtaining this answer can destroy optimality. Preserve the original weights and vertex universe when comparing with another layout or algorithm so that the comparison measures the same maximum-cut objective.

A few questions, answered

Must the two sides contain equal numbers of vertices?

No. There is no balance constraint, and an unbalanced cut can maximize the total crossing weight.

Why is vertex zero fixed on one side?

A cut and its complement cross exactly the same edges, so fixing one vertex removes only duplicate class-name symmetry.

Can weights be negative?

No. This implementation admits finite nonnegative edge weights and rejects negative inputs.

What happens on an edgeless graph?

Every partition has weight zero; an empty class is allowed by this page’s unrestricted partition convention.

Find your calculator

Start typing to explore the library.