![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
Class designed to store the tree of paths from a root node to a set of nodes in a very compact way (over performance). Memory consumption is in O(n) (n being the size of the tree) where node indices are "very" non-contiguous (extremely sparse node indices). It keeps node-sorted arrays of node and parent pairs, which can be accessed in O(log(n)) with a binary search. The creation of the tree is done in O(n*log(n)) time.
Definition at line 355 of file shortest_paths.h.
#include <shortest_paths.h>
Public Member Functions | |
PathTree () | |
void | Initialize (absl::Span< const NodeIndex > paths, absl::Span< const NodeIndex > destinations) |
NodeIndex | GetParent (NodeIndex node) const |
void | GetPath (NodeIndex from, NodeIndex to, std::vector< NodeIndex > *path) const |
|
inline |
Definition at line 357 of file shortest_paths.h.
NodeIndex operations_research::PathTree< NodeIndex, kNilNode >::GetParent | ( | NodeIndex | node | ) | const |
Returns the parent (predecessor) of node in the tree in O(log(path_tree_size)), where path_tree_size is the size of nodes_.
Definition at line 419 of file shortest_paths.h.
void operations_research::PathTree< NodeIndex, kNilNode >::GetPath | ( | NodeIndex | from, |
NodeIndex | to, | ||
std::vector< NodeIndex > * | path ) const |
Returns the path from node from to node to in the tree in O(log(path_tree_size) + path_size), where path_tree_size is the size of nodes_ and path_size is the size of the resulting path.
from and to are not connected.
Definition at line 431 of file shortest_paths.h.
void operations_research::PathTree< NodeIndex, kNilNode >::Initialize | ( | absl::Span< const NodeIndex > | paths, |
absl::Span< const NodeIndex > | destinations ) |
Initializes the tree from a non-sparse representation of the path tree represented by paths. The tree is reduced to the subtree in which nodes in destinations are the leafs.
Definition at line 381 of file shortest_paths.h.