Changeset 352:4b89077ab715 in lemon-0.x
- Timestamp:
- 04/17/04 23:50:48 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@471
- Location:
- src/work/johanna
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/johanna/kruskal.h
r349 r352 38 38 } 39 39 40 /* A work-around for running Kruskal with const-reference bool maps... */ 41 42 template<typename Map> 43 class NonConstMapWr { 44 const Map &m; 45 public: 46 typedef typename Map::ValueType ValueType; 47 48 NonConstMapWr(const Map &_m) : m(_m) {} 49 50 template<typename KeyType> 51 void set(KeyType const& k, ValueType const &v) const { m.set(k,v); } 52 }; 53 54 template <typename Graph, typename InputEdgeOrder, typename OutBoolMap> 55 inline 56 typename InputEdgeOrder::ValueType 57 Kruskal(Graph const& G, InputEdgeOrder const& edges, 58 OutBoolMap const& out_map) 59 { 60 NonConstMapWr<OutBoolMap> map_wr(out_map); 61 return Kruskal(G, edges, map_wr); 62 } 40 63 41 64 … … 50 73 template<typename Iterator> 51 74 class SequenceOutput { 52 Iterator it;75 mutable Iterator it; 53 76 54 77 public: … … 58 81 59 82 template<typename KeyType> 60 void set(KeyType const& k, bool v) { if(v) {*it=k; ++it;} }83 void set(KeyType const& k, bool v) const { if(v) {*it=k; ++it;} } 61 84 }; 62 85 … … 178 201 /// Input is from an EdgeMap, output is a plain boolmap. 179 202 template <typename Graph, typename EdgeCostMap, typename RetEdgeBoolMap> 203 inline 180 204 typename EdgeCostMap::ValueType 181 205 Kruskal_EdgeCostMapIn_BoolMapOut(Graph const& G, … … 194 218 /// Input is from an EdgeMap, output is to a sequence. 195 219 template <typename Graph, typename EdgeCostMap, typename RetIterator> 220 inline 196 221 typename EdgeCostMap::ValueType 197 222 Kruskal_EdgeCostMapIn_IteratorOut(Graph const& G, -
src/work/johanna/kruskal_test.cc
r349 r352 101 101 102 102 tree_edge_vec.clear(); 103 SequenceOutput< back_insert_iterator< vector<Edge> > > 104 vec_filler(back_inserter(tree_edge_vec)); 103 // SequenceOutput< back_insert_iterator< vector<Edge> > > 104 // vec_filler(back_inserter(tree_edge_vec)); 105 // cout << "Nemkonst koltseggel tarhatekonyabban: " 106 // << Kruskal(G, 107 // KruskalMapVec<ECostMap>(G, edge_cost_map), 108 // vec_filler) 109 // << endl; 105 110 cout << "Nemkonst koltseggel tarhatekonyabban: " 106 111 << Kruskal(G, 107 112 KruskalMapVec<ECostMap>(G, edge_cost_map), 108 vec_filler) 113 makeSequenceOutput(back_inserter(tree_edge_vec)) 114 ) 109 115 << endl; 110 116
Note: See TracChangeset
for help on using the changeset viewer.