Sync Google to Github

This commit is contained in:
Corentin Le Molgat
2021-10-13 23:17:11 +02:00
parent 66637a3226
commit 0863b128c4
29 changed files with 331 additions and 252 deletions

View File

@@ -16,11 +16,9 @@ package com.google.ortools.graph.samples;
// [START import]
import com.google.ortools.Loader;
import com.google.ortools.graph.MaxFlow;
import java.util.ArrayList;
import java.util.List;
// [END import]
/** Minimal MaxFlow program.*/
/** Minimal MaxFlow program. */
public final class SimpleMaxFlowProgram {
public static void main(String[] args) throws Exception {
Loader.loadNativeLibraries();
@@ -44,8 +42,9 @@ public final class SimpleMaxFlowProgram {
// Add each arc.
for (int i = 0; i < startNodes.length; ++i) {
int arc = maxFlow.addArcWithCapacity(startNodes[i], endNodes[i], capacities[i]);
if (arc != i)
if (arc != i) {
throw new Exception("Internal error");
}
}
// [END constraints]
@@ -57,7 +56,7 @@ public final class SimpleMaxFlowProgram {
// [START print_solution]
if (status == MaxFlow.Status.OPTIMAL) {
System.out.println("Max. flow: " + maxFlow.getOptimalFlow());
System.out.println("");
System.out.println();
System.out.println(" Arc Flow / Capacity");
for (int i = 0; i < maxFlow.getNumArcs(); ++i) {
System.out.println(maxFlow.getTail(i) + " -> " + maxFlow.getHead(i) + " "