562 lines
14 KiB
Python
562 lines
14 KiB
Python
# Copyright 2010-2025 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.
|
|
|
|
load("@pip_deps//:requirements.bzl", "requirement")
|
|
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
|
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
|
load("@rules_java//java:java_binary.bzl", "java_binary")
|
|
load("@rules_python//python:py_test.bzl", "py_test")
|
|
load("//bazel:run_binary_test.bzl", "run_binary_test")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
cc_test(
|
|
name = "assignment_linear_sum_assignment_test",
|
|
srcs = ["assignment_linear_sum_assignment.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:assignment",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:globals",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "assignment_linear_sum_assignment_py3",
|
|
srcs = ["assignment_linear_sum_assignment.py"],
|
|
main = "assignment_linear_sum_assignment.py",
|
|
deps = [
|
|
requirement("numpy"),
|
|
"//ortools/graph/python:linear_sum_assignment",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "AssignmentLinearSumAssignment",
|
|
srcs = ["AssignmentLinearSumAssignment.java"],
|
|
main_class = "com.google.ortools.graph.samples.AssignmentLinearSumAssignment",
|
|
deps = [
|
|
"//ortools/graph/java:graph",
|
|
"//ortools/java/com/google/ortools:Loader",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "AssignmentLinearSumAssignmentTest",
|
|
binary = ":AssignmentLinearSumAssignment",
|
|
)
|
|
|
|
cc_test(
|
|
name = "assignment_min_flow_test",
|
|
srcs = ["assignment_min_flow.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:min_cost_flow",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:globals",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "assignment_min_flow_py3",
|
|
srcs = ["assignment_min_flow.py"],
|
|
main = "assignment_min_flow.py",
|
|
deps = ["//ortools/graph/python:min_cost_flow"],
|
|
)
|
|
|
|
java_binary(
|
|
name = "AssignmentMinFlow",
|
|
srcs = ["AssignmentMinFlow.java"],
|
|
main_class = "com.google.ortools.graph.samples.AssignmentMinFlow",
|
|
deps = [
|
|
"//ortools/graph/java:graph",
|
|
"//ortools/java/com/google/ortools:Loader",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "AssignmentMinFlowTest",
|
|
binary = ":AssignmentMinFlow",
|
|
)
|
|
|
|
cc_test(
|
|
name = "balance_min_flow_test",
|
|
srcs = ["balance_min_flow.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:min_cost_flow",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:globals",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "balance_min_flow_py3",
|
|
srcs = ["balance_min_flow.py"],
|
|
main = "balance_min_flow.py",
|
|
deps = ["//ortools/graph/python:min_cost_flow"],
|
|
)
|
|
|
|
java_binary(
|
|
name = "BalanceMinFlow",
|
|
srcs = ["BalanceMinFlow.java"],
|
|
main_class = "com.google.ortools.graph.samples.BalanceMinFlow",
|
|
deps = [
|
|
"//ortools/graph/java:graph",
|
|
"//ortools/java/com/google/ortools:Loader",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "BalanceMinFlowTest",
|
|
binary = ":BalanceMinFlow",
|
|
)
|
|
|
|
cc_test(
|
|
name = "simple_max_flow_program_test",
|
|
srcs = ["simple_max_flow_program.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:max_flow",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:globals",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "simple_max_flow_program_py3",
|
|
srcs = ["simple_max_flow_program.py"],
|
|
main = "simple_max_flow_program.py",
|
|
deps = [
|
|
requirement("numpy"),
|
|
"//ortools/graph/python:max_flow",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "SimpleMaxFlowProgram",
|
|
srcs = ["SimpleMaxFlowProgram.java"],
|
|
main_class = "com.google.ortools.graph.samples.SimpleMaxFlowProgram",
|
|
deps = [
|
|
"//ortools/graph/java:graph",
|
|
"//ortools/java/com/google/ortools:Loader",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "SimpleMaxFlowProgramTest",
|
|
binary = ":SimpleMaxFlowProgram",
|
|
)
|
|
|
|
cc_test(
|
|
name = "simple_min_cost_flow_program_test",
|
|
srcs = ["simple_min_cost_flow_program.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:min_cost_flow",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:globals",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "simple_min_cost_flow_program_py3",
|
|
srcs = ["simple_min_cost_flow_program.py"],
|
|
main = "simple_min_cost_flow_program.py",
|
|
deps = [
|
|
requirement("numpy"),
|
|
"//ortools/graph/python:min_cost_flow",
|
|
],
|
|
)
|
|
|
|
java_binary(
|
|
name = "SimpleMinCostFlowProgram",
|
|
srcs = ["SimpleMinCostFlowProgram.java"],
|
|
main_class = "com.google.ortools.graph.samples.SimpleMinCostFlowProgram",
|
|
deps = [
|
|
"//ortools/graph/java:graph",
|
|
"//ortools/java/com/google/ortools:Loader",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "SimpleMinCostFlowProgramTest",
|
|
binary = ":SimpleMinCostFlowProgram",
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dijkstra_directed",
|
|
srcs = ["dijkstra_directed.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:bounded_dijkstra",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dijkstra_directed_test",
|
|
binary = ":dijkstra_directed",
|
|
grep_lines = ["Shortest path length: 8"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dijkstra_undirected",
|
|
srcs = ["dijkstra_undirected.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:bounded_dijkstra",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dijkstra_undirected_test",
|
|
binary = ":dijkstra_undirected",
|
|
grep_lines = ["Shortest path length: 4"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dijkstra_one_to_all",
|
|
srcs = ["dijkstra_one_to_all.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:bounded_dijkstra",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dijkstra_one_to_all_test",
|
|
binary = ":dijkstra_one_to_all",
|
|
grep_lines = [
|
|
"Distance to 1: 2",
|
|
"Distance to 2: 6",
|
|
"Distance to 3: 2",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dijkstra_sequential",
|
|
srcs = ["dijkstra_sequential.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:bounded_dijkstra",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dijkstra_sequential_test",
|
|
binary = ":dijkstra_sequential",
|
|
grep_lines = [
|
|
"Initial distance: 200",
|
|
"Distance_2_4: 2",
|
|
"Distance_8_1: 3",
|
|
"Distance_3_7: 4",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dijkstra_all_pairs_shortest_paths",
|
|
srcs = ["dijkstra_all_pairs_shortest_paths.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:bounded_dijkstra",
|
|
"@abseil-cpp//absl/algorithm:container",
|
|
"@abseil-cpp//absl/flags:flag",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/time",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dijkstra_all_pairs_shortest_paths_test",
|
|
binary = ":dijkstra_all_pairs_shortest_paths",
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_simple_shortest_path",
|
|
srcs = ["dag_simple_shortest_path.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_simple_shortest_path_test",
|
|
binary = ":dag_simple_shortest_path",
|
|
grep_lines = ["Shortest path length: 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_shortest_path_one_to_all",
|
|
srcs = ["dag_shortest_path_one_to_all.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"//ortools/graph:topologicalsorter",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_shortest_path_one_to_all_test",
|
|
binary = ":dag_shortest_path_one_to_all",
|
|
grep_lines = ["Length of shortest path to node 4: 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_shortest_path_sequential",
|
|
srcs = ["dag_shortest_path_sequential.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_shortest_path_sequential_test",
|
|
binary = ":dag_shortest_path_sequential",
|
|
grep_lines = [
|
|
"Initial distance: 200",
|
|
"Distance_2_4: 2",
|
|
"Distance_8_1: 100",
|
|
"Distance_3_7: 4",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "bfs_directed",
|
|
srcs = ["bfs_directed.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph:bfs",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "bfs_directed_test",
|
|
binary = ":bfs_directed",
|
|
grep_lines = ["Shortest path length (in arcs): 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "bfs_undirected",
|
|
srcs = ["bfs_undirected.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph:bfs",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "bfs_undirected_test",
|
|
binary = ":bfs_undirected",
|
|
grep_lines = ["Shortest path length (in arcs): 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "bfs_one_to_all",
|
|
srcs = ["bfs_one_to_all.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph:bfs",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "bfs_one_to_all_test",
|
|
binary = ":bfs_one_to_all",
|
|
grep_lines = ["Shortest path from 0 to 2 has length: 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "root_a_tree",
|
|
srcs = ["root_a_tree.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph",
|
|
"//ortools/graph:rooted_tree",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "root_a_tree_test",
|
|
binary = ":root_a_tree",
|
|
grep_lines = ["Depths:\n 0 -> 2"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "rooted_tree_paths",
|
|
srcs = ["rooted_tree_paths.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph:rooted_tree",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "rooted_tree_paths_test",
|
|
binary = ":rooted_tree_paths",
|
|
grep_lines = ["0 -> 4 [0, 1, 4]"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_simple_multiple_shortest_paths",
|
|
srcs = ["dag_simple_multiple_shortest_paths.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_simple_multiple_shortest_paths_test",
|
|
binary = ":dag_simple_multiple_shortest_paths",
|
|
grep_lines = [
|
|
"#1 shortest path has length: 2",
|
|
"#2 shortest path has length: 3",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_multiple_shortest_paths_one_to_all",
|
|
srcs = ["dag_multiple_shortest_paths_one_to_all.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/base:status_macros",
|
|
"//ortools/graph",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"//ortools/graph:topologicalsorter",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_multiple_shortest_paths_one_to_all_test",
|
|
binary = ":dag_multiple_shortest_paths_one_to_all",
|
|
grep_lines = [
|
|
"\t#1 shortest path to node 4 has length: 2",
|
|
"\t#2 shortest path to node 4 has length: 3",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_multiple_shortest_paths_sequential",
|
|
srcs = ["dag_multiple_shortest_paths_sequential.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_multiple_shortest_paths_sequential_test",
|
|
binary = ":dag_multiple_shortest_paths_sequential",
|
|
grep_lines = [
|
|
"\t#1 shortest path has length: 200",
|
|
"\t#2 shortest path has length: 202",
|
|
"\t#1 shortest path (2, 4) has length: 20",
|
|
"\t#2 shortest path (2, 4) has length: 102",
|
|
"\t#1 shortest path (8, 1) has length: 101",
|
|
"\t#2 shortest path (8, 1) has length: 108",
|
|
"\t#1 shortest path (3, 3) has length: 0",
|
|
"\t#2 shortest path (3, 3) has length: 112",
|
|
"\t#1 shortest path (0, 0) has length: 0",
|
|
"\t#2 shortest path (0, 0) has length: 111",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_simple_constrained_shortest_path",
|
|
srcs = ["dag_simple_constrained_shortest_path.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph:dag_constrained_shortest_path",
|
|
"//ortools/graph:dag_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_simple_constrained_shortest_path_test",
|
|
binary = ":dag_simple_constrained_shortest_path",
|
|
grep_lines = ["Constrained shortest path length: 4"],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "dag_constrained_shortest_path_sequential",
|
|
srcs = ["dag_constrained_shortest_path_sequential.cc"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"//ortools/graph",
|
|
"//ortools/graph:dag_constrained_shortest_path",
|
|
"@abseil-cpp//absl/strings",
|
|
],
|
|
)
|
|
|
|
run_binary_test(
|
|
name = "dag_constrained_shortest_path_sequential_test",
|
|
binary = ":dag_constrained_shortest_path_sequential",
|
|
grep_lines = [
|
|
"Initial distance: 200",
|
|
"Distance_2_3: 1",
|
|
"Distance_8_1: 100",
|
|
"Distance_3_7: 100",
|
|
],
|
|
)
|