This commit is contained in:
Corentin Le Molgat
2023-04-03 18:26:06 +02:00
parent df0f6aaf12
commit 47ce2eae9f
7 changed files with 56 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ and .Net. Each language have different requirements for the code samples.
```cpp
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <sstream>
#include "ortools/constraint_solver/routing.h"

View File

@@ -15,6 +15,7 @@
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <limits>
#include <string>

View File

@@ -4,62 +4,65 @@ This directory contains data structures and algorithms for graph and
network flow problems.
It contains in particular:
* a compact and efficient graph representation
([EbertGraph](https://dl.acm.org/doi/abs/10.1145/214762.214769)),
* a compact and efficient graph representation,
[`EbertGraph`](https://dl.acm.org/doi/abs/10.1145/214762.214769),
which is used for most of the algorithms herein, unless specified otherwise.
* well-tuned algorithms (for example shortest paths and
[Hamiltonian paths](https://en.wikipedia.org/wiki/Hamiltonian_path).)
* hard-to-find algorithms (Hamiltonian paths, push-relabel flow algorithms.)
* other, more common algorithm, that are useful to use with EbertGraph.
* well-tuned algorithms (for example shortest, paths and
[Hamiltonian paths](https://en.wikipedia.org/wiki/Hamiltonian_path)).
* hard-to-find algorithms (Hamiltonian paths, push-relabel flow algorithms).
* other, more common algorithm, that are useful to use with `EbertGraph`.
Graph representations:
* [ebert_graph.h](./ebert_graph.h): Entry point for a directed graph class.
* [digraph.h](./digraph.h): Entry point for a directed graph class.
* [ebert_graph.h](./ebert_graph.h): entry point for a directed graph class.
* [digraph.h](./digraph.h): entry point for a directed graph class.
To be deprecated by `ebert_graph.h`.
Paths:
* [shortestpaths.h](./shortestpaths.h): Entry point for shortest path computations.
* [shortestpaths.h](./shortestpaths.h): entry point for shortest paths.
Includes [Dijkstra](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) and
[Bellman-Ford](https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm) algorithms.
* [hamiltonian_path.h](./hamiltonian_path.h): Entry point for computing minimum
[Bellman-Ford](https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm)
algorithms. These implementations are being deprecated.
* [hamiltonian_path.h](./hamiltonian_path.h): entry point for computing minimum
[Hamiltonian paths](https://en.wikipedia.org/wiki/Hamiltonian_path) and
cycles on directed graphs with costs on arcs, using a dynamic-programming
algorithm (Does not need `ebert_graph.h` or `digraph.h`.)
algorithm. (It does not need `ebert_graph.h` or `digraph.h`.)
Graph decompositions:
* [connected_components.h](./connected_components.h): Entry point for computing connected
components in an undirected graph. (Does not need `ebert_graph.h` or `digraph.h`.)
* [connected_components.h](./connected_components.h): entry point for computing
connected components in an undirected graph. (It does not need `ebert_graph.h`
or `digraph.h`.)
* [strongly_connected_components.h](./strongly_connected_components.h): Entry point for
computing the strongly connected components of a directed graph, based on an algorithm of Tarjan.
* [strongly_connected_components.h](./strongly_connected_components.h): entry
point for computing the strongly connected components of a directed graph,
based on Tarjan's algorithm.
* [cliques.h](./cliques.h): Entry point for computing maximum cliques and clique covers in a directed graph,
based on the Bron-Kerbosch algorithm. (Does not need `ebert_graph.h` or `digraph.h`.)
* [cliques.h](./cliques.h): entry point for computing maximum cliques and
clique covers in a directed graph, based on the Bron-Kerbosch algorithm.
(It does not need `ebert_graph.h` or `digraph.h`.)
Flow algorithms:
* [linear_assignment.h](./linear_assignment.h): Entry point for solving linear sum assignment problems
(classical assignment problems where the total cost is the sum of the costs
of each arc used) on directed graphs with arc costs, based on a push-relabel
algorithm of Goldberg and Kennedy.
* [linear_assignment.h](./linear_assignment.h): entry point for solving linear
sum assignment problems (classical assignment problems where the total cost is
the sum of the costs of each arc used) on directed graphs with arc costs,
based on the Goldberg-Kennedy push-relabel algorithm.
* [max_flow.h](./max_flow.h): Entry point for computing maximum flows on directed graphs with
arc capacities, based on a push-relabel algorithm of Goldberg and Tarjan.
* [max_flow.h](./max_flow.h): entry point for computing maximum flows on
directed graphs with arc capacities, based on the Goldberg-Tarjan
push-relabel algorithm.
* [min_cost_flow.h](./min_cost_flow.h): Entry point for computing minimum-cost flows on directed
graphs with arc capacities, arc costs, and supplies/demands at nodes, based on
a push-relabel algorithm of Goldberg and Tarjan.
* [min_cost_flow.h](./min_cost_flow.h): entry point for computing minimum-cost
flows on directed graphs with arc capacities, arc costs, and supplies/demands
at nodes, based on the Goldberg-Tarjan push-relabel algorithm.
## Wrappers
* [python](python): the SWIG code that makes the wrapper available in Python,
* [python](python): the SWIG code that makes the wrapper available in Python
and its unit tests.
* [java](java): the SWIG code that makes the wrapper available in Java,
* [java](java): the SWIG code that makes the wrapper available in Java
and its unit tests.
* [csharp](csharp): the SWIG code that makes the wrapper available in C#,
* [csharp](csharp): the SWIG code that makes the wrapper available in C#
and its unit tests.
## Samples

View File

@@ -16,6 +16,7 @@
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <string>
#include <vector>

View File

@@ -15,6 +15,7 @@
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <memory>
#include <string>

View File

@@ -14,11 +14,11 @@
# Utilities to load native libraries in java or-tools.
cc_binary(
name = "libjniortools.so",
target_compatible_with = select({
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
linkshared = True,
target_compatible_with = select({
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
deps = [
"//ortools/algorithms/java:knapsacksolver_cc",
@@ -32,11 +32,11 @@ cc_binary(
cc_binary(
name = "libjniortools.dylib",
target_compatible_with = select({
"@platforms//os:osx": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
linkshared = True,
target_compatible_with = select({
"@platforms//os:osx": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
deps = [
"//ortools/algorithms/java:knapsacksolver_cc",
@@ -50,11 +50,11 @@ cc_binary(
cc_binary(
name = "jniortools.dll",
target_compatible_with = select({
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
linkshared = True,
target_compatible_with = select({
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
deps = [
"//ortools/algorithms/java:knapsacksolver_cc",
@@ -71,9 +71,9 @@ java_library(
srcs = ["Loader.java"],
visibility = ["//visibility:public"],
runtime_deps = select({
"@platforms//os:linux": ["//ortools/java/com/google/ortools:libjniortools.so"],
"@platforms//os:osx": ["//ortools/java/com/google/ortools:libjniortools.dylib"],
"@platforms//os:windows": ["//ortools/java/com/google/ortools:jniortools.dll"],
"@platforms//os:linux": ["//ortools/java/com/google/ortools:libjniortools.so"],
"@platforms//os:osx": ["//ortools/java/com/google/ortools:libjniortools.dylib"],
"@platforms//os:windows": ["//ortools/java/com/google/ortools:jniortools.dll"],
}),
deps = [
"@maven//:net_java_dev_jna_jna",

View File

@@ -105,8 +105,8 @@ public class Loader {
if (!loaded) {
try {
// prints the name of the Operating System
//System.out.println("OS: " + System.getProperty("os.name"));
//System.out.println("Library: " + System.mapLibraryName("jniortools"));
// System.out.println("OS: " + System.getProperty("os.name"));
// System.out.println("Library: " + System.mapLibraryName("jniortools"));
System.loadLibrary("jniortools");
loaded = true;