Classes | Namespaces | Functions
util.h File Reference
#include <algorithm>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include "ortools/base/hash.h"
#include "ortools/base/map_util.h"
#include "ortools/graph/connected_components.h"
#include "ortools/graph/graph.h"
#include "ortools/graph/iterators.h"
Include dependency graph for util.h:

Go to the source code of this file.

Classes

class  util::UndirectedAdjacencyListsOfDirectedGraph< Graph >
 This can be used to view a directed graph (that supports reverse arcs) from graph.h as un undirected graph: operator[](node) returns a pseudo-container that iterates over all nodes adjacent to "node" (from outgoing or incoming arcs). More...
 
class  util::UndirectedAdjacencyListsOfDirectedGraph< Graph >::AdjacencyListIterator
 

Namespaces

 util
 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
 

Functions

template<class Graph >
bool util::GraphHasSelfArcs (const Graph &graph)
 Here's a set of simple diagnosis tools. More...
 
template<class Graph >
bool util::GraphHasDuplicateArcs (const Graph &graph)
 
template<class Graph >
bool util::GraphIsSymmetric (const Graph &graph)
 
template<class Graph >
bool util::GraphIsWeaklyConnected (const Graph &graph)
 
template<class Graph >
std::unique_ptr< Graph > util::CopyGraph (const Graph &graph)
 Returns a fresh copy of a given graph. More...
 
template<class Graph >
std::unique_ptr< Graph > util::RemapGraph (const Graph &graph, const std::vector< int > &new_node_index)
 Creates a remapped copy of graph "graph", where node i becomes node new_node_index[i]. More...
 
template<class Graph >
std::unique_ptr< Graph > util::GetSubgraphOfNodes (const Graph &graph, const std::vector< int > &nodes)
 Gets the induced subgraph of "graph" restricted to the nodes in "nodes": the resulting graph will have exactly nodes.size() nodes, and its node #0 will be the former graph's node #nodes[0], etc. More...
 
template<class Graph >
std::vector< int > util::GetWeaklyConnectedComponents (const Graph &graph)
 Computes the weakly connected components of a directed graph that provides the OutgoingOrOppositeIncomingArcs() API, and returns them as a mapping from node to component index. More...
 
bool util::IsSubsetOf0N (const std::vector< int > &v, int n)
 Returns true iff the given vector is a subset of [0..n-1], i.e. More...
 
bool util::IsValidPermutation (const std::vector< int > &v)
 Returns true iff the given vector is a permutation of [0..size()-1]. More...
 
template<class Graph >
std::unique_ptr< Graph > util::RemoveSelfArcsAndDuplicateArcs (const Graph &graph)
 Returns a copy of "graph", without self-arcs and duplicate arcs. More...
 
template<class Graph >
void util::RemoveCyclesFromPath (const Graph &graph, std::vector< int > *arc_path)
 Given an arc path, changes it to a sub-path with the same source and destination but without any cycle. More...
 
template<class Graph >
bool util::PathHasCycle (const Graph &graph, const std::vector< int > &arc_path)
 Returns true iff the given path contains a cycle. More...
 
template<class Graph >
std::vector< int > util::ComputeOnePossibleReverseArcMapping (const Graph &graph, bool die_if_not_symmetric)
 Returns a vector representing a mapping from arcs to arcs such that each arc is mapped to another arc with its (tail, head) flipped, if such an arc exists (otherwise it is mapped to -1). More...