Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
util Namespace Reference

Namespaces

namespace  math
namespace  graph
namespace  internal

Classes

class  StatusBuilder
class  FlowGraph
class  BaseGraph
class  ArcPropertyIterator
struct  GraphTraits
class  ListGraph
class  StaticGraph
class  ReverseArcListGraph
class  ReverseArcStaticGraph
class  CompleteGraph
class  CompleteBipartiteGraph
class  BeginEndWrapper
class  BeginEndReverseIteratorWrapper
class  IntegerRangeIterator
class  IntegerRange
class  ChasingIterator
class  TopologicalSorter
class  UndirectedAdjacencyListsOfDirectedGraph

Typedefs

template<typename Graph, typename ArcIterator>
using ArcHeadIterator
template<typename Graph, typename ArcIterator>
using ArcOppositeArcIterator
typedef ListGraph Graph
typedef ::util::internal::DenseIntTopologicalSorterTpl< true > DenseIntStableTopologicalSorter
typedef ::util::internal::DenseIntTopologicalSorterTpl< false > DenseIntTopologicalSorter

Enumerations

enum  GraphToStringFormat { PRINT_GRAPH_ARCS , PRINT_GRAPH_ADJACENCY_LISTS , PRINT_GRAPH_ADJACENCY_LISTS_SORTED , PRINT_GRAPH_DOT }

Functions

StatusBuilder AbortedErrorBuilder ()
StatusBuilder AlreadyExistsErrorBuilder ()
StatusBuilder CancelledErrorBuilder ()
StatusBuilder DataLossErrorBuilder ()
StatusBuilder DeadlineExceededErrorBuilder ()
StatusBuilder FailedPreconditionErrorBuilder ()
StatusBuilder InternalErrorBuilder ()
StatusBuilder InvalidArgumentErrorBuilder ()
StatusBuilder NotFoundErrorBuilder ()
StatusBuilder OutOfRangeErrorBuilder ()
StatusBuilder PermissionDeniedErrorBuilder ()
StatusBuilder UnauthenticatedErrorBuilder ()
StatusBuilder ResourceExhaustedErrorBuilder ()
StatusBuilder UnavailableErrorBuilder ()
StatusBuilder UnimplementedErrorBuilder ()
StatusBuilder UnknownErrorBuilder ()
template<class UndirectedGraph, class NodeType>
std::vector< NodeType > GetConnectedComponentsTpl (NodeType num_nodes, const UndirectedGraph &graph)
template<class UndirectedGraph>
std::vector< int > GetConnectedComponents (int num_nodes, const UndirectedGraph &graph)
template<class IntVector, class Array>
void Permute (const IntVector &permutation, Array *array_to_permute)
 DEFINE_RANGE_BASED_ARC_ITERATION (ReverseArcListGraph, OutgoingOrOppositeIncoming)
 DEFINE_RANGE_BASED_ARC_ITERATION (ReverseArcStaticGraph, OutgoingOrOppositeIncoming)
template<class Graph>
std::string GraphToString (const Graph &graph, GraphToStringFormat format)
template<class Graph>
absl::Status WriteGraphToFile (const Graph &graph, const std::string &filename, bool directed, absl::Span< const int > num_nodes_with_color)
template<typename Iterator>
BeginEndWrapper< Iterator > BeginEndRange (Iterator begin, Iterator end)
template<typename Iterator>
BeginEndWrapper< Iterator > BeginEndRange (std::pair< Iterator, Iterator > begin_end)
template<typename MultiMap>
BeginEndWrapper< typename MultiMap::iterator > EqualRange (MultiMap &multi_map, const typename MultiMap::key_type &key)
template<typename MultiMap>
BeginEndWrapper< typename MultiMap::const_iterator > EqualRange (const MultiMap &multi_map, const typename MultiMap::key_type &key)
template<typename Container>
BeginEndReverseIteratorWrapper< Container > Reverse (const Container &c)
std::unique_ptr< StaticGraph<> > GenerateRandomMultiGraph (int num_nodes, int num_arcs, bool finalized, absl::BitGenRef gen)
std::unique_ptr< StaticGraph<> > GenerateRandomDirectedSimpleGraph (int num_nodes, int num_arcs, bool finalized, absl::BitGenRef gen)
std::unique_ptr< StaticGraph<> > GenerateRandomUndirectedSimpleGraph (int num_nodes, int num_edges, bool finalized, absl::BitGenRef gen)
template<class Graph>
std::unique_ptr< GraphCreate2DGridGraph (int64_t width, int64_t height)
template<typename T>
ABSL_MUST_USE_RESULT bool TopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order)
template<typename T>
ABSL_MUST_USE_RESULT bool TopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order, std::vector< T > *cycle)
template<typename T>
std::vector< T > TopologicalSortOrDie (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs)
template<typename T>
ABSL_MUST_USE_RESULT bool StableTopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order)
template<typename T>
ABSL_MUST_USE_RESULT bool StableTopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order, std::vector< T > *cycle)
template<typename T>
std::vector< T > StableTopologicalSortOrDie (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs)
ABSL_MUST_USE_RESULT std::vector< int > FindCycleInDenseIntGraph (int num_nodes, const std::vector< std::pair< int, int > > &arcs)
ABSL_MUST_USE_RESULT bool DenseIntTopologicalSort (int num_nodes, const std::vector< std::pair< int, int > > &arcs, std::vector< int > *topological_order)
std::vector< int > DenseIntStableTopologicalSortOrDie (int num_nodes, const std::vector< std::pair< int, int > > &arcs)
ABSL_MUST_USE_RESULT bool DenseIntStableTopologicalSort (int num_nodes, const std::vector< std::pair< int, int > > &arcs, std::vector< int > *topological_order)
std::vector< int > DenseIntTopologicalSortOrDie (int num_nodes, const std::vector< std::pair< int, int > > &arcs)
template<typename T>
bool TopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order)
template<typename T>
bool TopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order, std::vector< T > *cycle)
template<typename T>
bool StableTopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order)
template<typename T>
bool StableTopologicalSort (const std::vector< T > &nodes, const std::vector< std::pair< T, T > > &arcs, std::vector< T > *topological_order, std::vector< T > *cycle)
bool IsSubsetOf0N (absl::Span< const int > v, int n)
template<class Graph>
bool GraphHasSelfArcs (const Graph &graph)
template<class Graph>
bool GraphHasDuplicateArcs (const Graph &graph)
template<class Graph>
bool GraphIsSymmetric (const Graph &graph)
template<class Graph>
bool GraphIsWeaklyConnected (const Graph &graph)
template<class Graph>
std::unique_ptr< GraphCopyGraph (const Graph &graph)
template<class Graph>
std::unique_ptr< GraphRemapGraph (const Graph &graph, absl::Span< const int > new_node_index)
template<class Graph>
std::unique_ptr< GraphGetSubgraphOfNodes (const Graph &graph, absl::Span< const int > nodes)
template<class Graph>
 UndirectedAdjacencyListsOfDirectedGraph (const Graph &) -> UndirectedAdjacencyListsOfDirectedGraph< Graph >
template<class Graph>
std::vector< int > GetWeaklyConnectedComponents (const Graph &graph)
bool IsValidPermutation (absl::Span< const int > v)
template<class Graph>
std::unique_ptr< GraphRemoveSelfArcsAndDuplicateArcs (const Graph &graph)
template<class Graph>
void RemoveCyclesFromPath (const Graph &graph, std::vector< int > *arc_path)
template<class Graph>
bool PathHasCycle (const Graph &graph, absl::Span< const int > arc_path)
template<class Graph>
std::vector< int > ComputeOnePossibleReverseArcMapping (const Graph &graph, bool die_if_not_symmetric)

Typedef Documentation

◆ ArcHeadIterator

template<typename Graph, typename ArcIterator>
using util::ArcHeadIterator
Initial value:

Definition at line 381 of file graph.h.

◆ ArcOppositeArcIterator

template<typename Graph, typename ArcIterator>
using util::ArcOppositeArcIterator
Initial value:

Definition at line 387 of file graph.h.

◆ DenseIntStableTopologicalSorter

◆ DenseIntTopologicalSorter

◆ Graph

Definition at line 2065 of file graph.h.

Enumeration Type Documentation

◆ GraphToStringFormat

Enumerator
PRINT_GRAPH_ARCS 
PRINT_GRAPH_ADJACENCY_LISTS 
PRINT_GRAPH_ADJACENCY_LISTS_SORTED 
PRINT_GRAPH_DOT 

Definition at line 42 of file graph_io.h.

Function Documentation

◆ AbortedErrorBuilder()

StatusBuilder util::AbortedErrorBuilder ( )
inline

Definition at line 79 of file status_builder.h.

◆ AlreadyExistsErrorBuilder()

StatusBuilder util::AlreadyExistsErrorBuilder ( )
inline

Definition at line 83 of file status_builder.h.

◆ BeginEndRange() [1/2]

template<typename Iterator>
BeginEndWrapper< Iterator > util::BeginEndRange ( Iterator begin,
Iterator end )
inline

Definition at line 75 of file iterators.h.

◆ BeginEndRange() [2/2]

template<typename Iterator>
BeginEndWrapper< Iterator > util::BeginEndRange ( std::pair< Iterator, Iterator > begin_end)
inline

Definition at line 79 of file iterators.h.

◆ CancelledErrorBuilder()

StatusBuilder util::CancelledErrorBuilder ( )
inline

Definition at line 87 of file status_builder.h.

◆ ComputeOnePossibleReverseArcMapping()

template<class Graph>
std::vector< int > util::ComputeOnePossibleReverseArcMapping ( const Graph & graph,
bool die_if_not_symmetric )

Definition at line 397 of file util.h.

◆ CopyGraph()

template<class Graph>
std::unique_ptr< Graph > util::CopyGraph ( const Graph & graph)

Definition at line 273 of file util.h.

◆ Create2DGridGraph()

template<class Graph>
std::unique_ptr< Graph > util::Create2DGridGraph ( int64_t width,
int64_t height )

Definition at line 37 of file test_util.h.

◆ DataLossErrorBuilder()

StatusBuilder util::DataLossErrorBuilder ( )
inline

Definition at line 91 of file status_builder.h.

◆ DeadlineExceededErrorBuilder()

StatusBuilder util::DeadlineExceededErrorBuilder ( )
inline

Definition at line 95 of file status_builder.h.

◆ DEFINE_RANGE_BASED_ARC_ITERATION() [1/2]

util::DEFINE_RANGE_BASED_ARC_ITERATION ( ReverseArcListGraph ,
OutgoingOrOppositeIncoming  )

◆ DEFINE_RANGE_BASED_ARC_ITERATION() [2/2]

util::DEFINE_RANGE_BASED_ARC_ITERATION ( ReverseArcStaticGraph ,
OutgoingOrOppositeIncoming  )

◆ DenseIntStableTopologicalSort()

bool util::DenseIntStableTopologicalSort ( int num_nodes,
const std::vector< std::pair< int, int > > & arcs,
std::vector< int > * topological_order )
inline

Definition at line 530 of file topologicalsorter.h.

◆ DenseIntStableTopologicalSortOrDie()

std::vector< int > util::DenseIntStableTopologicalSortOrDie ( int num_nodes,
const std::vector< std::pair< int, int > > & arcs )
inline

Definition at line 575 of file topologicalsorter.h.

◆ DenseIntTopologicalSort()

bool util::DenseIntTopologicalSort ( int num_nodes,
const std::vector< std::pair< int, int > > & arcs,
std::vector< int > * topological_order )
inline

Definition at line 523 of file topologicalsorter.h.

◆ DenseIntTopologicalSortOrDie()

std::vector< int > util::DenseIntTopologicalSortOrDie ( int num_nodes,
const std::vector< std::pair< int, int > > & arcs )
inline

Definition at line 570 of file topologicalsorter.h.

◆ EqualRange() [1/2]

template<typename MultiMap>
BeginEndWrapper< typename MultiMap::const_iterator > util::EqualRange ( const MultiMap & multi_map,
const typename MultiMap::key_type & key )
inline

Definition at line 93 of file iterators.h.

◆ EqualRange() [2/2]

template<typename MultiMap>
BeginEndWrapper< typename MultiMap::iterator > util::EqualRange ( MultiMap & multi_map,
const typename MultiMap::key_type & key )
inline

Definition at line 88 of file iterators.h.

◆ FailedPreconditionErrorBuilder()

StatusBuilder util::FailedPreconditionErrorBuilder ( )
inline

Definition at line 99 of file status_builder.h.

◆ FindCycleInDenseIntGraph()

ABSL_MUST_USE_RESULT std::vector< int > util::FindCycleInDenseIntGraph ( int num_nodes,
const std::vector< std::pair< int, int > > & arcs )
inline

Definition at line 153 of file topologicalsorter.h.

◆ GenerateRandomDirectedSimpleGraph()

std::unique_ptr< StaticGraph<> > util::GenerateRandomDirectedSimpleGraph ( int num_nodes,
int num_arcs,
bool finalized,
absl::BitGenRef gen )

Definition at line 161 of file random_graph.cc.

◆ GenerateRandomMultiGraph()

std::unique_ptr< StaticGraph<> > util::GenerateRandomMultiGraph ( int num_nodes,
int num_arcs,
bool finalized,
absl::BitGenRef gen )

Definition at line 54 of file random_graph.cc.

◆ GenerateRandomUndirectedSimpleGraph()

std::unique_ptr< StaticGraph<> > util::GenerateRandomUndirectedSimpleGraph ( int num_nodes,
int num_edges,
bool finalized,
absl::BitGenRef gen )

Definition at line 167 of file random_graph.cc.

◆ GetConnectedComponents()

template<class UndirectedGraph>
std::vector< int > util::GetConnectedComponents ( int num_nodes,
const UndirectedGraph & graph )

Definition at line 65 of file connected_components.h.

◆ GetConnectedComponentsTpl()

template<class UndirectedGraph, class NodeType>
std::vector< NodeType > util::GetConnectedComponentsTpl ( NodeType num_nodes,
const UndirectedGraph & graph )

Definition at line 324 of file connected_components.h.

◆ GetSubgraphOfNodes()

template<class Graph>
std::unique_ptr< Graph > util::GetSubgraphOfNodes ( const Graph & graph,
absl::Span< const int > nodes )

Definition at line 305 of file util.h.

◆ GetWeaklyConnectedComponents()

template<class Graph>
std::vector< int > util::GetWeaklyConnectedComponents ( const Graph & graph)

Definition at line 144 of file util.h.

◆ GraphHasDuplicateArcs()

template<class Graph>
bool util::GraphHasDuplicateArcs ( const Graph & graph)

Definition at line 210 of file util.h.

◆ GraphHasSelfArcs()

template<class Graph>
bool util::GraphHasSelfArcs ( const Graph & graph)

Definition at line 202 of file util.h.

◆ GraphIsSymmetric()

template<class Graph>
bool util::GraphIsSymmetric ( const Graph & graph)

Definition at line 228 of file util.h.

◆ GraphIsWeaklyConnected()

template<class Graph>
bool util::GraphIsWeaklyConnected ( const Graph & graph)

Definition at line 257 of file util.h.

◆ GraphToString()

template<class Graph>
std::string util::GraphToString ( const Graph & graph,
GraphToStringFormat format )

Definition at line 79 of file graph_io.h.

◆ InternalErrorBuilder()

StatusBuilder util::InternalErrorBuilder ( )
inline

Definition at line 103 of file status_builder.h.

◆ InvalidArgumentErrorBuilder()

StatusBuilder util::InvalidArgumentErrorBuilder ( )
inline

Definition at line 107 of file status_builder.h.

◆ IsSubsetOf0N()

bool util::IsSubsetOf0N ( absl::Span< const int > v,
int n )

Definition at line 22 of file util.cc.

◆ IsValidPermutation()

bool util::IsValidPermutation ( absl::Span< const int > v)
inline

Definition at line 155 of file util.h.

◆ NotFoundErrorBuilder()

StatusBuilder util::NotFoundErrorBuilder ( )
inline

Definition at line 111 of file status_builder.h.

◆ OutOfRangeErrorBuilder()

StatusBuilder util::OutOfRangeErrorBuilder ( )
inline

Definition at line 115 of file status_builder.h.

◆ PathHasCycle()

template<class Graph>
bool util::PathHasCycle ( const Graph & graph,
absl::Span< const int > arc_path )

Definition at line 386 of file util.h.

◆ PermissionDeniedErrorBuilder()

StatusBuilder util::PermissionDeniedErrorBuilder ( )
inline

Definition at line 119 of file status_builder.h.

◆ Permute()

template<class IntVector, class Array>
void util::Permute ( const IntVector & permutation,
Array * array_to_permute )

Definition at line 1125 of file graph.h.

◆ RemapGraph()

template<class Graph>
std::unique_ptr< Graph > util::RemapGraph ( const Graph & graph,
absl::Span< const int > new_node_index )

Definition at line 286 of file util.h.

◆ RemoveCyclesFromPath()

template<class Graph>
void util::RemoveCyclesFromPath ( const Graph & graph,
std::vector< int > * arc_path )

Definition at line 361 of file util.h.

◆ RemoveSelfArcsAndDuplicateArcs()

template<class Graph>
std::unique_ptr< Graph > util::RemoveSelfArcsAndDuplicateArcs ( const Graph & graph)

Definition at line 339 of file util.h.

◆ ResourceExhaustedErrorBuilder()

StatusBuilder util::ResourceExhaustedErrorBuilder ( )
inline

Definition at line 127 of file status_builder.h.

◆ Reverse()

template<typename Container>
BeginEndReverseIteratorWrapper< Container > util::Reverse ( const Container & c)

Definition at line 115 of file iterators.h.

◆ StableTopologicalSort() [1/4]

template<typename T>
bool util::StableTopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order )

Definition at line 554 of file topologicalsorter.h.

◆ StableTopologicalSort() [2/4]

template<typename T>
ABSL_MUST_USE_RESULT bool util::StableTopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order )

Definition at line 554 of file topologicalsorter.h.

◆ StableTopologicalSort() [3/4]

template<typename T>
bool util::StableTopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order,
std::vector< T > * cycle )

Definition at line 562 of file topologicalsorter.h.

◆ StableTopologicalSort() [4/4]

template<typename T>
ABSL_MUST_USE_RESULT bool util::StableTopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order,
std::vector< T > * cycle )

Definition at line 562 of file topologicalsorter.h.

◆ StableTopologicalSortOrDie()

template<typename T>
std::vector< T > util::StableTopologicalSortOrDie ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs )

Definition at line 587 of file topologicalsorter.h.

◆ TopologicalSort() [1/4]

template<typename T>
bool util::TopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order )

Definition at line 538 of file topologicalsorter.h.

◆ TopologicalSort() [2/4]

template<typename T>
ABSL_MUST_USE_RESULT bool util::TopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order )

Definition at line 538 of file topologicalsorter.h.

◆ TopologicalSort() [3/4]

template<typename T>
bool util::TopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order,
std::vector< T > * cycle )

Definition at line 546 of file topologicalsorter.h.

◆ TopologicalSort() [4/4]

template<typename T>
ABSL_MUST_USE_RESULT bool util::TopologicalSort ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs,
std::vector< T > * topological_order,
std::vector< T > * cycle )

Definition at line 546 of file topologicalsorter.h.

◆ TopologicalSortOrDie()

template<typename T>
std::vector< T > util::TopologicalSortOrDie ( const std::vector< T > & nodes,
const std::vector< std::pair< T, T > > & arcs )

Definition at line 581 of file topologicalsorter.h.

◆ UnauthenticatedErrorBuilder()

StatusBuilder util::UnauthenticatedErrorBuilder ( )
inline

Definition at line 123 of file status_builder.h.

◆ UnavailableErrorBuilder()

StatusBuilder util::UnavailableErrorBuilder ( )
inline

Definition at line 131 of file status_builder.h.

◆ UndirectedAdjacencyListsOfDirectedGraph()

template<class Graph>
util::UndirectedAdjacencyListsOfDirectedGraph ( const Graph & ) ->UndirectedAdjacencyListsOfDirectedGraph< Graph >

◆ UnimplementedErrorBuilder()

StatusBuilder util::UnimplementedErrorBuilder ( )
inline

Definition at line 135 of file status_builder.h.

◆ UnknownErrorBuilder()

StatusBuilder util::UnknownErrorBuilder ( )
inline

Definition at line 139 of file status_builder.h.

◆ WriteGraphToFile()

template<class Graph>
absl::Status util::WriteGraphToFile ( const Graph & graph,
const std::string & filename,
bool directed,
absl::Span< const int > num_nodes_with_color )

Definition at line 115 of file graph_io.h.