Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
graphs.h
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// Temporary utility class needed as long as we have two slightly
15// different graph interface: The one in ebert_graph.h and the one in graph.h
16
17#ifndef OR_TOOLS_GRAPH_GRAPHS_H_
18#define OR_TOOLS_GRAPH_GRAPHS_H_
19
20#include <vector>
21
23
24namespace operations_research {
25
26// Since StarGraph does not have exactly the same interface as the other
27// graphs, we define a correspondence there.
28template <typename Graph>
29struct Graphs {
30 typedef typename Graph::ArcIndex ArcIndex;
31 typedef typename Graph::NodeIndex NodeIndex;
33 return graph.OppositeArc(arc);
34 }
35 static bool IsArcValid(const Graph& graph, ArcIndex arc) {
36 return graph.IsArcValid(arc);
37 }
39 return graph.node_capacity();
40 }
42 return graph.arc_capacity();
43 }
44 static void Build(Graph* graph) { graph->Build(); }
45 static void Build(Graph* graph, std::vector<ArcIndex>* permutation) {
46 graph->Build(permutation);
47 }
48};
49
50template <>
53#if defined(_MSC_VER)
56#else
57 typedef typename Graph::ArcIndex ArcIndex;
58 typedef typename Graph::NodeIndex NodeIndex;
59#endif
61 return graph.Opposite(arc);
62 }
63 static bool IsArcValid(const Graph& graph, ArcIndex arc) {
64 return graph.CheckArcValidity(arc);
65 }
67 return graph.max_num_nodes();
68 }
70 return graph.max_num_arcs();
71 }
72 static void Build(Graph* graph) {}
73 static void Build(Graph* graph, std::vector<ArcIndex>* permutation) {
74 permutation->clear();
75 }
76};
77
78} // namespace operations_research
79
80#endif // OR_TOOLS_GRAPH_GRAPHS_H_
GraphType graph
int arc
In SWIG mode, we don't want anything besides these top-level includes.
static ArcIndex ArcReservation(const Graph &graph)
Definition graphs.h:69
static void Build(Graph *graph, std::vector< ArcIndex > *permutation)
Definition graphs.h:73
static ArcIndex OppositeArc(const Graph &graph, ArcIndex arc)
Definition graphs.h:60
static NodeIndex NodeReservation(const Graph &graph)
Definition graphs.h:66
static bool IsArcValid(const Graph &graph, ArcIndex arc)
Definition graphs.h:63
static void Build(Graph *graph)
Definition graphs.h:44
static ArcIndex ArcReservation(const Graph &graph)
Definition graphs.h:41
Graph::NodeIndex NodeIndex
Definition graphs.h:31
static bool IsArcValid(const Graph &graph, ArcIndex arc)
Definition graphs.h:35
static ArcIndex OppositeArc(const Graph &graph, ArcIndex arc)
Definition graphs.h:32
static NodeIndex NodeReservation(const Graph &graph)
Definition graphs.h:38
static void Build(Graph *graph, std::vector< ArcIndex > *permutation)
Definition graphs.h:45
Graph::ArcIndex ArcIndex
Definition graphs.h:30