Send feedback
Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class ChristofidesPathSolver
Note: This documentation is automatically generated.
Method
ChristofidesPathSolver
Arguments: NodeIndex num_nodes, CostFunction costs
SetMatchingAlgorithm
Return type: void
Arguments: MatchingAlgorithm matching
Sets the matching algorithm to use. A minimum weight perfect matching
(MINIMUM_WEIGHT_MATCHING) guarantees the 3/2 upper bound to the optimal
solution. A minimal weight perfect matching (MINIMAL_WEIGHT_MATCHING)
finds a locally minimal weight matching which does not offer any bound
guarantee but, as of 1/2017, is orders of magnitude faster than the
minimum matching.
By default, MINIMAL_WEIGHT_MATCHING is selected.
TODO(user): Change the default when minimum matching gets faster.
Solve
Return type: bool
Runs the Christofides algorithm. Returns true if a solution was found,
false otherwise.
TravelingSalesmanCost
Return type: CostType
Returns the cost of the approximate TSP tour.
TravelingSalesmanPath
Return type: std::vector<NodeIndex>
Returns the approximate TSP tour.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-09-14 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?