Aleph-w 3.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
 
Convertconvert = nullptr
 

Detailed Description

template<class GT, typename Key, class Convert, class 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;
}
};
Node Node
The graph type.
Definition tpl_graph.H:432
Generic m-ary trees.
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:4060
DynList< T > maps(const C &c, Op op)
Classic map operation.
See also
graph_to_tree_node() Free function alternative
Tree_Node Target tree structure

Definition at line 211 of file graph_to_tree.H.

Constructor & Destructor Documentation

◆ Graph_To_Tree_Node()

template<class GT , typename Key , class Convert , class 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 260 of file graph_to_tree.H.

Member Function Documentation

◆ graph_to_tree() [1/2]

template<class GT , typename Key , class Convert , class 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]

◆ operator()() [1/2]

template<class GT , typename Key , class Convert , class 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 (must be acyclic)
grootNode to use as the tree root
convConverter functor instance
Returns
Root of the new Tree_Node<Key> tree
Exceptions
std::domain_errorIf the graph is not acyclic
std::bad_allocIf memory allocation fails

Definition at line 273 of file graph_to_tree.H.

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

◆ operator()() [2/2]

template<class GT , typename Key , class Convert , class 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<class GT , typename Key , class Convert , class SA = Dft_Show_Arc<GT>>
Convert* Aleph::Graph_To_Tree_Node< GT, Key, Convert, SA >::convert = nullptr
private

◆ sa

template<class GT , typename Key , class Convert , class 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: