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

GSoC 2022: Nitish Chauhan Week 3 #223

Merged
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
1 change: 1 addition & 0 deletions configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ traversal | Y | Y | Y
coloring | Y | Y | Y
planar | Y | Y | Y
dominator | Y | Y | Y
circuits | N | N | N
#----------------------
# SQL only directories
#----------------------
Expand Down
3 changes: 1 addition & 2 deletions doc/circuits/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[[

SET(LOCAL_FILES
pgr_hawickCircuits.rst
)
Expand All @@ -9,4 +9,3 @@ foreach (f ${LOCAL_FILES})
endforeach()

set(PROJECT_DOC_FILES ${PROJECT_DOC_FILES} ${LOCAL_DOC_FILES} PARENT_SCOPE)
]]
2 changes: 1 addition & 1 deletion include/c_types/circuits_rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* return type for circuit
* ***********************************************************************/
struct circuits_rt {
int seq;
// int seq;
int64_t *circuit;
int circuit_size;
};
Expand Down
77 changes: 77 additions & 0 deletions include/circuits/hawickcircuits.hpp
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_
4 changes: 2 additions & 2 deletions include/drivers/circuits/hawickcircuits_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ do_hawickCircuits(
Edge_t *, // data_edges
size_t, // total_tuples
circuits_rt **, // return_tuples
size_t *, //return_count
size_t *, // return_count

char **, // log_msg
char **, // notice_msg
char **); //err_msg
char **); // err_msg


#ifdef __cplusplus
Expand Down
4 changes: 1 addition & 3 deletions sql/circuits/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[[
SET(LOCAL_FILES
_hawickCircuits.sql
hawickCircuits.sql
Expand All @@ -13,5 +12,4 @@ foreach (f ${LOCAL_FILES})
list(APPEND PACKAGE_SQL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${f})
endforeach()

set(PROJECT_SQL_FILES ${PROJECT_SQL_FILES} ${PACKAGE_SQL_FILES} PARENT_SCOPE)
]]
set(PROJECT_SQL_FILES ${PROJECT_SQL_FILES} ${PACKAGE_SQL_FILES} PARENT_SCOPE)
5 changes: 2 additions & 3 deletions src/circuits/CMakeLists.txt
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
)
]]
)