|
| OutgoingArcIterator (const OutgoingArcIterator &)=default |
|
OutgoingArcIterator & | operator= (const OutgoingArcIterator &)=default |
|
| OutgoingArcIterator (const StaticGraph &graph, NodeIndexType node) |
|
| OutgoingArcIterator (const StaticGraph &graph, NodeIndexType node, ArcIndexType arc) |
|
bool | Ok () const |
|
ArcIndexType | Index () const |
|
void | Next () |
|
| DEFINE_STL_ITERATOR_FUNCTIONS (OutgoingArcIterator) |
|
StaticGraph< NodeIndexType, ArcIndexType > | FromArcs (NodeIndexType num_nodes, const ArcContainer &arcs) |
| StaticGraph implementation -----------------------------------------------—.
|
|
bool | IsArcValid (ArcIndexType arc) const |
|
| StaticGraph () |
|
| StaticGraph (NodeIndexType num_nodes, ArcIndexType arc_capacity) |
|
StaticGraph< NodeIndexType, ArcIndexType > | FromArcs (NodeIndexType num_nodes, const ArcContainer &arcs) |
| StaticGraph implementation -----------------------------------------------—.
|
|
NodeIndexType | Head (ArcIndexType arc) const |
|
NodeIndexType | Tail (ArcIndexType arc) const |
|
ArcIndexType | OutDegree (NodeIndexType node) const |
|
BeginEndWrapper< OutgoingArcIterator > | OutgoingArcs (NodeIndexType node) const |
|
BeginEndWrapper< OutgoingArcIterator > | OutgoingArcsStartingFrom (NodeIndexType node, ArcIndexType from) const |
|
absl::Span< const NodeIndexType > | operator[] (NodeIndexType node) const |
|
void | ReserveNodes (NodeIndexType bound) override |
|
void | ReserveArcs (ArcIndexType bound) override |
|
void | AddNode (NodeIndexType node) |
|
ArcIndexType | AddArc (NodeIndexType tail, NodeIndexType head) |
|
void | Build () |
|
void | Build (std::vector< ArcIndexType > *permutation) |
|
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 () |
|
template<typename NodeIndexType = int32_t, typename ArcIndexType = int32_t>
class util::StaticGraph< NodeIndexType, ArcIndexType >::OutgoingArcIterator
Definition at line 1448 of file graph.h.
void util::StaticGraph< NodeIndexType, ArcIndexType >::Build |
( |
std::vector< ArcIndexType > * | permutation | ) |
|
Implementation details: A reader may be surprised that we do many passes into the data where things could be done in one pass. For instance, during construction, we store the edges first, and then do a second pass at the end to compute the degree distribution.
This is because it is a lot more efficient cache-wise to do it this way. This was determined by various experiments, but can also be understood:
- during repetitive call to AddArc() a client usually accesses various areas of memory, and there is no reason to pollute the cache with possibly random access to degree[i].
- When the degrees are needed, we compute them in one go, maximizing the chance of cache hit during the computation.
If Arc are in order, start_ already contains the degree distribution.
Computes outgoing degree of each nodes. We have to clear start_, since at least the first arc was processed with arc_in_order_ == true.
Computes the forward arc permutation.
- Note
- this temporarily alters the start_ vector.
We use "tail_" (which now contains rubbish) to permute "head_" faster.
Restore in start_[i] the index of the first arc with tail >= i.
Recompute the correct tail_ vector
Definition at line 449 of file graph.h.
template<typename NodeIndexType = int32_t, typename ArcIndexType = int32_t>
Note(user): we lose a bit by returning a BeginEndWrapper<> on top of this iterator rather than a simple IntegerRange<> on the arc indices. On my computer: around 420M arcs/sec instead of 440M arcs/sec.
However, it is slightly more consistent to do it this way, and we don't have two different codes depending on the way a client iterates on the arcs.