00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef SGI_spanning_tree_h_INCLUDED
00038 #define SGI_spanning_tree_h_INCLUDED
00039
00040 #include "bucket_container.h"
00041 #include "container_with_membership.h"
00042
00043 #include <stdio.h>
00044
00045 namespace SGI {
00046
00047 template <class ClusterIterator,
00048 class OutputIterator,
00049 class Compare,
00050 class DestinationFunction,
00051 class Sizetype>
00052 OutputIterator minimum_spanning_tree(
00053 ClusterIterator initial,
00054 OutputIterator result,
00055 Compare comp,
00056 DestinationFunction destination,
00057 Sizetype size)
00058 {
00059 typedef iterator_traits<ClusterIterator>::value_type::iterator edge_iterator;
00060 typedef iterator_traits<edge_iterator>::value_type heap_element;
00061 typedef heap_with_membership<heap_element,
00062 DestinationFunction,
00063 Compare> heap_type;
00064 heap_type heap(size, destination, comp);
00065 typename heap_type::insert_iterator inserter(heap);
00066 heap.remove(initial);
00067 copy(initial->begin(), initial->end(), inserter);
00068 while (!heap.empty()) {
00069 initial = destination(heap.top());
00070 *result++ = heap.top();
00071 heap.pop();
00072 copy(initial->begin(), initial->end(), inserter);
00073 }
00074 return result;
00075 }
00076
00077 }
00078
00079 #endif
00080
00081
00082
00083