13namespace fishnet::graph::__impl{
26 using N = G::node_type;
29 while(not q.empty()and not searchResult.stop()) {
30 N current = q.front();
32 searchResult.open(current);
33 for(
auto const& neighbour : g.getNeighbours(current)){
34 searchResult.onEdge(current,neighbour);
35 if (searchResult.isUnknown(neighbour) and predicate(current,neighbour) ) {
36 searchResult.open(neighbour);
40 searchResult.close(current);
53static void bfs(
const G & g,
auto & searchResult,
const typename G::node_type & start) {
67 auto nodes = g.getNodes();
68 for(
auto const& n : nodes){
69 if (searchResult.stop()){
72 if(searchResult.isUnknown(n)){
73 bfs(g, searchResult,n,predicate);
79static void bfs_all(
const Graph
auto & g,
auto& searchResult){
96 using H = G::adj_container_type::hash_function;
97 using E = G::adj_container_type::equality_predicate;
126 using H = G::adj_container_type::hash_function;
127 using E = G::adj_container_type::equality_predicate;
129 __impl::bfs_all<G>(graph,concurrentConnectedComponents,inRelation);
130 return concurrentConnectedComponents;
156auto findPath(
const G & graph,
const typename G::node_type & start,
const typename G::node_type & goal) {
157 using H = G::adj_container_type::hash_function;
158 using E = G::adj_container_type::equality_predicate;
160 __impl::bfs(graph,p,start);
175 using N = G::node_type;
176 std::optional<std::vector<N>> nodesOpt =
findPath(graph,start,goal).get();
178 return std::vector<typename G::edge_type>();
180 std::vector<N> nodes = *nodesOpt;
181 std::vector<typename G::edge_type> edges;
182 for(
size_t i = 0; i < nodes.size()-1; i++) {
183 edges.push_back(graph.makeEdge(nodes[i],nodes[i+1]));
188template<Graph G, Graph O>
requires std::same_as<typename G::node_type, typename O::node_type>
189G
neighborhood(
const G & graph,
const typename G::node_type & node,
size_t order, O && outputGraph){
190 outputGraph.addNode(node);
196template<Graph G>
requires std::is_default_constructible_v<G>
197G
neighborhood(
const G & graph,
const typename G::node_type & node,
size_t order){
201template<Graph G>
requires (!std::is_default_constructible_v<G> && std::is_copy_constructible_v<G>)
202G
neighborhood(
const G & graph,
const typename G::node_type & node,
size_t order){
216template<Graph G,
typename P,
typename R = std::invoke_result_t<std::decay_t<P>>>
requires std::same_as<typename G::node_type, typename R::node_type>
230template<Graph G>
requires std::is_default_constructible_v<G>
Concurrent specialization for computing connected components.
Definition ConnectedComponents.hpp:159
Search Result for Connected Components.
Definition ConnectedComponents.hpp:73
Definition Neighborhood.hpp:8
Search Path implementation.
Definition SearchPath.hpp:16
Definition ConnectedComponents.hpp:175
Blocking queue implementation. Blocks when no elements are present and take() is called until further...
Definition BlockingQueue.hpp:14
Definition FunctionalConcepts.hpp:42
Definition CollectionConcepts.hpp:27
Definition BFSAlgorithm.hpp:84
auto connectedComponents(const G &graph, fishnet::util::BiPredicate< typename G::node_type > auto const &inRelation)
Compute connected components of the graph.
Definition BFSAlgorithm.hpp:95
G neighborhood(const G &graph, const typename G::node_type &node, size_t order, O &&outputGraph)
Definition BFSAlgorithm.hpp:189
auto findPath(const G &graph, const typename G::node_type &start, const typename G::node_type &goal)
Find breadth-first search between between start and goal node.
Definition BFSAlgorithm.hpp:156
util::input_range_of< typename G::edge_type > auto getPath(const G &graph, const typename G::node_type &start, const typename G::node_type &goal)
Find breadth-first search between between start and goal node.
Definition BFSAlgorithm.hpp:174
fishnet::util::forward_range_of< R > auto subgraphs(const G &graph, P &&emptyGraphProducer)
Find all subgraphs in the given graph.
Definition BFSAlgorithm.hpp:217
Definition FunctionalConcepts.hpp:83