Package com.jgalgo.alg.cycle
Class ChinesePostmanImpl
- java.lang.Object
-
- com.jgalgo.alg.cycle.ChinesePostmanAbstract
-
- com.jgalgo.alg.cycle.ChinesePostmanImpl
-
- All Implemented Interfaces:
ChinesePostman
public class ChinesePostmanImpl extends ChinesePostmanAbstract
An algorithm for the chinese postman problem using minimum weighted perfect matching and Eulerian tour.The chinese postman problem is to find a closed path that visits all edges in the graph at least once, with minimum weight sum with respect to a given edge weight function. The algorithm uses the following steps:
- Find all vertices with odd degree. If all vertices have even degree, an Eulerian tour should exists (if the graph is connected).
- Create a complete graph of the odd vertices, with edges weighted by the shortest paths between each pair.
- Compute a minimum weighted perfect matching between the odd vertices.
- Create a graph with the original vertices and edges, and for each edge resulted from the perfect matching, add an edge between the two vertices in the original graph.
- Compute an Eulerian tour in the new graph.
- Construct the full result path by replacing each artificial edge connecting two odd vertices with the shortest path between them.
The running time and space are dominated by the shortest path all pairs and minimum perfect matching algorithms. Other than that, the algorithm use linear time and space.
- Author:
- Barak Ugav
-
-
Constructor Summary
Constructors Constructor Description ChinesePostmanImpl()
Create a new instance of the Chinese postman algorithm.
-
Method Summary
-
Methods inherited from class com.jgalgo.alg.cycle.ChinesePostmanAbstract
computeShortestEdgeVisitorCircleIfExist
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jgalgo.alg.cycle.ChinesePostman
computeShortestEdgeVisitorCircle
-
-
-
-
Constructor Detail
-
ChinesePostmanImpl
public ChinesePostmanImpl()
Create a new instance of the Chinese postman algorithm.Please prefer using
ChinesePostman.newInstance()
to get a default implementation for theChinesePostman
interface.
-
-