50 template <
class TYPE_EDGES = u
int8_t>
66 TNodeID child_id_,
bool direction_child_to_parent =
false,
67 const TYPE_EDGES& edge_data = TYPE_EDGES())
68 :
id(child_id_),
reverse(direction_child_to_parent),
data(edge_data)
113 const size_t depth_level) = 0;
120 const TNodeID vroot, Visitor& user_visitor,
121 const size_t root_depth_level = 0)
const 123 const size_t next_depth_level = root_depth_level + 1;
126 const TListEdges& children = itChildren->second;
127 for (
auto itEdge = children.begin(); itEdge != children.end(); ++itEdge)
129 user_visitor.OnVisitNode(vroot, *itEdge, next_depth_level);
131 itEdge->id, user_visitor,
140 const TNodeID vroot, Visitor& user_visitor,
141 const size_t root_depth_level = 0)
const 143 const size_t next_depth_level = root_depth_level + 1;
146 const TListEdges& children = itChildren->second;
147 for (
auto itEdge = children.begin(); itEdge != children.end(); ++itEdge)
148 user_visitor.OnVisitNode(vroot, *itEdge, next_depth_level);
149 for (
auto itEdge = children.begin(); itEdge != children.end(); ++itEdge)
151 itEdge->id, user_visitor,
172 std::stringstream& m_s;
173 CMyVisitor(std::stringstream&
s) : m_s(
s) {}
177 TYPE_EDGES>::Visitor::tree_t::TEdgeInfo& edge_to_child,
178 const size_t depth_level)
override 181 << (edge_to_child.reverse ?
"<-" :
"->")
182 << edge_to_child.id << std::endl;
185 CMyVisitor myVisitor(
s);
186 s <<
root << std::endl;
std::map< TNodeID, TListEdges > TMapNode2ListEdges
TMapNode2ListEdges edges_to_children
The edges of each node.
A special kind of graph in the form of a tree with directed edges and optional edge annotations of te...
Abstract graph and tree data structures, plus generic graph algorithms.
Virtual base class for user-defined visitors.
bool reverse
True if edge direction is child->parent, false if it's parent->child.
virtual void OnVisitNode(const TNodeID parent, const typename tree_t::TEdgeInfo &edge_to_child, const size_t depth_level)=0
Virtual method to be implemented by the user and which will be called during the visit to a graph wit...
void visitDepthFirst(const TNodeID vroot, Visitor &user_visitor, const size_t root_depth_level=0) const
Depth-first visit of all children nodes of a given root (itself excluded from the visit)...
std::list< TEdgeInfo > TListEdges
TNodeID root
The root of the tree.
TNodeID id
The ID of the child node.
GLsizei const GLchar ** string
TEdgeInfo(TNodeID child_id_, bool direction_child_to_parent=false, const TYPE_EDGES &edge_data=TYPE_EDGES())
Edge constructor from data.
TYPE_EDGES data
User data for this edge.
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
void clear()
Empty all edge data and set "root" to INVALID_NODEID.
GLsizei GLsizei GLenum GLenum const GLvoid * data
std::string getAsTextDescription() const
Return a text representation of the tree spanned in a depth-first view, as in this example: ...
void visitBreadthFirst(const TNodeID vroot, Visitor &user_visitor, const size_t root_depth_level=0) const
Breadth-first visit of all children nodes of a given root (itself excluded from the visit)...