![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
#include <graph.h>
Public Member Functions | |
OutgoingArcIterator (const ListGraph &graph, NodeIndexType node) | |
OutgoingArcIterator (const ListGraph &graph, NodeIndexType node, ArcIndexType arc) | |
bool | Ok () const |
ArcIndexType | Index () const |
void | Next () |
DEFINE_STL_ITERATOR_FUNCTIONS (OutgoingArcIterator) | |
bool | IsArcValid (ArcIndexType arc) const |
ListGraph () | |
ListGraph (NodeIndexType num_nodes, ArcIndexType arc_capacity) | |
void | AddNode (NodeIndexType node) |
ArcIndexType | AddArc (NodeIndexType tail, NodeIndexType head) |
void | Build () |
void | Build (std::vector< ArcIndexType > *permutation) |
ArcIndexType | OutDegree (NodeIndexType node) const |
BeginEndWrapper< OutgoingArcIterator > | OutgoingArcs (NodeIndexType node) const |
BeginEndWrapper< OutgoingArcIterator > | OutgoingArcsStartingFrom (NodeIndexType node, ArcIndexType from) const |
BeginEndWrapper< OutgoingHeadIterator > | operator[] (NodeIndexType node) const |
NodeIndexType | Tail (ArcIndexType arc) const |
Returns the tail/head of a valid arc. | |
NodeIndexType | Head (ArcIndexType arc) const |
void | ReserveNodes (NodeIndexType bound) override |
void | ReserveArcs (ArcIndexType bound) override |
bool | IsArcValid (ArcIndexType arc) const |
![]() | |
BaseGraph () | |
BaseGraph (const BaseGraph &)=default | |
BaseGraph & | operator= (const BaseGraph &)=default |
virtual | ~BaseGraph ()=default |
NodeIndexType | num_nodes () const |
NodeIndexType | size () const |
ArcIndexType | num_arcs () const |
Returns the number of valid arcs in the graph. | |
IntegerRange< NodeIndex > | AllNodes () const |
BaseGraph implementation -------------------------------------------------—. | |
IntegerRange< ArcIndex > | AllForwardArcs () const |
bool | IsNodeValid (NodeIndexType node) const |
Returns true if the given node is a valid node of the graph. | |
bool | IsArcValid (ArcIndexType arc) const |
NodeIndexType | node_capacity () const |
Capacity reserved for future nodes, always >= num_nodes_. | |
ArcIndexType | arc_capacity () const |
Capacity reserved for future arcs, always >= num_arcs_. | |
void | Reserve (NodeIndexType node_capacity, ArcIndexType arc_capacity) |
void | FreezeCapacities () |
BaseGraph () | |
BaseGraph (const BaseGraph &)=default | |
BaseGraph & | operator= (const BaseGraph &)=default |
virtual | ~BaseGraph ()=default |
NodeIndexType | num_nodes () const |
NodeIndexType | size () const |
ArcIndexType | num_arcs () const |
Returns the number of valid arcs in the graph. | |
IntegerRange< NodeIndex > | AllNodes () const |
BaseGraph implementation -------------------------------------------------—. | |
IntegerRange< ArcIndex > | AllForwardArcs () const |
bool | IsNodeValid (NodeIndexType node) const |
Returns true if the given node is a valid node of the graph. | |
bool | IsArcValid (ArcIndexType arc) const |
NodeIndexType | node_capacity () const |
Capacity reserved for future nodes, always >= num_nodes_. | |
ArcIndexType | arc_capacity () const |
Capacity reserved for future arcs, always >= num_arcs_. | |
void | Reserve (NodeIndexType node_capacity, ArcIndexType arc_capacity) |
void | FreezeCapacities () |
Additional Inherited Members | |
![]() | |
typedef NodeIndexType | NodeIndex |
typedef ArcIndexType | ArcIndex |
typedef NodeIndexType | NodeIndex |
typedef ArcIndexType | ArcIndex |
![]() | |
static constexpr bool | kHasNegativeReverseArcs |
static const NodeIndexType | kNilNode |
static const ArcIndexType | kNilArc |
static constexpr bool | kHasNegativeReverseArcs |
static const NodeIndexType | kNilNode |
static const ArcIndexType | kNilArc |
![]() | |
void | ComputeCumulativeSum (std::vector< ArcIndexType > *v) |
Functions commented when defined because they are implementation details. | |
void | BuildStartAndForwardHead (SVector< NodeIndexType > *head, std::vector< ArcIndexType > *start, std::vector< ArcIndexType > *permutation) |
void | ComputeCumulativeSum (std::vector< ArcIndexType > *v) |
Functions commented when defined because they are implementation details. | |
void | BuildStartAndForwardHead (SVector< NodeIndexType > *head, std::vector< ArcIndexType > *start, std::vector< ArcIndexType > *permutation) |
![]() | |
NodeIndexType | num_nodes_ |
NodeIndexType | node_capacity_ |
ArcIndexType | num_arcs_ |
ArcIndexType | arc_capacity_ |
bool | const_capacities_ |
NodeIndexType | num_nodes_ |
NodeIndexType | node_capacity_ |
ArcIndexType | num_arcs_ |
ArcIndexType | arc_capacity_ |
bool | const_capacities_ |
|
inline |
|
inline |
ArcIndexType util::ListGraph< NodeIndexType, ArcIndexType >::AddArc | ( | NodeIndexType | tail, |
NodeIndexType | head ) |
Adds an arc to the graph and returns its current index which will always be num_arcs() - 1. It will also automatically call AddNode(tail) and AddNode(head). It will fail in DEBUG mode if the capacities are fixed and this cause the graph to grow beyond them.
void util::ListGraph< NodeIndexType, ArcIndexType >::AddNode | ( | NodeIndexType | node | ) |
|
inline |
Some graph implementations need to be finalized with Build() before they can be used. After Build() is called, the arc indices (which had been the return values of previous AddArc() calls) may change: the new index of former arc #i will be stored in permutation[i] if #i is smaller than permutation.size() or will be unchanged otherwise. If you don't care about these, just call the simple no-output version Build().
void util::ListGraph< NodeIndexType, ArcIndexType >::Build | ( | std::vector< ArcIndexType > * | permutation | ) |
util::ListGraph< NodeIndexType, ArcIndexType >::OutgoingArcIterator::DEFINE_STL_ITERATOR_FUNCTIONS | ( | OutgoingArcIterator | ) |
NodeIndexType util::ListGraph< NodeIndexType, ArcIndexType >::Head | ( | ArcIndexType | arc | ) | const |
|
inline |
( | ArcIndexType | arc | ) | const |
Returns true if the given arc is a valid arc of the graph.
|
inline |
|
inline |
|
inline |
Reserve space for the graph at construction and do not allow it to grow beyond that, see FreezeCapacities(). This constructor also makes any nodes in [0, num_nodes) valid.
|
inline |
|
inline |
BeginEndWrapper< typename ListGraph< NodeIndexType, ArcIndexType >::OutgoingHeadIterator > util::ListGraph< NodeIndexType, ArcIndexType >::operator[] | ( | NodeIndexType | node | ) | const |
ArcIndexType util::ListGraph< NodeIndexType, ArcIndexType >::OutDegree | ( | NodeIndexType | node | ) | const |
Graph jargon: the "degree" of a node is its number of arcs. The out-degree is the number of outgoing arcs. The in-degree is the number of incoming arcs, and is only available for some graph implementations, below.
ListGraph<>::OutDegree() works in O(degree).
BeginEndWrapper< OutgoingArcIterator > util::ListGraph< NodeIndexType, ArcIndexType >::OutgoingArcs | ( | NodeIndexType | node | ) | const |
Allows to iterate over the forward arcs that verify Tail(arc) == node. This is meant to be used as: for (const ArcIndex arc : graph.OutgoingArcs(node)) { ... }
BeginEndWrapper< OutgoingArcIterator > util::ListGraph< NodeIndexType, ArcIndexType >::OutgoingArcsStartingFrom | ( | NodeIndexType | node, |
ArcIndexType | from ) const |
Advanced usage. Same as OutgoingArcs(), but allows to restart the iteration from an already known outgoing arc of the given node.
|
overridevirtual |
Reimplemented from util::BaseGraph< NodeIndexType, ArcIndexType, false >.
|
overridevirtual |
Reimplemented from util::BaseGraph< NodeIndexType, ArcIndexType, false >.
NodeIndexType util::ListGraph< NodeIndexType, ArcIndexType >::Tail | ( | ArcIndexType | arc | ) | const |