@@ -22,7 +22,7 @@ struct mst_descriptor {
2222 edges.reserve (n_vertices - constants::one);
2323 }
2424
25- std::vector<types::const_ref_wrap< edge_type> > edges;
25+ std::vector<edge_type> edges;
2626 weight_type weight = static_cast <weight_type>(constants::zero);
2727};
2828
@@ -41,7 +41,7 @@ template <type_traits::c_undirected_graph GraphType>
4141 [[nodiscard]] gl_attr_force_inline bool operator ()(
4242 const edge_info_type& lhs, const edge_info_type& rhs
4343 ) const {
44- return get_weight<GraphType>(lhs.edge . get ()) > get_weight<GraphType>(rhs.edge . get () );
44+ return get_weight<GraphType>(lhs.edge ) > get_weight<GraphType>(rhs.edge );
4545 }
4646 };
4747
@@ -69,7 +69,7 @@ template <type_traits::c_undirected_graph GraphType>
6969 const auto min_edge_info = edge_queue.top ();
7070 edge_queue.pop ();
7171
72- const auto & min_edge = min_edge_info.edge . get () ;
72+ const auto & min_edge = min_edge_info.edge ;
7373 const auto min_weight = get_weight<GraphType>(min_edge);
7474
7575 const auto & target_id = min_edge.incident_vertex (min_edge_info.source_id );
@@ -107,7 +107,7 @@ requires type_traits::c_has_numeric_limits_max<types::vertex_distance_type<Graph
107107
108108 std::vector<bool > in_mst (n_vertices, false );
109109 std::vector<distance_type> min_cost (n_vertices, std::numeric_limits<distance_type>::max ());
110- std::vector<const edge_type*> min_cost_edges (n_vertices, nullptr );
110+ std::vector<std::optional< edge_type>> min_cost_edges (n_vertices, std:: nullopt );
111111
112112 // set the distance to the root vertex to 0
113113 min_cost.at (root_id_opt.value_or (constants::zero)) = constants::zero;
@@ -132,8 +132,8 @@ requires type_traits::c_has_numeric_limits_max<types::vertex_distance_type<Graph
132132
133133 in_mst[vertex_id] = true ;
134134
135- const auto * min_cost_edge = min_cost_edges[vertex_id];
136- if (min_cost_edge != nullptr ) { // Add the corresponding edge to MST
135+ const auto min_cost_edge = min_cost_edges[vertex_id];
136+ if (min_cost_edge. has_value () ) { // Add the corresponding edge to MST
137137 mst.edges .emplace_back (*min_cost_edge);
138138 mst.weight += min_cost[vertex_id];
139139 }
@@ -145,7 +145,7 @@ requires type_traits::c_has_numeric_limits_max<types::vertex_distance_type<Graph
145145
146146 if (not in_mst[incident_vertex_id] && edge_weight < min_cost[incident_vertex_id]) {
147147 min_cost[incident_vertex_id] = edge_weight;
148- min_cost_edges[incident_vertex_id] = & edge;
148+ min_cost_edges[incident_vertex_id]. emplace ( edge) ;
149149 }
150150 }
151151
0 commit comments