- Type Parameters:
V- the graph vertex type
E- the graph edge type
The algorithm works with directed and undirected graphs which may contain loops and/or multiple
edges. The runtime complexity is O(N^3) where N is the number of vertices in the graph. Mixed
graphs are currently not supported, as solving the CPP for mixed graphs is NP-hard. The graph on
which this algorithm is invoked must be strongly connected; invoking this algorithm on a graph
which is not strongly connected may result in undefined behavior. In case of weighted graphs, all
edge weights must be positive.
If the input graph is Eulerian (see
GraphTests.isEulerian(Graph) for details) use
The implementation is based on the following paper:
Edmonds, J., Johnson, E.L. Matching, Euler tours and the Chinese postman, Mathematical Programming (1973) 5: 88. doi:10.1007/BF01580113
More concise descriptions of the algorithms can be found here:
- Joris Kinable
getCPPSolutionSolves the Chinese Postman Problem on the given graph. For Undirected graph, this implementation uses the @
KolmogorovWeightedPerfectMatchingmatching algorithm; for directed graphs, @
KuhnMunkresMinimalWeightBipartitePerfectMatchingis used instead. The input graph must be strongly connected. Otherwise the behavior of this class is undefined.
graph- the input graph (must be a strongly connected graph)
- Eulerian circuit of minimum weight.