Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #103

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions D3128_Algorithms/src/visitor_edge.hpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
template <class G, class Visitor>
concept has_on_examine_edge = //
concept has_on_examine_edge = // For exposition only
requires(Visitor& v, edge_descriptor<vertex_id_t<G>, true, edge_reference_t<G>, void> edesc) {
{ v.on_examine_edge(edesc) };
};
template <class G, class Visitor>
concept has_on_edge_relaxed = //
concept has_on_edge_relaxed = // For exposition only
requires(Visitor& v, edge_descriptor<vertex_id_t<G>, true, edge_reference_t<G>, void> edesc) {
{ v.on_edge_relaxed(edesc) };
};
template <class G, class Visitor>
concept has_on_edge_not_relaxed = //
concept has_on_edge_not_relaxed = // For exposition only
requires(Visitor& v, edge_descriptor<vertex_id_t<G>, true, edge_reference_t<G>, void> edesc) {
{ v.on_edge_not_relaxed(edesc) };
};
template <class G, class Visitor>
concept has_on_edge_minimized = //
concept has_on_edge_minimized = // For exposition only
requires(Visitor& v, edge_descriptor<vertex_id_t<G>, true, edge_reference_t<G>, void> edesc) {
{ v.on_edge_minimized(edesc) };
};
template <class G, class Visitor>
concept has_on_edge_not_minimized =
concept has_on_edge_not_minimized = // For exposition only
requires(Visitor& v, edge_descriptor<vertex_id_t<G>, true, edge_reference_t<G>, void> edesc) {
{ v.on_edge_not_minimized(edesc) };
};
8 changes: 4 additions & 4 deletions D3128_Algorithms/src/visitor_vertex.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
template <class G, class Visitor>
concept has_on_initialize_vertex = //
concept has_on_initialize_vertex = // For exposition only
requires(Visitor& v, vertex_descriptor<vertex_id_t<G>, vertex_reference_t<G>, void> vdesc) {
{ v.on_initialize_vertex(vdesc) };
};
template <class G, class Visitor>
concept has_on_discover_vertex = //
concept has_on_discover_vertex = // For exposition only
requires(Visitor& v, vertex_descriptor<vertex_id_t<G>, vertex_reference_t<G>, void> vdesc) {
{ v.on_discover_vertex(vdesc) };
};
template <class G, class Visitor>
concept has_on_examine_vertex = //
concept has_on_examine_vertex = // For exposition only
requires(Visitor& v, vertex_descriptor<vertex_id_t<G>, vertex_reference_t<G>, void> vdesc) {
{ v.on_examine_vertex(vdesc) };
};
template <class G, class Visitor>
concept has_on_finish_vertex = //
concept has_on_finish_vertex = // For exposition only
requires(Visitor& v, vertex_descriptor<vertex_id_t<G>, vertex_reference_t<G>, void> vdesc) {
{ v.on_finish_vertex(vdesc) };
};
4 changes: 3 additions & 1 deletion D3128_Algorithms/tex/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ \section{Shortest Paths}
\phil{I assume \tcode{adjacency_list_graph} is the same as our \tcode{adjacency_list}. \tcode{bidirectional_adjacency_list_graph} is new; what to do with it?}
\end{comment}


\subsection{Initialization}

{\small
Expand Down Expand Up @@ -461,6 +460,9 @@ \subsection{Dijkstra Shortest Paths and Shortest Distances}

\subsubsection{Dijkstra Shortest Paths}

\phil{Feedback: use std::invocable instead of std::function to avoid performance penalty.
(Is this really an issue, when the function parameter has a default lambda?)}

\paragraph{Single-Source Shortest Paths}
{\small
\lstinputlisting{D3128_Algorithms/src/dijkstra_shortest_paths.hpp}
Expand Down
6 changes: 6 additions & 0 deletions D3129_Views/tex/revision.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ \subsection*{\paperno r1}
and to the \tcode{has_edge_value} concept if a \tcode{evf(uv)} function is passed. The same applies to
all \textit{sourced} versions of the BFS, DFS and Topological Sort views.
\end{itemize}

\subsection*{\paperno r2}
\begin{itemize}
\item Restore the allocator parameters on the DFS, BFS and Toplogical Sort views, based on feedback and
by SG14/SG19 joint meeting.
\end{itemize}
101 changes: 50 additions & 51 deletions D3129_Views/tex/views.tex
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,11 @@ \subsection{Common Types and Functions for ``Search'' }

\subsection{Depth First Search Views}

\phil{Add optional bitset enum event parameter, that match the visitor events.}

Depth First Search views iterate over the vertices and edges from a given seed vertex, returning a \tcode{vertex_descriptor} or \tcode{edge_descriptor} on each iteration when it is first encountered, depending on the function used.
Table \ref{tab:dfs} shows the functions and their return values.

%While not shown in the examples, all functions have a final, optional allocator parameter that defaults to \tcode{std::allocator<bool>}.
%It is used for containers that are internal to the view. The \tcode{<bool>} argument has no particular meaning.
The \tcode{alloc} parameter shown in the following examples is optional and defaults to \tcode{std::allocator<bool>}. It is used for containers
that are internal to the view. The \tcode{bool} argument has no particular meaning.

\tcode{vertices_dfs} views require a \tcode{vvf(u)} function, and the \tcode{basic_vertices_dfs} views require a \tcode{vvf(uid)} function.
\tcode{edges_dfs} views require a \tcode{evf(uv)} function. \tcode{basic_sourced_edges_dfs} views require a \tcode{evf(eid)} function.
Expand All @@ -422,9 +420,8 @@ \subsection{Depth First Search Views}
% basic_edges_dfs(g,seed,evf) implies the use of Sourced type internally to have source_id in the call call to evf(eid)

\phil{Consider adding an enum bitset of events matching the visitor events, and creating Overloads
that accept the bitset. Returned type would include the bitset event triggered, after the
value from the user-defined function. The returned value would be a class derived from
\tcode{vertex_descriptor} or \tcode{edge_descriptor}. This could offer a similar benefit as
that accept the bitset. The returned type would be a subclass of \tcode{vertex_descriptor} or \tcode{edge_descriptor}
and would add the event bitset as a final member value, with the bit set for the event . This could offer a similar benefit as
coroutines.}

\begin{table}[h!]
Expand All @@ -434,23 +431,23 @@ \subsection{Depth First Search Views}
\hline
\textbf{Example} & \textbf{Return} \\
\hline
\tcode{for(auto\&\& [vid,v] : vertices_dfs(g,seed))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_dfs(g,seed,vvf))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\tcode{for(auto\&\& [vid,v] : vertices_dfs(g,seed,alloc))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_dfs(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid,uv] : edges_dfs(g,seed))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_dfs(g,seed,evf))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\tcode{for(auto\&\& [vid,uv] : edges_dfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_dfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\hdashline
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_dfs(g,seed))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_dfs(g,seed,evf))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_dfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_dfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\hline
\tcode{for(auto\&\& [vid] : basic_vertices_dfs(g,seed))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_dfs(g,seed,vvf))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\tcode{for(auto\&\& [vid] : basic_vertices_dfs(g,seed,alloc))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_dfs(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid] : basic_edges_dfs(g,seed))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_dfs(g,seed,evf))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\tcode{for(auto\&\& [vid] : basic_edges_dfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_dfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\hdashline
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_dfs(g,seed))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_dfs(g,seed,evf))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_dfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_dfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\hline
\end{tabular}}
\caption{depth\_first\_search View Functions}
Expand All @@ -461,13 +458,12 @@ \subsection{Depth First Search Views}
\subsection{Breadth First Search Views}
\phil{NetworkX provides an optional depth\_limit parameter for bfs. Add? }

\phil{Add optional bitset enum event parameter, that match the visitor events.}

Breadth First Search views iterate over the vertices and edges from a given seed vertex, returning a \tcode{vertex_descriptor}
or \tcode{edge_descriptor} on each iteration when it is first encountered, depending on the function used.
Table \ref{tab:bfs} shows the functions and their return values.

%While not shown in the examples, all functions have a final, optional allocator parameter that defaults to \tcode{std::allocator<bool>}. It is used for containers that are internal to the view. The \tcode{<bool>} argument has no particular meaning.
The \tcode{alloc} parameter shown in the following examples is optional and defaults to \tcode{std::allocator<bool>}. It is used for containers
that are internal to the view. The \tcode{bool} argument has no particular meaning.

\tcode{vertices_bfs} views require a \tcode{vvf(u)} function, and the \tcode{basic_vertices_bfs} views require a \tcode{vvf(uid)} function.
\tcode{edges_bfs} views require a \tcode{evf(uv)} function.
Expand All @@ -478,9 +474,8 @@ \subsection{Breadth First Search Views}
% basic_edges_bfs(g,seed,evf) implies the use of Sourced type internally to have source_id in the call call to evf(eid)

\phil{Consider adding an enum bitset of events matching the visitor events, and creating Overloads
that accept the bitset. Returned type would include the bitset event triggered, after the
value from the user-defined function. The returned value would be a class derived from
\tcode{vertex_descriptor} or \tcode{edge_descriptor}. This could offer a similar benefit as
that accept the bitset. The returned type would be a subclass of \tcode{vertex_descriptor} or \tcode{edge_descriptor}
and would add the event bitset as a final member value, with the bit set for the event . This could offer a similar benefit as
coroutines.}

\begin{table}[h!]
Expand All @@ -491,23 +486,23 @@ \subsection{Breadth First Search Views}
\textbf{Example} & \textbf{Return} \\
\hline
\hdashline
\tcode{for(auto\&\& [vid,v] : vertices_bfs(g,seed))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_bfs(g,seed,vvf))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\tcode{for(auto\&\& [vid,v] : vertices_bfs(g,seed,alloc))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_bfs(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid,uv] : edges_bfs(g,seed))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_bfs(g,seed,evf))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\tcode{for(auto\&\& [vid,uv] : edges_bfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_bfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\hdashline
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_bfs(g,seed))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_bfs(g,seed,evf))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_bfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_bfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\hline
\tcode{for(auto\&\& [vid] : basic_vertices_bfs(g,seed))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_bfs(g,seed,vvf))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\tcode{for(auto\&\& [vid] : basic_vertices_bfs(g,seed,alloc))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_bfs(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid] : basic_edges_bfs(g,seed))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_bfs(g,seed,evf))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\tcode{for(auto\&\& [vid] : basic_edges_bfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_bfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\hdashline
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_bfs(g,seed))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_bfs(g,seed,evf))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_bfs(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_bfs(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\hline
\end{tabular}}
\caption{breadth\_first\_search View Functions}
Expand All @@ -520,14 +515,18 @@ \subsection{Topological Sort Views}
\tcode{edge_descriptor} on each iteration when it is first encountered, depending on the function used.
Table \ref{tab:topo_sort} shows the functions and their return values.

%While not shown in the examples, all functions have a final, optional allocator parameter that defaults to \tcode{std::allocator<bool>}. It is used for containers that are internal to the view. The \tcode{<bool>} argument has no particular meaning.
The \tcode{alloc} parameter shown in the following examples is optional and defaults to \tcode{std::allocator<bool>}. It is used for containers
that are internal to the view. The \tcode{bool} argument has no particular meaning.

\tcode{vertices_topological_sort} views require a \tcode{vvf(u)} function, and the \tcode{basic_vertices_topological_sort} views require a \tcode{vvf(uid)} function.
\tcode{edges_topological_sort} views require a \tcode{evf(uv)} function.

% basic_edges_topological_sort(g,seed,evf) implies the use of Sourced type internally to have source_id in the call call to evf(eid)

\phil{Consider adding a enum bitset similar to those for dfs and bfs.}
\phil{Consider adding an enum bitset of events matching the visitor events, and creating Overloads
that accept the bitset. The returned type would be a subclass of \tcode{vertex_descriptor} or \tcode{edge_descriptor}
and would add the event bitset as a final member value, with the bit set for the event . This could offer a similar benefit as
coroutines.}

\begin{table}[h!]
\begin{center}
Expand All @@ -536,23 +535,23 @@ \subsection{Topological Sort Views}
\hline
\textbf{Example} & \textbf{Return} \\
\hline
\tcode{for(auto\&\& [vid,v] : vertices_topological_sort(g,seed))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_topological_sort(g,seed,vvf))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\tcode{for(auto\&\& [vid,v] : vertices_topological_sort(g,seed,alloc))} & \tcode{vertex_descriptor<VId,V,void>} \\
\tcode{for(auto\&\& [vid,v,val] : vertices_topological_sort(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,V,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid,uv] : edges_topological_sort(g,seed))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_topological_sort(g,seed,evf))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\tcode{for(auto\&\& [vid,uv] : edges_topological_sort(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,E,void>} \\
\tcode{for(auto\&\& [vid,uv,val] : edges_topological_sort(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,E,EV>} \\
\hdashline
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_topological_sort(g,seed))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_topological_sort(g,seed,evf))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\tcode{for(auto\&\& [uid,vid,uv] : sourced_edges_topological_sort(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,E,void>} \\
\tcode{for(auto\&\& [uid,vid,uv,val] : sourced_edges_topological_sort(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,E,EV>} \\
\hline
\tcode{for(auto\&\& [vid] : basic_vertices_topological_sort(g,seed))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_topological_sort(g,seed,vvf))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\tcode{for(auto\&\& [vid] : basic_vertices_topological_sort(g,seed,alloc))} & \tcode{vertex_descriptor<VId,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_vertices_topological_sort(g,seed,vvf,alloc))} & \tcode{vertex_descriptor<VId,void,VV>} \\
\hdashline
\tcode{for(auto\&\& [vid] : basic_edges_topological_sort(g,seed))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_topological_sort(g,seed,evf))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\tcode{for(auto\&\& [vid] : basic_edges_topological_sort(g,seed,alloc))} & \tcode{edge_descriptor<VId,false,void,void>} \\
\tcode{for(auto\&\& [vid,val] : basic_edges_topological_sort(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,false,void,EV>} \\ % requires source_ for evf(eid)
\hdashline
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_topological_sort(g,seed))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_topological_sort(g,seed,evf))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\tcode{for(auto\&\& [uid,vid] : basic_sourced_edges_topological_sort(g,seed,alloc))} & \tcode{edge_descriptor<VId,true,void,void>} \\
\tcode{for(auto\&\& [uid,vid,val] : basic_sourced_edges_topological_sort(g,seed,evf,alloc))} & \tcode{edge_descriptor<VId,true,void,EV>} \\
\hline
\end{tabular}}
\caption{topological\_sort View Functions}
Expand Down
Binary file removed P1709r5.pdf
Binary file not shown.
Loading