47struct PCNodeChildrenIterable;
48struct PCNodeNeighborsIterable;
59 : m_node(
node), m_pred(pred), m_curr(curr) { }
100 unsigned long count() const;
109 , m_first(first != nullptr
111 : (
node->m_child1 != nullptr ?
node->m_child1 :
node->getParent())) {
112 if (this->m_first ==
nullptr) {
116 || this->m_first->isParentOf(this->m_node));
124 unsigned long count() const;
131template<
bool dfs,
bool reverse = false>
134 typename std::conditional<dfs, std::vector<PCNode*>, std::deque<PCNode*>>::type;
153 std::function<
bool(
PCNode*)> visit = return_true,
154 std::function<
bool(
PCNode*)> descend_from = return_true)
155 : m_pending({start}), m_visit(std::move(visit)), m_descend(std::move(descend_from)) {
156 if (!m_pending.empty() && !m_visit(top())) {
172 return m_pending.back();
174 return m_pending.front();
187 OGDF_DEPRECATED(
"Calling FilteringPCTreeWalk++ will copy the array of pending nodes")
200 m_pending.pop_back();
202 m_pending.pop_front();
204 if (m_descend(
node)) {
205 std::copy(
node->children().begin(),
node->children().end(),
206 std::back_inserter(m_pending));
208 std::reverse(m_pending.end() -
node->getChildCount(), m_pending.end());
211 }
while (!m_pending.empty() && !m_visit(top()));
214 explicit operator bool()
const {
return valid(); }
216 bool valid()
const {
return !m_pending.empty(); }
A node in a PC-tree that is either a P-node, C-node or leaf.
Basic declarations, included by all source files.
Class for the representation of nodes.
A DFS or BFS through a PCTree.
typename std::conditional< dfs, std::vector< PCNode * >, std::deque< PCNode * > >::type container_type
bool operator!=(const FilteringPCTreeWalk &rhs) const
static bool return_true(PCNode *n)
FilteringPCTreeWalk(const PCTree &T, PCNode *start, std::function< bool(PCNode *)> visit=return_true, std::function< bool(PCNode *)> descend_from=return_true)
FilteringPCTreeWalk()=default
bool operator==(const FilteringPCTreeWalk &rhs) const
FilteringPCTreeWalk end() const
std::ptrdiff_t difference_type
FilteringPCTreeWalk & begin()
std::function< bool(PCNode *)> m_visit
FilteringPCTreeWalk & operator++()
Increment operator (prefix, returns result).
std::input_iterator_tag iterator_category
std::function< bool(PCNode *)> m_descend
A node in a PC-tree that is either a P-node, C-node or leaf.
bool isParentOf(const PCNode *other) const
std::forward_iterator_tag iterator_category
bool operator==(const PCNodeIterator &rhs) const
bool operator!=(const PCNodeIterator &rhs) const
PCNode & operator->() const
PCNodeIterator operator++(int)
Increment operator (postfix, returns previous value).
PCNodeIterator & operator++()
Increment operator (prefix, returns result).
std::ptrdiff_t difference_type
PCNodeIterator(PCNode *node, PCNode *pred, PCNode *curr)
PCNode * operator*() const
A PC-tree represents a set of cyclic orders of its leaves by labeling its inner nodes as either P- or...
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Reverse< T > reverse(T &container)
Provides iterators for container to make it easily iterable in reverse.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
PCNodeChildrenIterable(PCNode *node)
PCNodeIterator begin() const noexcept
PCNodeNeighborsIterable(PCNode *node, PCNode *first=nullptr)
PCNodeIterator begin() const noexcept