-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from nitishchauhan0022/nitish-week-3
GSoC 2022: Nitish Chauhan Week 3
- Loading branch information
Showing
7 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*PGR-GNU***************************************************************** | ||
Copyright (c) 2022 pgRouting developers | ||
Mail: project@pgrouting.org | ||
Copyright (c) 2022 Nitish Chauhan | ||
Mail: nitishchauhan0022 at gmail.com | ||
------ | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
********************************************************************PGR-GNU*/ | ||
|
||
#ifndef INCLUDE_CIRCUITS_HAWICKCIRCUITS_HPP_ | ||
#define INCLUDE_CIRCUITS_HAWICKCIRCUITS_HPP_ | ||
#pragma once | ||
|
||
#include <boost/graph/adjacency_list.hpp> | ||
#include <boost/graph/graph_traits.hpp> | ||
#include <boost/graph/hawick_circuits.hpp> | ||
#include <boost/property_map/property_map.hpp> | ||
|
||
#include <iostream> | ||
#include <iterator> | ||
#include <vector> | ||
|
||
#include "cpp_common/basePath_SSEC.hpp" | ||
#include "cpp_common/pgr_base_graph.hpp" | ||
#include "cpp_common/pgr_assert.h" | ||
#include "c_types/circuits_rt.h" | ||
|
||
struct circuit_detector { | ||
std::vector<circuits_rt> results; | ||
template <typename Path, typename Graph> | ||
void cycle(Path const &p, Graph const &g) { | ||
if (p.empty()) | ||
return; | ||
// Iterate over path printing each vertex that forms the circuit. | ||
typename Path::const_iterator i = p.begin(), before_end = p.end(); | ||
|
||
int64_t *circuit = nullptr; | ||
size_t adj_siz = static_cast<size_t>(before_end - i); | ||
circuit = pgr_alloc(adj_siz, circuit); | ||
int number = 0; | ||
for (; i != before_end; ++i) { | ||
circuit[number++] = i; | ||
} | ||
results.push_back({circuit, adj_siz}); | ||
} | ||
|
||
std::vector<circuits_rt> result() { | ||
return results; | ||
} | ||
}; | ||
|
||
template <typename G> | ||
std::vector<circuits_rt> pgr_hawickCircuits(G &graph) { | ||
circuit_detector visitor; | ||
boost::hawick_circuits(graph, visitor); | ||
|
||
return visitor.result(); | ||
} | ||
|
||
#endif // INCLUDE_CIRCUITS_HAWICKCIRCUITS_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#[[ADD_LIBRARY(hawick_circuits OBJECT | ||
ADD_LIBRARY(hawick_circuits OBJECT | ||
hawickCircuits.c | ||
hawickCircuits_driver.cpp | ||
) | ||
]] | ||
) |