Skip to content

Commit 16bdfb2

Browse files
committed
Apply Copilot recommended changes for views
1 parent 260b279 commit 16bdfb2

File tree

6 files changed

+113
-75
lines changed

6 files changed

+113
-75
lines changed

include/graph/views/breadth_first_search.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
// for(auto&& [vid,uv,val] : edges_breadth_first_search(g,seed,evf))
1717
// for(auto&& [vid,uv,val] : edges_breadth_first_search(g,seeds,evf))
1818
//
19-
// for(auto&& [uid,vid,uv] : sourced_edges_depth_first_search(g,seed))
20-
// for(auto&& [uid,vid,uv] : sourced_edges_depth_first_search(g,seeds))
21-
// for(auto&& [uid,vid,uv,val] : sourced_edges_depth_first_search(g,seed,evf))
22-
// for(auto&& [uid,vid,uv,val] : sourced_edges_depth_first_search(g,seeds,evf))
19+
// for(auto&& [uid,vid,uv] : sourced_edges_breadth_first_search(g,seed))
20+
// for(auto&& [uid,vid,uv] : sourced_edges_breadth_first_search(g,seeds))
21+
// for(auto&& [uid,vid,uv,val] : sourced_edges_breadth_first_search(g,seed,evf))
22+
// for(auto&& [uid,vid,uv,val] : sourced_edges_breadth_first_search(g,seeds,evf))
2323
//
2424
// Given bfs is one of the breadth-first views above, the following functions are also available.
2525
//
@@ -268,7 +268,7 @@ class vertices_breadth_first_search_view : public bfs_base<G, Alloc> {
268268
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
269269
internal_value() : shadow_{} {}
270270
~internal_value() {}
271-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
271+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
272272
};
273273

274274
public:
@@ -387,7 +387,7 @@ class vertices_breadth_first_search_view<G, void, Alloc> : public bfs_base<G, Al
387387
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
388388
internal_value() : shadow_{} {}
389389
~internal_value() {}
390-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
390+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
391391
};
392392

393393
public:
@@ -509,7 +509,7 @@ class edges_breadth_first_search_view : public bfs_base<G, Alloc> {
509509
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
510510
internal_value() : shadow_{} {}
511511
~internal_value() {}
512-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
512+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
513513
};
514514

515515
public:
@@ -623,7 +623,7 @@ class edges_breadth_first_search_view<G, void, Sourced, Alloc> : public bfs_base
623623
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
624624
internal_value() : shadow_{} {}
625625
~internal_value() {}
626-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
626+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
627627
};
628628

629629
public:
@@ -960,7 +960,7 @@ namespace views {
960960
constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy;
961961

962962
if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) {
963-
return edges_breadth_first_search(__g, seed, alloc); // intentional ADL
963+
return edges_breadth_first_search(__g, seed, evf, alloc); // intentional ADL
964964
} else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) {
965965
return edges_breadth_first_search_view<_G, _EVF, false>(__g, seed, evf, alloc); // default impl
966966
} else {
@@ -1113,7 +1113,7 @@ namespace views {
11131113
constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy;
11141114

11151115
if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) {
1116-
return sourced_edges_breadth_first_search(__g, seed, alloc); // intentional ADL
1116+
return sourced_edges_breadth_first_search(__g, seed, evf, alloc); // intentional ADL
11171117
} else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) {
11181118
return edges_breadth_first_search_view<_G, _EVF, true>(__g, seed, evf, alloc); // default impl
11191119
} else {

include/graph/views/depth_first_search.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class vertices_depth_first_search_view : public dfs_base<G, Alloc> {
253253
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
254254
internal_value() : shadow_{} {}
255255
~internal_value() {}
256-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
256+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
257257
};
258258

259259
public:
@@ -362,7 +362,7 @@ class vertices_depth_first_search_view<G, void, Alloc> : public dfs_base<G, Allo
362362
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
363363
internal_value() : shadow_{} {}
364364
~internal_value() {}
365-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
365+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
366366
};
367367

368368
public:
@@ -479,7 +479,7 @@ class edges_depth_first_search_view : public dfs_base<G, Alloc> {
479479
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
480480
internal_value() : shadow_{} {}
481481
~internal_value() {}
482-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
482+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
483483
};
484484

485485
public:
@@ -587,7 +587,7 @@ class edges_depth_first_search_view<G, void, Sourced, Alloc> : public dfs_base<G
587587
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
588588
internal_value() : shadow_{} {}
589589
~internal_value() {}
590-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
590+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
591591
};
592592

593593
public:
@@ -722,15 +722,15 @@ namespace views {
722722

723723
public:
724724
/**
725-
* @brief Single Source, Breadth First Search for vertices
725+
* @brief Single Source, Depth First Search for vertices
726726
*
727727
* Complexity: O(V + E)
728728
*
729729
* @tparam G The graph type.
730730
* @tparam Alloc The allocator type.
731731
* @param g A graph instance.
732732
* @param seed The vertex id to start the search.
733-
* @return A forward range for the breadth first search.
733+
* @return A forward range for the depth first search.
734734
*/
735735
template <class _G, class _Alloc = std::allocator<bool>>
736736
requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None)
@@ -750,7 +750,7 @@ namespace views {
750750
}
751751

752752
/**
753-
* @brief Single Source, Breadth First Search for vertices with VVF
753+
* @brief Single Source, Depth First Search for vertices with VVF
754754
*
755755
* Complexity: O(V + E)
756756
*
@@ -762,7 +762,7 @@ namespace views {
762762
* @param vvf The vertex value function.
763763
* @param seed The vertex id to start the search.
764764
*
765-
* @return A forward range for the breadth first search.
765+
* @return A forward range for the depth first search.
766766
*/
767767
template <class _G, class _VVF, class _Alloc = std::allocator<bool>>
768768
requires(_Choice_ref_vvf<_G&, _VVF, _Alloc>._Strategy != _St_ref_vvf::_None)
@@ -871,7 +871,7 @@ namespace views {
871871

872872
public:
873873
/**
874-
* @brief Single Source, Breadth First Search for edges
874+
* @brief Single Source, Depth First Search for edges
875875
*
876876
* Complexity: O(V + E)
877877
*
@@ -881,7 +881,7 @@ namespace views {
881881
* @param g A graph instance.
882882
* @param seed The vertex id to start the search.
883883
*
884-
* @return A forward range for the breadth first search.
884+
* @return A forward range for the depth first search.
885885
*/
886886
template <class _G, class _Alloc = std::allocator<bool>>
887887
requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None)
@@ -901,7 +901,7 @@ namespace views {
901901
}
902902

903903
/**
904-
* @brief Single Source, Breadth First Search for edges with EVF
904+
* @brief Single Source, Depth First Search for edges with EVF
905905
*
906906
* Complexity: O(V + E)
907907
*
@@ -913,7 +913,7 @@ namespace views {
913913
* @param evf The vertex value function.
914914
* @param seed The vertex id to start the search.
915915
*
916-
* @return A forward range for the breadth first search.
916+
* @return A forward range for the depth first search.
917917
*/
918918
template <class _G, class _EVF, class _Alloc = std::allocator<bool>>
919919
requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None)
@@ -923,7 +923,7 @@ namespace views {
923923
constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy;
924924

925925
if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) {
926-
return edges_depth_first_search(__g, seed, alloc); // intentional ADL
926+
return edges_depth_first_search(__g, seed, evf, alloc); // intentional ADL
927927
} else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) {
928928
return edges_depth_first_search_view<_G, _EVF, false>(__g, seed, evf, alloc); // default impl
929929
} else {
@@ -1024,7 +1024,7 @@ namespace views {
10241024

10251025
public:
10261026
/**
1027-
* @brief Single Source, Breadth First Search for source edges.
1027+
* @brief Single Source, Depth First Search for source edges.
10281028
*
10291029
* Complexity: O(V + E)
10301030
*
@@ -1034,7 +1034,7 @@ namespace views {
10341034
* @param g A graph instance.
10351035
* @param seed The vertex id to start the search.
10361036
*
1037-
* @return A forward range for the breadth first search.
1037+
* @return A forward range for the depth first search.
10381038
*/
10391039
template <class _G, class _Alloc = std::allocator<bool>>
10401040
requires(_Choice_ref<_G&, _Alloc>._Strategy != _St_ref::_None)
@@ -1055,7 +1055,7 @@ namespace views {
10551055

10561056

10571057
/**
1058-
* @brief Single Source, Breadth First Search for edges with EVF
1058+
* @brief Single Source, Depth First Search for edges with EVF
10591059
*
10601060
* Complexity: O(V + E)
10611061
*
@@ -1067,7 +1067,7 @@ namespace views {
10671067
* @param evf The vertex value function.
10681068
* @param seed The vertex id to start the search.
10691069
*
1070-
* @return A forward range for the breadth first search.
1070+
* @return A forward range for the depth first search.
10711071
*/
10721072
template <class _G, class _EVF, class _Alloc = std::allocator<bool>>
10731073
requires(_Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy != _St_ref_evf::_None)
@@ -1077,7 +1077,7 @@ namespace views {
10771077
constexpr _St_ref_evf _Strat_ref_evf = _Choice_ref_evf<_G&, _EVF, _Alloc>._Strategy;
10781078

10791079
if constexpr (_Strat_ref_evf == _St_ref_evf::_Non_member) {
1080-
return sourced_edges_depth_first_search(__g, seed, alloc); // intentional ADL
1080+
return sourced_edges_depth_first_search(__g, seed, evf, alloc); // intentional ADL
10811081
} else if constexpr (_Strat_ref_evf == _St_ref_evf::_Auto_eval) {
10821082
return edges_depth_first_search_view<_G, _EVF, true>(__g, seed, evf, alloc); // default impl
10831083
} else {

include/graph/views/edgelist.hpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class edgelist_iterator<G, void> : public edgelist_iterator_base<G> {
240240
internal_value(const internal_value& rhs) : shadow_(rhs.shadow_) {}
241241
internal_value() : shadow_{} {}
242242
~internal_value() {}
243-
internal_value& operator=(const internal_value& rhs) { value_.shadow = rhs.value_.shadow; }
243+
internal_value& operator=(const internal_value& rhs) { shadow_ = rhs.shadow_; return *this; }
244244
};
245245

246246
public:
@@ -426,7 +426,7 @@ namespace views {
426426
&& invocable<EVF, edge_reference_t<_G>>;
427427

428428
#ifdef ENABLE_EDGELIST_RANGE
429-
template <class ELR, class class Proj>
429+
template <class ELR, class Proj>
430430
concept _Has_edgelist_all_proj_ADL = edgelist_range<ELR> //
431431
&& invocable<Proj, range_value_t<ELR>>;
432432
template <class ELR, class Proj>
@@ -568,13 +568,15 @@ namespace views {
568568
* Complexity: O(E)
569569
*
570570
* Default implementation:
571-
* using iterator_type = edgelist_iterator<G, void>;
572-
* edgelist_view<G, void>(iterator_type(g), end(vertices(g)));
571+
* using iterator_type = edgelist_iterator<G, EVF>;
572+
* edgelist_view<G, EVF>(iterator_type(g, evf), end(vertices(g)));
573573
*
574574
* @tparam G The graph type.
575+
* @tparam EVF The edge value function type.
575576
* @param g A graph instance.
577+
* @param evf The edge value function.
576578
* @return A range of edges in graph g where the range value_type is
577-
* edge_info<vertex_id_t<G>,false,vertex_reference_t<G>,void>
579+
* edge_info<vertex_id_t<G>,true,edge_reference_t<G>,invoke_result_t<EVF,edge_reference_t<G>>>
578580
*/
579581
template <class _G, class EVF>
580582
requires(_Choice_all_evf<_G&, EVF>._Strategy != _St_adjlist_all::_None)
@@ -583,7 +585,7 @@ namespace views {
583585
constexpr _St_adjlist_all _Strat_ref = _Choice_all_evf<_G&, EVF>._Strategy;
584586

585587
if constexpr (_Strat_ref == _St_adjlist_all::_Non_member) {
586-
return edgelist(__g); // intentional ADL
588+
return edgelist(__g, evf); // intentional ADL
587589
} else if constexpr (_Strat_ref == _St_adjlist_all::_Auto_eval) {
588590
using iterator_type = edgelist_iterator<_G, EVF>;
589591
return edgelist_view<_G, EVF>(iterator_type(__g, evf), end(vertices(__g)));
@@ -605,8 +607,10 @@ namespace views {
605607
*
606608
* @tparam G The graph type.
607609
* @param __g A graph instance.
610+
* @param first First vertex id in range.
611+
* @param last Last vertex id in range.
608612
* @return A range of edges in graph __g where the range value_type is
609-
* edge_info<vertex_id_t<G>,false,vertex_reference_t<G>,void>
613+
* edge_info<vertex_id_t<G>,true,edge_reference_t<G>,void>
610614
*/
611615
template <class _G>
612616
requires(_Choice_idrng<_G&>._Strategy != _St_adjlist_idrng::_None)
@@ -615,7 +619,7 @@ namespace views {
615619
constexpr _St_adjlist_idrng _Strat_ref = _Choice_idrng<_G&>._Strategy;
616620

617621
if constexpr (_Strat_ref == _St_adjlist_idrng::_Non_member) {
618-
return edgelist(__g); // intentional ADL
622+
return edgelist(__g, first, last); // intentional ADL
619623
} else if constexpr (_Strat_ref == _St_adjlist_idrng::_Auto_eval) {
620624
using iterator_type = edgelist_iterator<_G, void>;
621625
return edgelist_view<_G, void>(iterator_type(__g, find_vertex(__g, first)), find_vertex(__g, last));
@@ -627,18 +631,22 @@ namespace views {
627631

628632
// edgelist(g,uid,vid,evf)
629633
/**
630-
* @brief Get the edgelist of all edges in a graph, with edge values.
634+
* @brief Get the edgelist of edges in a graph within a vertex id range, with edge values.
631635
*
632636
* Complexity: O(E)
633637
*
634638
* Default implementation:
635-
* using iterator_type = edgelist_iterator<_G, void>;
636-
* edgelist_view<_G, void>(iterator_type(g), end(vertices(g)));
639+
* using iterator_type = edgelist_iterator<_G, EVF>;
640+
* edgelist_view<_G, EVF>(iterator_type(__g, evf), end(vertices(__g)));
637641
*
638642
* @tparam _G The graph type.
639-
* @param g A graph instance.
640-
* @return A range of edges in graph g where the range value_type is
641-
* edge_info<vertex_id_t<_G>,false,vertex_reference_t<_G>,void>
643+
* @tparam EVF The edge value function type.
644+
* @param __g A graph instance.
645+
* @param first First vertex id in range.
646+
* @param last Last vertex id in range.
647+
* @param evf The edge value function.
648+
* @return A range of edges in graph __g where the range value_type is
649+
* edge_info<vertex_id_t<_G>,true,edge_reference_t<_G>,invoke_result_t<EVF,edge_reference_t<_G>>>
642650
*/
643651
template <class _G, class EVF>
644652
requires(_Choice_idrng_evf<_G&, EVF>._Strategy != _St_adjlist_idrng::_None)
@@ -648,10 +656,10 @@ namespace views {
648656
constexpr _St_adjlist_idrng _Strat_ref = _Choice_idrng_evf<_G&, EVF>._Strategy;
649657

650658
if constexpr (_Strat_ref == _St_adjlist_idrng::_Non_member) {
651-
return edgelist(__g); // intentional ADL
659+
return edgelist(__g, first, last, evf); // intentional ADL
652660
} else if constexpr (_Strat_ref == _St_adjlist_idrng::_Auto_eval) {
653661
using iterator_type = edgelist_iterator<_G, EVF>;
654-
return edgelist_view<_G, void>(iterator_type(__g, evf), end(vertices(__g))); // default impl
662+
return edgelist_view<_G, EVF>(iterator_type(__g, evf), end(vertices(__g))); // default impl
655663
} else {
656664
static_assert(_AlwaysFalse<_G>,
657665
"edgelist(g,uid,vid,evf) is not defined and the default implementation cannot be evaluated");

0 commit comments

Comments
 (0)