// Copyright 2010-2021 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Protobuf representing a flow problem on a graph. It supports several problem // types. Depending on the type, the message is interpreted differently as // explained under each type description below. // // LINEAR_SUM_ASSIGNMENT: the algorithm computes the minimum-cost perfect // matching if there is one. // - Arcs are assumed to be from a left node to a right node. In particular // the id space of the left and right nodes can be the same. That is an arc // from the left node 0 to the right node 0 will be coded as (0, 0). // - If a perfect matching does not exist, the problem is not feasible. // - Capacity and supply values are ignored. // // MAX_FLOW: The algorithm computes the maximum flow under the arc capacity // constraints. // - Only one source (with supply > 0) and one sink (with supply < 0), the // supply values are not important. Only the signs are. // - The costs are ignored. // // MIN_COST_FLOW: the algorithm computes the flow of minimum cost. If a feasible // flow does not exist (in particular if the sum of supplies is not 0), the // problem is not feasible. syntax = "proto2"; package operations_research; option java_package = "com.google.ortools.graph"; option java_multiple_files = true; option csharp_namespace = "Google.OrTools.Graph"; message FlowArcProto { // A directed arc goes from a tail node to a head node. // Node ids must be non-negative (>= 0). optional int64 tail = 1; optional int64 head = 2; // Capacity of the arc. Must be non-negative (>= 0). If the capacity is zero, // it is equivalent to not including the arc in the FlowModelProto. optional int64 capacity = 3 [default = 1]; // Cost of this arc per unit of flow. // Note that it can take any positive, negative or null value. optional int64 unit_cost = 4 [default = 0]; } message FlowNodeProto { // The ids must be non-negative (>= 0). They should be dense for good // performance. Note that it is not mandatory to include nodes with no supply // in a FlowModelProto. optional int64 id = 1; // The supply can be positive or negative in which case it means demand. // The sum of the supplies over all nodes must always be 0. optional int64 supply = 2 [default = 0]; } // Holds a flow problem, see NodeProto and ArcProto for more details. message FlowModelProto { repeated FlowNodeProto nodes = 1; repeated FlowArcProto arcs = 2; // The type of problem to solve. enum ProblemType { LINEAR_SUM_ASSIGNMENT = 0; MAX_FLOW = 1; MIN_COST_FLOW = 2; } optional ProblemType problem_type = 3; }