Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA > Class Template Reference

Computes the minimum spanning tree of a graph using Prim's algorithm. More...

#include <Prim.H>

Public Member Functions

 Prim_Min_Spanning_Tree (Distance __dist=Distance(), SA __sa=SA())
 Constructor.
 
void operator() (const GT &g, GT &tree)
 Invokes the computation of the minimum spanning tree using Prim's algorithm.
 
void operator() (const GT &g, typename GT::Node *start, GT &tree)
 Invokes the computation of the minimum spanning tree using Prim's algorithm.
 
void operator() (const GT &g)
 overload ()
 
void operator() (const GT &g, typename GT::Node *start)
 

Private Types

typedef Prim_Heap_Info< GT, Distance > Acc_Heap
 
typedef Simple_Prim_Heap< GT, Distance > Acc_Simple_Heap
 
typedef ArcHeap< GT, Distance, Acc_Heap > Heap
 
typedef ArcHeap< GT, Distance, Acc_Simple_Heap > Simple_Heap
 

Private Member Functions

void paint_min_spanning_tree (const GT &g, typename GT::Node *first)
 
void min_spanning_tree (const GT &g, typename GT::Node *first, GT &tree)
 

Private Attributes

Distance dist
 
SA sa
 

Detailed Description

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
class Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >

Computes the minimum spanning tree of a graph using Prim's algorithm.

This class uses Prim's algorithm to compute the minimum spanning tree of a graph and stores it in another graph.

The resulting minimum spanning tree is fully mapped to the graph.

The algorithm uses an internal queue whose maximum length is proportional to the number of nodes of the graph.

Prim's algorithm is recommended for dense graphs.

The procedure is parameterized with the following specifications:

  1. GT: the graph type, based on List_Graph.
  2. Distance<GT>: the class that reads an arc's weight, which must export the following members:
    1. typedef Distance<GT>::Distance_Type: the data type that represents an arc's weight.
    2. Distance<GT>::Distance_Type operator()(typename GT::Arc *a): returns the weight value of arc a.
    3. Distance<GT>::Max_Distance: static constant corresponding to the maximum distance value an algorithm would consider as infinite.
    4. typename Distance<GT>::Zero_Distance: static constant corresponding to the neutral element of the sum. Traditionally, in the vast majority of cases, this will be zero.
  3. Compare<GT>: class that compares two weights and whose prototype is:
  4. SA: arc filter
See also
Kruskal_Min_Spanning_Tree

Definition at line 214 of file Prim.H.

Member Typedef Documentation

◆ Acc_Heap

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef Prim_Heap_Info<GT, Distance> Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::Acc_Heap
private

Definition at line 216 of file Prim.H.

◆ Acc_Simple_Heap

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef Simple_Prim_Heap<GT, Distance> Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::Acc_Simple_Heap
private

Definition at line 218 of file Prim.H.

◆ Heap

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef ArcHeap<GT, Distance, Acc_Heap> Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::Heap
private

Definition at line 220 of file Prim.H.

◆ Simple_Heap

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef ArcHeap<GT, Distance, Acc_Simple_Heap> Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::Simple_Heap
private

Definition at line 222 of file Prim.H.

Constructor & Destructor Documentation

◆ Prim_Min_Spanning_Tree()

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::Prim_Min_Spanning_Tree ( Distance  __dist = Distance(),
SA  __sa = SA() 
)
inline

Constructor.

Parameters
[in]__distaccess to each arc's distance
[in]__saarc iterator filter

Definition at line 233 of file Prim.H.

Member Function Documentation

◆ min_spanning_tree()

◆ operator()() [1/4]

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator() ( const GT &  g)
inline

◆ operator()() [2/4]

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator() ( const GT &  g,
GT &  tree 
)
inline

Invokes the computation of the minimum spanning tree using Prim's algorithm.

Parameters
[in]gthe graph whose minimum spanning tree is to be computed.
[out]treethe graph where the resulting minimum spanning tree is to be stored. This graph is cleared before the algorithm starts.
Exceptions
bad_allocif there is not enough memory to build tree. In this case tree's value is indeterminate and it is not clean.

Definition at line 381 of file Prim.H.

References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::min_spanning_tree().

◆ operator()() [3/4]

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator() ( const GT &  g,
typename GT::Node *  start 
)
inline

◆ operator()() [4/4]

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
void Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator() ( const GT &  g,
typename GT::Node *  start,
GT &  tree 
)
inline

Invokes the computation of the minimum spanning tree using Prim's algorithm.

Parameters
[in]gthe graph whose minimum spanning tree is to be computed.
[in]startthe node from which the algorithm starts.
[out]treethe graph where the resulting minimum spanning tree is to be stored. This graph is cleared before the algorithm starts.
Exceptions
bad_allocif there is not enough memory to build tree. In this case tree's value is indeterminate and it is not clean.

Definition at line 399 of file Prim.H.

References Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::min_spanning_tree().

◆ paint_min_spanning_tree()

Member Data Documentation

◆ dist

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::dist
private

◆ sa

template<AlephGraph GT, class Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
SA Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::sa
private

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