C++ Reference: class SimpleLinearSumAssignment

This documentation is automatically generated.

Method
AddArcWithCost

Return type: ArcIndex

Arguments: NodeIndex left_node, NodeIndex right_node, CostValue cost

Adds an arc from a left node to a right node with a given cost. * Node indices must be non-negative (>= 0). For a perfect matching to exist on n nodes, the values taken by "left_node" must cover [0, n), same for "right_node". * The arc cost can be any integer, negative, positive or zero. * After the method finishes, NumArcs() == the returned ArcIndex + 1.

AssignmentCost

Return type: CostValue

Arguments: NodeIndex left_node

Returns the cost of the arc used for "left_node"'s assignment. This works only if Solve() returned OPTIMAL.

Cost

Return type: CostValue

Arguments: ArcIndex arc

LeftNode

Return type: NodeIndex

Arguments: ArcIndex arc

Returns user-provided data. The implementation will crash if "arc" is not in [0, NumArcs()).

NumArcs

Return type: ArcIndex

Returns the current number of arcs in the graph.

NumNodes

Return type: NodeIndex

Returns the current number of left nodes which is the same as the number of right nodes. This is one greater than the largest node index seen so far in AddArcWithCost().

OptimalCost

Return type: CostValue

Returns the cost of an assignment with minimal cost. This is 0 if the last Solve() didn't return OPTIMAL.

RightMate

Return type: NodeIndex

Arguments: NodeIndex left_node

Returns the right node assigned to the given left node in the last solution computed by Solve(). This works only if Solve() returned OPTIMAL. Note: It is possible that there is more than one optimal solution. The algorithm is deterministic so it will always return the same solution for a given problem. There is no such guarantee from one code version to the next, but the code does not change often.

RightNode

Return type: NodeIndex

Arguments: ArcIndex arc

SimpleLinearSumAssignment

The constructor takes no size. New node indices will be created lazily by AddArcWithCost().

Solve

Return type: Status