Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
graph_generator.h File Reference

Go to the source code of this file.

Functions

template<typename Graph>
Graph GenerateCompleteUndirectedGraph (const typename Graph::NodeIndex num_nodes)
template<typename Graph>
Graph GenerateCompleteUndirectedBipartiteGraph (const typename Graph::NodeIndex num_nodes_1, const typename Graph::NodeIndex num_nodes_2)
template<typename Graph>
Graph GenerateCompleteDirectedBipartiteGraph (const typename Graph::NodeIndex num_nodes_1, const typename Graph::NodeIndex num_nodes_2)

Function Documentation

◆ GenerateCompleteDirectedBipartiteGraph()

template<typename Graph>
Graph GenerateCompleteDirectedBipartiteGraph ( const typename Graph::NodeIndex num_nodes_1,
const typename Graph::NodeIndex num_nodes_2 )

Generates a complete directed bipartite graph with num_nodes_1 and num_nodes_2 nodes in each part.

A complete bipartite graph is a graph in which all pairs of distinct nodes, one in each part, are connected by an edge. Edges are directed from the first part towards the second part. The graph is represented using the provided Graph template. If the chosen graph type requires a call to Build(), the user is expected to perform this call, possibly after tweaking the graph.

Consider using CompleteBipartiteGraph (util/graph/graph.h) instead of this function in production code, as it uses constant memory to store the graph. Instead, this function explicitly creates the graph using the template type, which is mostly useful for tests or when you have to tweak the graph after creation (i.e. a complete graph is just the core of your final graph).

Args: num_nodes_1: The number of nodes in the first part of the graph. num_nodes_2: The number of nodes in the second part of the graph.

Returns: A complete directed bipartite graph.

Definition at line 105 of file graph_generator.h.

◆ GenerateCompleteUndirectedBipartiteGraph()

template<typename Graph>
Graph GenerateCompleteUndirectedBipartiteGraph ( const typename Graph::NodeIndex num_nodes_1,
const typename Graph::NodeIndex num_nodes_2 )

Generates a complete undirected bipartite graph with num_nodes_1 and num_nodes_2 nodes in each part.

A complete bipartite graph is a graph in which all pairs of distinct nodes, one in each part, are connected by an edge. The graph is represented using the provided Graph template. If the chosen graph type requires a call to Build(), the user is expected to perform this call, possibly after tweaking the graph.

Args: num_nodes_1: The number of nodes in the first part of the graph. num_nodes_2: The number of nodes in the second part of the graph.

Returns: A complete undirected bipartite graph.

Definition at line 67 of file graph_generator.h.

◆ GenerateCompleteUndirectedGraph()

template<typename Graph>
Graph GenerateCompleteUndirectedGraph ( const typename Graph::NodeIndex num_nodes)

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. Generates a complete undirected graph with num_nodes nodes.

A complete graph is a graph in which all pairs of distinct nodes are connected by an edge. The graph is represented using the provided Graph template. If the chosen graph type requires a call to Build(), the user is expected to perform this call, possibly after tweaking the graph.

Consider using CompleteGraph (util/graph/graph.h) instead of this function in production code, as it uses constant memory to store the graph. Instead, this function explicitly creates the graph using the template type, which is mostly useful for tests or when you have to tweak the graph after creation (i.e. a complete graph is just the core of your final graph).

Args: num_nodes: The number of nodes in the graph.

Returns: A complete undirected graph.

Definition at line 37 of file graph_generator.h.