name: Problem
about: Propose a new problem type
title: "[Model] MixedChinesePostman"
labels: model
assignees: ''
Motivation
CHINESE POSTMAN FOR MIXED GRAPHS (P101) from Garey & Johnson, A2 ND25. A fundamental problem in combinatorial optimization on mixed graphs (graphs containing both directed arcs and undirected edges). While the Chinese Postman Problem is polynomial-time solvable on purely undirected or purely directed graphs, the mixed case is NP-complete (Papadimitriou, 1976). It is a target in the reduction from 3SAT (R46).
Associated rules:
- R46: 3SAT -> CHINESE POSTMAN FOR MIXED GRAPHS (incoming)
Definition
Name: MixedChinesePostman
Canonical name: CHINESE POSTMAN FOR MIXED GRAPHS (also: Mixed Chinese Postman Problem, MCPP)
Reference: Garey & Johnson, Computers and Intractability, A2 ND25
Mathematical definition:
INSTANCE: Mixed graph G = (V, A, E), where A is a set of directed edges (arcs) and E is a set of undirected edges on V, length l(e) ∈ Z_0+ for each e ∈ A∪E, bound B ∈ Z+.
QUESTION: Is there a closed walk in G that traverses each arc in its specified direction and each undirected edge in at least one direction, possibly traversing some arcs/edges multiple times, with total length ≤ B?
Variables
- Count: |E| binary variables — one per undirected edge, representing the chosen traversal direction.
- Per-variable domain: {0, 1} — 0 = forward direction (u → v), 1 = reverse direction (v → u), for each undirected edge {u, v}.
- Meaning: A configuration fixes the orientation of every undirected edge. Given fixed orientations, the graph becomes purely directed and the minimum-cost Chinese Postman tour on this directed graph can be computed in polynomial time (via min-cost flow to balance vertex degrees). The configuration is satisfying if this minimum directed CPP cost is ≤ B.
Dims
[2; num_edges] — one binary variable per undirected edge.
Schema (data type)
Type name: MixedChinesePostman
Variants: weight type (W)
Prerequisite type: MixedGraph — a new graph topology type representing a graph with both directed arcs and undirected edges. Stores num_vertices: usize, arcs: Vec<(usize, usize)> (directed), and edges: Vec<(usize, usize)> (undirected). Lives under src/models/graph/.
| Field |
Type |
Description |
graph |
MixedGraph |
The mixed graph G = (V, A, E) |
arc_weights |
Vec<W> |
Length for each arc in A (parallel to graph.arcs) |
edge_weights |
Vec<W> |
Length for each undirected edge in E (parallel to graph.edges) |
bound |
W |
The total length bound B |
Notes:
- This is a satisfaction (decision) problem:
Metric = bool, implementing SatisfactionProblem.
MixedGraph is a new topology type (not parameterized by G). The problem struct is MixedChinesePostman<W>.
- The cycle must traverse every arc in its specified direction and every undirected edge in at least one direction, possibly traversing some arcs/edges multiple times.
- Given fixed edge orientations, the problem reduces to a directed Chinese Postman: find minimum-cost additional arc copies to make the directed graph Eulerian (balanced in-degree equals out-degree at every vertex), solvable via min-cost flow in O(V³).
- Polynomial-time solvable when A = ∅ (undirected Chinese Postman, solved by T-join/matching) or E = ∅ (directed Chinese Postman, solved by min-cost flow).
Size fields
| Getter |
Description |
num_vertices |
Number of vertices |V| |
num_arcs |
Number of directed arcs |A| |
num_edges |
Number of undirected edges |E| |
bound |
Total length bound B |
Complexity
- Best known exact algorithm: Brute-force enumeration over all 2^|E| orientations of undirected edges. For each orientation, solve the resulting directed Chinese Postman Problem via min-cost flow in O(V³). Total: O(2^|E| · |V|³).
- Complexity expression:
"2^num_edges * num_vertices^3"
- NP-completeness: NP-complete (Papadimitriou, 1976, "On the complexity of edge traversing"). Remains NP-complete even if all edge lengths are equal (unit lengths), G is planar, and the maximum vertex degree is 3.
- Special cases: Polynomial-time solvable when A = ∅ (Edmonds and Johnson, 1973) or E = ∅ (standard min-cost flow).
- Approximation: A 3/2-approximation algorithm exists for the optimization version (Frederickson, SIAM J. Discrete Math.).
- References:
- C.H. Papadimitriou (1976). "On the complexity of edge traversing." Journal of the ACM, 23(3):544–554.
- J. Edmonds and E.L. Johnson (1973). "Matching, Euler tours, and the Chinese postman." Mathematical Programming, 5:88–124.
Extra Remark
Full book text:
INSTANCE: Mixed graph G = (V,A,E), where A is a set of directed edges and E is a set of undirected edges on V, length l(e) ∈ Z0+ for each e ∈ A∪E, bound B ∈ Z+.
QUESTION: Is there a cycle in G that includes each directed and undirected edge at least once, traversing directed edges only in the specified direction, and that has total length no more than B?
Reference: [Papadimitriou, 1976b]. Transformation from 3SAT.
Comment: Remains NP-complete even if all edge lengths are equal, G is planar, and the maximum vertex degree is 3. Can be solved in polynomial time if either A or E is empty (i.e., if G is either a directed or an undirected graph) [Edmonds and Johnson, 1973].
How to solve
Example Instance
Instance 1 (YES — postman tour within bound):
Mixed graph G with 5 vertices {0, 1, 2, 3, 4}:
- Arcs A (directed): (0→1, length 2), (1→2, length 3), (2→3, length 1), (3→0, length 4)
- Edges E (undirected): {0,2, length 2}, {1,3, length 3}, {0,4, length 1}, {4,2, length 2}
- Bound B = 24
Base traversal cost (sum of all arc/edge lengths): 2 + 3 + 1 + 4 + 2 + 3 + 1 + 2 = 18.
Optimal orientation: edge {0,2} as 2→0, edge {1,3} as 3→1, edge {0,4} as 0→4, edge {4,2} as 4→2.
With this orientation, the directed graph has arcs:
- Original arcs: 0→1(2), 1→2(3), 2→3(1), 3→0(4)
- Oriented edges: 2→0(2), 3→1(3), 0→4(1), 4→2(2)
Degree imbalance d(v) = out_degree − in_degree:
- d(0) = 2 − 2 = 0
- d(1) = 1 − 2 = −1 (deficit: needs 1 more outgoing)
- d(2) = 2 − 3 = −1 (deficit: needs 1 more outgoing)
- d(3) = 2 − 1 = +1 (surplus: needs 1 more incoming)
- d(4) = 1 − 1 = 0
To balance: duplicate arcs along shortest path from surplus to deficit vertices. Duplicate 1→2(3) and 2→3(1), cost = 4. This routes the surplus at vertex 3 through 1→2→3, balancing all degrees.
Total cost = 18 (base) + 4 (duplications) = 22 ≤ 24 = B. ✅
Tour (Eulerian circuit on balanced graph): 0 → 1 → 2 → 3 → 0 → 4 → 2 → 3 → 1 → 2 → 0, total length = 22.
Suboptimal feasible solutions: Two additional orientations yield cost 24 (≤ B), providing suboptimal feasible solutions. For example, orienting {0,2} as 2→0, {1,3} as 1→3, {0,4} as 0→4, {4,2} as 4→2 gives balancing cost 6, total = 24.
Answer: YES
Expected Outcome: The optimal orientation achieves cost 22 ≤ 24 = B, with duplicated arcs 1→2 and 2→3. Two suboptimal orientations also feasible at cost 24.
Instance 2 (NO — postman tour exceeds bound):
Mixed graph G with 6 vertices {0, 1, 2, 3, 4, 5}:
- Arcs A: (0→1, length 1), (1→0, length 1), (2→3, length 1)
- Edges E: {0,2, length 1}, {1,3, length 1}, {3,4, length 5}, {4,5, length 5}, {5,2, length 5}
- Bound B = 10
Base traversal cost: arcs = 1 + 1 + 1 = 3, edges = 1 + 1 + 5 + 5 + 5 = 17, total = 20.
Since the base cost alone (20) already exceeds B = 10, and any feasible tour must traverse every arc and edge at least once (total length ≥ 20), no tour can have total length ≤ 10.
Answer: NO
name: Problem
about: Propose a new problem type
title: "[Model] MixedChinesePostman"
labels: model
assignees: ''
Motivation
CHINESE POSTMAN FOR MIXED GRAPHS (P101) from Garey & Johnson, A2 ND25. A fundamental problem in combinatorial optimization on mixed graphs (graphs containing both directed arcs and undirected edges). While the Chinese Postman Problem is polynomial-time solvable on purely undirected or purely directed graphs, the mixed case is NP-complete (Papadimitriou, 1976). It is a target in the reduction from 3SAT (R46).
Associated rules:
Definition
Name:
MixedChinesePostmanCanonical name: CHINESE POSTMAN FOR MIXED GRAPHS (also: Mixed Chinese Postman Problem, MCPP)
Reference: Garey & Johnson, Computers and Intractability, A2 ND25
Mathematical definition:
INSTANCE: Mixed graph G = (V, A, E), where A is a set of directed edges (arcs) and E is a set of undirected edges on V, length l(e) ∈ Z_0+ for each e ∈ A∪E, bound B ∈ Z+.
QUESTION: Is there a closed walk in G that traverses each arc in its specified direction and each undirected edge in at least one direction, possibly traversing some arcs/edges multiple times, with total length ≤ B?
Variables
Dims
[2; num_edges]— one binary variable per undirected edge.Schema (data type)
Type name:
MixedChinesePostmanVariants: weight type (W)
Prerequisite type:
MixedGraph— a new graph topology type representing a graph with both directed arcs and undirected edges. Storesnum_vertices: usize,arcs: Vec<(usize, usize)>(directed), andedges: Vec<(usize, usize)>(undirected). Lives undersrc/models/graph/.graphMixedGrapharc_weightsVec<W>graph.arcs)edge_weightsVec<W>graph.edges)boundWNotes:
Metric = bool, implementingSatisfactionProblem.MixedGraphis a new topology type (not parameterized byG). The problem struct isMixedChinesePostman<W>.Size fields
num_verticesnum_arcsnum_edgesboundComplexity
"2^num_edges * num_vertices^3"Extra Remark
Full book text:
INSTANCE: Mixed graph G = (V,A,E), where A is a set of directed edges and E is a set of undirected edges on V, length l(e) ∈ Z0+ for each e ∈ A∪E, bound B ∈ Z+.
QUESTION: Is there a cycle in G that includes each directed and undirected edge at least once, traversing directed edges only in the specified direction, and that has total length no more than B?
Reference: [Papadimitriou, 1976b]. Transformation from 3SAT.
Comment: Remains NP-complete even if all edge lengths are equal, G is planar, and the maximum vertex degree is 3. Can be solved in polynomial time if either A or E is empty (i.e., if G is either a directed or an undirected graph) [Edmonds and Johnson, 1973].
How to solve
Example Instance
Instance 1 (YES — postman tour within bound):
Mixed graph G with 5 vertices {0, 1, 2, 3, 4}:
Base traversal cost (sum of all arc/edge lengths): 2 + 3 + 1 + 4 + 2 + 3 + 1 + 2 = 18.
Optimal orientation: edge {0,2} as 2→0, edge {1,3} as 3→1, edge {0,4} as 0→4, edge {4,2} as 4→2.
With this orientation, the directed graph has arcs:
Degree imbalance d(v) = out_degree − in_degree:
To balance: duplicate arcs along shortest path from surplus to deficit vertices. Duplicate 1→2(3) and 2→3(1), cost = 4. This routes the surplus at vertex 3 through 1→2→3, balancing all degrees.
Total cost = 18 (base) + 4 (duplications) = 22 ≤ 24 = B. ✅
Tour (Eulerian circuit on balanced graph): 0 → 1 → 2 → 3 → 0 → 4 → 2 → 3 → 1 → 2 → 0, total length = 22.
Suboptimal feasible solutions: Two additional orientations yield cost 24 (≤ B), providing suboptimal feasible solutions. For example, orienting {0,2} as 2→0, {1,3} as 1→3, {0,4} as 0→4, {4,2} as 4→2 gives balancing cost 6, total = 24.
Answer: YES
Expected Outcome: The optimal orientation achieves cost 22 ≤ 24 = B, with duplicated arcs 1→2 and 2→3. Two suboptimal orientations also feasible at cost 24.
Instance 2 (NO — postman tour exceeds bound):
Mixed graph G with 6 vertices {0, 1, 2, 3, 4, 5}:
Base traversal cost: arcs = 1 + 1 + 1 = 3, edges = 1 + 1 + 5 + 5 + 5 = 17, total = 20.
Since the base cost alone (20) already exceeds B = 10, and any feasible tour must traverse every arc and edge at least once (total length ≥ 20), no tour can have total length ≤ 10.
Answer: NO