Skip to content

Commit

Permalink
Merge pull request #223 from nitishchauhan0022/nitish-week-3
Browse files Browse the repository at this point in the history
GSoC 2022: Nitish Chauhan Week 3
  • Loading branch information
nitishchauhan0022 authored Jul 3, 2022
2 parents 58a5ed1 + ca433ed commit c7eae5d
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 11 deletions.
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
)
]]
)

0 comments on commit c7eae5d

Please sign in to comment.