You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Problem
about: Propose a new problem type
title: "[Model] UndirectedTwoCommodityIntegralFlow"
labels: model
assignees: ''
Motivation
UNDIRECTED TWO-COMMODITY INTEGRAL FLOW (P115) from Garey & Johnson, A2 ND39. An NP-complete problem that extends the directed two-commodity integral flow to undirected graphs, where flow on each edge can go in either direction but each commodity must choose a single direction per edge. Notable for remaining NP-complete with unit capacities, yet becoming polynomial when all capacities are even (a rare parity-dependent complexity dichotomy).
Associated reduction rules:
As source: None in current set.
As target: R60: DIRECTED TWO-COMMODITY INTEGRAL FLOW -> UNDIRECTED TWO-COMMODITY INTEGRAL FLOW
Definition
Name:UndirectedTwoCommodityIntegralFlow Canonical name: UNDIRECTED TWO-COMMODITY INTEGRAL FLOW Reference: Garey & Johnson, Computers and Intractability, A2 ND39
Mathematical definition:
INSTANCE: Graph G = (V,E), specified vertices s_1, s_2, t_1, and t_2, a capacity c(e) ∈ Z^+ for each e ∈ E, requirements R_1,R_2 ∈ Z^+.
QUESTION: Are there two flow functions f_1,f_2: {(u,v),(v,u): {u,v} ∈ E} → Z_0^+ such that
(1) for all {u,v} ∈ E and i ∈ {1,2}, either f_i((u,v)) = 0 or f_i((v,u)) = 0,
(2) for each {u,v} ∈ E,
max{f_1((u,v)),f_1((v,u))} + max{f_2((u,v)),f_2((v,u))} ≤ c({u,v}),
(3) for each v ∈ V − {s_1,s_2,t_1,t_2} and i ∈ {1,2}, flow f_i is conserved at v, and
(4) for i ∈ {1,2}, the net flow into t_i under flow f_i is at least R_i?
Variables
Count: 4|E| (for each edge {u,v} and each commodity i in {1,2}: variables f_i((u,v)) and f_i((v,u))).
Per-variable domain: {0, 1, ..., c(e)} for each directed version of edge e. Subject to antisymmetry: for each commodity i, at most one of f_i((u,v)), f_i((v,u)) is nonzero.
Meaning: Each variable represents the integer flow of a specific commodity in a specific direction along an edge. The joint capacity constraint limits the total flow (from both commodities) on each edge. A valid configuration satisfies antisymmetry, joint capacity, conservation for each commodity, and both requirements.
Schema (data type)
Type name:UndirectedTwoCommodityIntegralFlow Variants: None (single variant; problem is always on an undirected graph with SimpleGraph).
Field
Type
Description
graph
SimpleGraph
Undirected graph G = (V, E) using the codebase's standard SimpleGraph type (petgraph-based). Vertex count and edge list are derived from the graph.
capacities
Vec<u64>
Capacity c(e) for each edge (indexed by edge index in the graph)
This is a satisfaction (decision) problem: Metric = bool, implementing SatisfactionProblem.
The graph is stored as SimpleGraph (not generic over graph type) since the problem is defined on general undirected graphs without special structure constraints.
NP-complete even with unit capacities (c(e) = 1 for all e).
Polynomial when all capacities are even.
The fractional (non-integral) version is solvable in polynomial time.
Antisymmetry constraint: each commodity can only send flow in one direction per edge.
Complexity
Best known exact algorithm: The problem is NP-complete (Even, Itai, and Shamir, 1976). No sub-exponential exact algorithm is known. A brute-force approach enumerates flow assignments: for each edge and each commodity, choose a direction and flow amount. With unit capacities, the search space is O(5^|E|) (each edge can carry: nothing, commodity 1 left, commodity 1 right, commodity 2 left, commodity 2 right). For general capacities, the complexity is O(∏_e (c(e)+1)^4) before pruning by conservation constraints.
NP-completeness: Proved by Even, Itai, and Shamir (1976) via reduction from DIRECTED TWO-COMMODITY INTEGRAL FLOW. Remains NP-complete with unit capacities.
Polynomial cases:
All capacities even: polynomial (Even, Itai, and Shamir, 1976).
Non-integral flows allowed: polynomial (solvable by LP or specialized algorithms).
References:
S. Even, A. Itai, A. Shamir (1976). "On the complexity of timetable and multicommodity flow problems". SIAM J. Comput. 5, pp. 691-703.
Extra Remark
Full book text:
INSTANCE: Graph G = (V,E), specified vertices s_1, s_2, t_1, and t_2, a capacity c(e) ∈ Z^+ for each e ∈ E, requirements R_1,R_2 ∈ Z^+.
QUESTION: Are there two flow functions f_1,f_2: {(u,v),(v,u): {u,v} ∈ E} → Z_0^+ such that
(1) for all {u,v} ∈ E and i ∈ {1,2}, either f_i((u,v)) = 0 or f_i((v,u)) = 0,
(2) for each {u,v} ∈ E,
max{f_1((u,v)),f_1((v,u))} + max{f_2((u,v)),f_2((v,u))} ≤ c({u,v}),
(3) for each v ∈ V − {s_1, s_2, t_1, t_2} and i ∈ {1,2}, flow f_i is conserved at v, and
(4) for i ∈ {1,2}, the net flow into t_i under flow f_i is at least R_i?
Reference: [Even, Itai, and Shamir, 1976]. Transformation from DIRECTED TWO-COMMODITY INTEGRAL FLOW.
Comment: Remains NP-complete even if c(e) = 1 for all e ∈ E. Solvable in polynomial time if c(e) is even for all e ∈ E. Corresponding problem with non-integral flows allowed can be solved in polynomial time.
Note: The original book text uses "v ∈ V − {s,t}" in condition (3), which appears to be shorthand. The correct exclusion set for this problem is {s_1, s_2, t_1, t_2} (all four terminal vertices), as shown in the definition above.
How to solve
It can be solved by (existing) bruteforce. The variable domains are finite ({0, ..., c(e)} per directed edge per commodity), so exhaustive enumeration is possible, though exponential.
It can be solved by reducing to integer programming.
Other: Formulate as an ILP: for each edge {u,v} and commodity i, introduce integer variables f_i_uv, f_i_vu >= 0 with binary direction indicators. Constraints: antisymmetry (at most one direction per commodity per edge), joint capacity, conservation, and requirements. Standard ILP solvers can handle moderate instances.
Example Instance
Instance 1 (YES):
Graph with 6 vertices {0=s_1, 1=s_2, 2, 3, 4=t_1, 5=t_2} and 8 edges (all capacity 1):
Instance 2 (NO):
Graph with 4 vertices {0=s_1, 1=s_2, 2, 3} where t_1=3, t_2=3, and 3 edges (all capacity 1):
e_0 = {0,2}, e_1 = {1,2}, e_2 = {2,3}
Requirements: R_1 = 1, R_2 = 1.
Both commodities need to route 1 unit to vertex 3. Both must use edge e_2={2,3}. Joint capacity on e_2: max flow from commodity 1 + max flow from commodity 2 <= 1. But both need >= 1 unit through this edge. f_1 + f_2 >= 2 > 1 = c(e_2). Answer: NO.
Instance 3 (YES, even capacities -- polynomial case):
Same graph as Instance 2 but c(e_2) = 2.
name: Problem
about: Propose a new problem type
title: "[Model] UndirectedTwoCommodityIntegralFlow"
labels: model
assignees: ''
Motivation
UNDIRECTED TWO-COMMODITY INTEGRAL FLOW (P115) from Garey & Johnson, A2 ND39. An NP-complete problem that extends the directed two-commodity integral flow to undirected graphs, where flow on each edge can go in either direction but each commodity must choose a single direction per edge. Notable for remaining NP-complete with unit capacities, yet becoming polynomial when all capacities are even (a rare parity-dependent complexity dichotomy).
Associated reduction rules:
Definition
Name:
UndirectedTwoCommodityIntegralFlowCanonical name: UNDIRECTED TWO-COMMODITY INTEGRAL FLOW
Reference: Garey & Johnson, Computers and Intractability, A2 ND39
Mathematical definition:
INSTANCE: Graph G = (V,E), specified vertices s_1, s_2, t_1, and t_2, a capacity c(e) ∈ Z^+ for each e ∈ E, requirements R_1,R_2 ∈ Z^+.
QUESTION: Are there two flow functions f_1,f_2: {(u,v),(v,u): {u,v} ∈ E} → Z_0^+ such that
(1) for all {u,v} ∈ E and i ∈ {1,2}, either f_i((u,v)) = 0 or f_i((v,u)) = 0,
(2) for each {u,v} ∈ E,
max{f_1((u,v)),f_1((v,u))} + max{f_2((u,v)),f_2((v,u))} ≤ c({u,v}),
(3) for each v ∈ V − {s_1,s_2,t_1,t_2} and i ∈ {1,2}, flow f_i is conserved at v, and
(4) for i ∈ {1,2}, the net flow into t_i under flow f_i is at least R_i?
Variables
Schema (data type)
Type name:
UndirectedTwoCommodityIntegralFlowVariants: None (single variant; problem is always on an undirected graph with
SimpleGraph).graphSimpleGraphSimpleGraphtype (petgraph-based). Vertex count and edge list are derived from the graph.capacitiesVec<u64>source_1usizesink_1usizesource_2usizesink_2usizerequirement_1u64requirement_2u64Size fields (for overhead expressions):
num_vertices(fromgraph.node_count()),num_edges(fromgraph.edge_count())Notes:
Metric = bool, implementingSatisfactionProblem.SimpleGraph(not generic over graph type) since the problem is defined on general undirected graphs without special structure constraints.Complexity
"5^num_edges"(unit-capacity brute-force upper bound; no better exact algorithm known).Extra Remark
Full book text:
INSTANCE: Graph G = (V,E), specified vertices s_1, s_2, t_1, and t_2, a capacity c(e) ∈ Z^+ for each e ∈ E, requirements R_1,R_2 ∈ Z^+.
QUESTION: Are there two flow functions f_1,f_2: {(u,v),(v,u): {u,v} ∈ E} → Z_0^+ such that
(1) for all {u,v} ∈ E and i ∈ {1,2}, either f_i((u,v)) = 0 or f_i((v,u)) = 0,
(2) for each {u,v} ∈ E,
max{f_1((u,v)),f_1((v,u))} + max{f_2((u,v)),f_2((v,u))} ≤ c({u,v}),
(3) for each v ∈ V − {s_1, s_2, t_1, t_2} and i ∈ {1,2}, flow f_i is conserved at v, and
(4) for i ∈ {1,2}, the net flow into t_i under flow f_i is at least R_i?
Reference: [Even, Itai, and Shamir, 1976]. Transformation from DIRECTED TWO-COMMODITY INTEGRAL FLOW.
Comment: Remains NP-complete even if c(e) = 1 for all e ∈ E. Solvable in polynomial time if c(e) is even for all e ∈ E. Corresponding problem with non-integral flows allowed can be solved in polynomial time.
Note: The original book text uses "v ∈ V − {s,t}" in condition (3), which appears to be shorthand. The correct exclusion set for this problem is {s_1, s_2, t_1, t_2} (all four terminal vertices), as shown in the definition above.
How to solve
Example Instance
Instance 1 (YES):
Graph with 6 vertices {0=s_1, 1=s_2, 2, 3, 4=t_1, 5=t_2} and 8 edges (all capacity 1):
Requirements: R_1 = 1, R_2 = 1.
Solution:
Instance 2 (NO):
Graph with 4 vertices {0=s_1, 1=s_2, 2, 3} where t_1=3, t_2=3, and 3 edges (all capacity 1):
Requirements: R_1 = 1, R_2 = 1.
Instance 3 (YES, even capacities -- polynomial case):
Same graph as Instance 2 but c(e_2) = 2.