Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA > Class Template Reference

Functor class to convert a tree graph to Tree_Node structure. More...

#include <graph_to_tree.H>

Public Member Functions

 Graph_To_Tree_Node (SA __sa=SA())
 
Tree_Node< Key > * operator() (GT &g, typename GT::Node *groot, Convert &&conv=Convert())
 Convert a tree graph to Tree_Node structure.
 
Tree_Node< Key > * operator() (GT &g, typename GT::Node *groot, Convert &conv)
 

Private Member Functions

void graph_to_tree (typename GT::Node *groot, Tree_Node< Key > *troot)
 
Tree_Node< Key > * graph_to_tree (GT &g, typename GT::Node *groot, Convert &conv)
 

Private Attributes

SA sa
 
Convert * convert = nullptr
 

Detailed Description

template<AlephGraph GT, typename Key, class Convert, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
class Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >

Functor class to convert a tree graph to Tree_Node structure.

Provides a callable interface for converting spanning trees from graph representation to Tree_Node<Key> representation.

This class version offers more flexibility than the free function, allowing the arc filter to be configured at construction time.

Template Parameters

  • GT: Graph type (derived from List_Graph)
  • Key: Data type to store in tree nodes
  • Convert: Functor class with operator()(gnode, tnode) that copies data from graph nodes to tree nodes
  • SA: Arc filter class (default: show all arcs)

Usage Example

struct MyConvert {
void operator()(Graph::Node* gn, Tree_Node<int>* tn) {
tn->get_key() = gn->get_info().id;
}
};
Graph_To_Tree_Node<Graph, int, MyConvert> converter;
auto* root = converter(g, start_node);
Node Node
The graph type.
Definition tpl_graph.H:443
Forward declaration used by CRTP helpers before the full node definition.
T & get_key() noexcept
Returns a modifiable reference to the node contents.
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
Definition gmpfrxx.h:4138
See also
graph_to_tree_node() Free function alternative
Tree_Node Target tree structure

Definition at line 320 of file graph_to_tree.H.

Constructor & Destructor Documentation

◆ Graph_To_Tree_Node()

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::Graph_To_Tree_Node ( SA  __sa = SA())
inline

Definition at line 359 of file graph_to_tree.H.

Member Function Documentation

◆ graph_to_tree() [1/2]

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Tree_Node< Key > * Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::graph_to_tree ( GT &  g,
typename GT::Node *  groot,
Convert &  conv 
)
inlineprivate

◆ graph_to_tree() [2/2]

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::graph_to_tree ( typename GT::Node *  groot,
Tree_Node< Key > *  troot 
)
inlineprivate

◆ operator()() [1/2]

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Tree_Node< Key > * Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::operator() ( GT &  g,
typename GT::Node *  groot,
Convert &&  conv = Convert() 
)
inline

Convert a tree graph to Tree_Node structure.

Parameters
gThe tree graph to convert (acyclic by the arcs that the filter shows)
grootNode to use as the tree root
convConverter functor instance
Returns
Root of the new Tree_Node<Key> tree
Exceptions
std::domain_errorIf the arcs that the filter shows have a cycle
std::bad_allocIf memory allocation fails
anythingthat conv throws. If something throws, the tree that was built is freed.
Note
The arcs are not marked, so that the graph can be converted again.

Definition at line 378 of file graph_to_tree.H.

References Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::graph_to_tree().

◆ operator()() [2/2]

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Tree_Node< Key > * Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::operator() ( GT &  g,
typename GT::Node *  groot,
Convert &  conv 
)
inline

Member Data Documentation

◆ convert

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Convert* Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::convert = nullptr
private

◆ sa

template<AlephGraph GT, typename Key , class Convert , ArcFilter< GT > SA = Dft_Show_Arc<GT>>
SA Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::sa
private

The documentation for this class was generated from the following file: