|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
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 |
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:
|
private |
|
private |
|
private |
|
inline |
|
inlineprivate |
Definition at line 314 of file Prim.H.
References ah_domain_error_if, Aleph::and, ARC_BITS, Aleph::clear_graph(), Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::dist, GTArcCommon< ArcInfo >::get_info(), ArcHeap< GT, Distance, Access_Heap_Node >::get_min_arc(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::init, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), IS_ARC_VISITED, GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::GenBinHeap< NodeType, Key, Compare >::is_empty(), IS_NODE_VISITED, GraphCommon< GT, Node, Arc >::map_arcs(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_BITS, NODE_COOKIE, PRIMINFO, ArcHeap< GT, Distance, Access_Heap_Node >::put_arc(), GraphCommon< GT, Node, Arc >::reset_arcs(), Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::sa, Aleph::Spanning_Tree, and TREENODE.
Referenced by Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator()(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator()().
|
inline |
overload ()
Definition at line 439 of file Prim.H.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::paint_min_spanning_tree().
|
inline |
Invokes the computation of the minimum spanning tree using Prim's algorithm.
| [in] | g | the graph whose minimum spanning tree is to be computed. |
| [out] | tree | the graph where the resulting minimum spanning tree is to be stored. This graph is cleared before the algorithm starts. |
| bad_alloc | if there is not enough memory to build tree. In this case tree's value is indeterminate and it is not clean. |
Definition at line 415 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().
|
inline |
Definition at line 444 of file Prim.H.
References Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::paint_min_spanning_tree().
|
inline |
Invokes the computation of the minimum spanning tree using Prim's algorithm.
| [in] | g | the graph whose minimum spanning tree is to be computed. |
| [in] | start | the node from which the algorithm starts. |
| [out] | tree | the graph where the resulting minimum spanning tree is to be stored. This graph is cleared before the algorithm starts. |
| bad_alloc | if there is not enough memory to build tree. In this case tree's value is indeterminate and it is not clean. |
Definition at line 433 of file Prim.H.
References Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::min_spanning_tree().
|
inlineprivate |
Definition at line 248 of file Prim.H.
References ah_domain_error_if, Aleph::and, ARC_BITS, Aleph::count(), Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::dist, GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), IS_ARC_VISITED, GraphCommon< GT, Node, Arc >::is_digraph(), IS_NODE_VISITED, Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_BITS, NODE_COOKIE, GraphCommon< GT, Node, Arc >::reset_arcs(), GraphCommon< GT, Node, Arc >::reset_nodes(), Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::sa, and Aleph::Spanning_Tree.
Referenced by Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator()(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::operator()().
|
private |
Definition at line 232 of file Prim.H.
Referenced by Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::min_spanning_tree(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::paint_min_spanning_tree().
|
private |
Definition at line 233 of file Prim.H.
Referenced by Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::min_spanning_tree(), and Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA >::paint_min_spanning_tree().