Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
graph_to_tree_example.cc File Reference

Educational examples for converting graphs to tree structures. More...

#include <iostream>
#include <tpl_graph.H>
#include <tpl_tree_node.H>
#include <graph_to_tree.H>
#include <tpl_graph_utils.H>
#include <generate_tree.H>
Include dependency graph for graph_to_tree_example.cc:

Go to the source code of this file.

Functions

template<typename T >
void print_tree (Tree_Node< T > *node, int depth=0)
 
template<typename T >
void delete_tree (Tree_Node< T > *node)
 
int main ()
 

Detailed Description

Educational examples for converting graphs to tree structures.

WHY CONVERT GRAPH TO TREE?

  • Trees are simpler than graphs (no cycles)
  • Tree algorithms are often more efficient
  • Tree visualization is easier (ntreepic, btreepic)
  • Spanning trees capture connectivity

IMPORTANT DISTINCTION:

If your graph has cycles, you must first extract a spanning tree, then convert that spanning tree to Tree_Node format.

COMPILE & RUN:

Built as part of Aleph-w examples, or manually with the library.

Definition in file graph_to_tree_example.cc.

Function Documentation

◆ delete_tree()

template<typename T >
void delete_tree ( Tree_Node< T > *  node)

◆ main()

◆ print_tree()

template<typename T >
void print_tree ( Tree_Node< T > *  node,
int  depth = 0 
)