Skip to content

Commit

Permalink
[c_types][C] fixing mst_rt.h
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvergara committed Aug 3, 2021
1 parent c4bdc78 commit 2a3d174
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 85 deletions.
10 changes: 6 additions & 4 deletions include/breadthFirstSearch/pgr_breadthFirstSearch.hpp
Expand Up @@ -33,6 +33,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/interruption.h"
#include "c_types/mst_rt.h"

//******************************************

namespace pgrouting {
Expand All @@ -46,11 +48,11 @@ class Pgr_breadthFirstSearch {
typedef typename G::B_G B_G;


std::vector<pgr_mst_rt> breadthFirstSearch(
std::vector<MST_rt> breadthFirstSearch(
G &graph,
std::vector<int64_t> start_vertex,
int64_t depth) {
std::vector<pgr_mst_rt> results;
std::vector<MST_rt> results;
using bfs_visitor = visitors::Edges_order_bfs_visitor<E>;

for (auto source : start_vertex) {
Expand All @@ -74,12 +76,12 @@ class Pgr_breadthFirstSearch {

private:
template <typename T>
std::vector<pgr_mst_rt> get_results(
std::vector<MST_rt> get_results(
T order,
int64_t source,
int64_t max_depth,
const G &graph) {
std::vector<pgr_mst_rt> results;
std::vector<MST_rt> results;

std::vector<double> agg_cost(graph.num_vertices(), 0);
std::vector<int64_t> depth(graph.num_vertices(), 0);
Expand Down
12 changes: 6 additions & 6 deletions include/c_types/pgr_mst_rt.h → include/c_types/mst_rt.h
@@ -1,5 +1,5 @@
/*PGR-GNU*****************************************************************
File: pgr_kruskal_t.h
File: mst_rt.h
Copyright (c) 2015 Aditya Pratap Singh
Mail: adityapratap.singh28@gmail.com
Expand All @@ -22,8 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
/*! @file */

#ifndef INCLUDE_C_TYPES_PGR_MST_RT_H_
#define INCLUDE_C_TYPES_PGR_MST_RT_H_
#ifndef INCLUDE_C_TYPES_MST_RT_H_
#define INCLUDE_C_TYPES_MST_RT_H_
#pragma once

/* for int64_t */
Expand All @@ -33,13 +33,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# include <stdint.h>
#endif

typedef struct {
struct MST_rt {
int64_t from_v;
int64_t depth;
int64_t node;
int64_t edge;
double cost;
double agg_cost;
} pgr_mst_rt;
};

#endif // INCLUDE_C_TYPES_PGR_MST_RT_H_
#endif // INCLUDE_C_TYPES_MST_RT_H_
Expand Up @@ -34,12 +34,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
/* for size-t */
#ifdef __cplusplus
# include <cstddef>
# include <cstdint>
#else
# include <stddef.h>
# include <stdint.h>
#endif

typedef struct Edge_t Edge_t;
#include "c_types/pgr_mst_rt.h"
typedef struct MST_rt MST_rt;

#ifdef __cplusplus
extern "C" {
Expand All @@ -60,7 +62,7 @@ extern "C" {
size_t size_start_vidsArr,
int64_t max_depth,
bool directed,
pgr_mst_rt **return_tuples,
MST_rt **return_tuples,
size_t *return_count,
char ** log_msg,
char ** notice_msg,
Expand Down
2 changes: 0 additions & 2 deletions include/drivers/components/makeConnected_driver.h
Expand Up @@ -39,8 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#endif

typedef struct Edge_t Edge_t;
#include "c_types/pgr_mst_rt.h"

typedef struct pgr_makeConnected_t pgr_makeConnected_t;

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion include/drivers/planar/boyerMyrvold_driver.h
Expand Up @@ -40,7 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

typedef struct Edge_t Edge_t;
#include "c_types/pgr_boyer_t.h"
#include "c_types/pgr_mst_rt.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 0 additions & 1 deletion include/drivers/planar/isPlanar_driver.h
Expand Up @@ -40,7 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

typedef struct Edge_t Edge_t;
#include "c_types/pgr_boyer_t.h"
#include "c_types/pgr_mst_rt.h"

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 4 additions & 2 deletions include/drivers/spanningTree/kruskal_driver.h
Expand Up @@ -34,12 +34,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
/* for size-t */
#ifdef __cplusplus
# include <cstddef>
# include <cstdint>
#else
# include <stddef.h>
# include <stdint.h>
#endif

typedef struct Edge_t Edge_t;
#include "c_types/pgr_mst_rt.h"
typedef struct MST_rt MST_rt;

#ifdef __cplusplus
extern "C" {
Expand All @@ -58,7 +60,7 @@ extern "C" {
int64_t max_depth,
double distance,

pgr_mst_rt **return_tuples,
MST_rt **return_tuples,
size_t *return_count,
char ** log_msg,
char ** notice_msg,
Expand Down
6 changes: 4 additions & 2 deletions include/drivers/spanningTree/prim_driver.h
Expand Up @@ -34,12 +34,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
/* for size-t */
#ifdef __cplusplus
# include <cstddef>
# include <cstdint>
#else
# include <stddef.h>
# include <stdint.h>
#endif

typedef struct Edge_t Edge_t;
#include "c_types/pgr_mst_rt.h"
typedef struct MST_rt MST_rt;

#ifdef __cplusplus
extern "C" {
Expand All @@ -57,7 +59,7 @@ void do_pgr_prim(
int64_t max_depth,
double distance,

pgr_mst_rt **return_tuples,
MST_rt **return_tuples,
size_t *return_count,

char ** log_msg,
Expand Down
6 changes: 4 additions & 2 deletions include/drivers/traversal/depthFirstSearch_driver.h
Expand Up @@ -34,12 +34,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
/* for size-t */
#ifdef __cplusplus
# include <cstddef>
# include <cstdint>
#else
# include <stddef.h>
# include <stdint.h>
#endif

typedef struct Edge_t Edge_t;
#include "c_types/pgr_mst_rt.h"
typedef struct MST_rt MST_rt;

#ifdef __cplusplus
extern "C" {
Expand All @@ -65,7 +67,7 @@ extern "C" {
bool directed,
int64_t max_depth,

pgr_mst_rt **return_tuples,
MST_rt **return_tuples,
size_t *return_count,

char ** log_msg,
Expand Down
4 changes: 2 additions & 2 deletions include/spanningTree/details.hpp
Expand Up @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#pragma once

#include <vector>
#include "c_types/pgr_mst_rt.h"
#include "c_types/mst_rt.h"

namespace pgrouting {

Expand All @@ -36,7 +36,7 @@ namespace details {
std::vector<int64_t>
clean_vids(std::vector<int64_t> vids);

std::vector<pgr_mst_rt>
std::vector<MST_rt>
get_no_edge_graph_result(
std::vector<int64_t> vids);

Expand Down
16 changes: 8 additions & 8 deletions include/spanningTree/pgr_kruskal.hpp
Expand Up @@ -40,19 +40,19 @@ namespace functions {
template <class G>
class Pgr_kruskal : public Pgr_mst<G> {
public:
std::vector<pgr_mst_rt> kruskal(G &graph);
std::vector<MST_rt> kruskal(G &graph);

std::vector<pgr_mst_rt> kruskalBFS(
std::vector<MST_rt> kruskalBFS(
G &graph,
std::vector<int64_t> roots,
int64_t max_depth);

std::vector<pgr_mst_rt> kruskalDFS(
std::vector<MST_rt> kruskalDFS(
G &graph,
std::vector<int64_t> roots,
int64_t max_depth);

std::vector<pgr_mst_rt> kruskalDD(
std::vector<MST_rt> kruskalDD(
G &graph,
std::vector<int64_t> roots,
double distance);
Expand Down Expand Up @@ -81,15 +81,15 @@ Pgr_kruskal<G>::generate_mst(const G &graph) {


template <class G>
std::vector<pgr_mst_rt>
std::vector<MST_rt>
Pgr_kruskal<G>::kruskal(
G &graph) {
return this->mst(graph);
}


template <class G>
std::vector<pgr_mst_rt>
std::vector<MST_rt>
Pgr_kruskal<G>::kruskalBFS(
G &graph,
std::vector<int64_t> roots,
Expand All @@ -98,7 +98,7 @@ Pgr_kruskal<G>::kruskalBFS(
}

template <class G>
std::vector<pgr_mst_rt>
std::vector<MST_rt>
Pgr_kruskal<G>::kruskalDFS(
G &graph,
std::vector<int64_t> roots,
Expand All @@ -107,7 +107,7 @@ Pgr_kruskal<G>::kruskalDFS(
}

template <class G>
std::vector<pgr_mst_rt>
std::vector<MST_rt>
Pgr_kruskal<G>::kruskalDD(
G &graph,
std::vector<int64_t> roots,
Expand Down
30 changes: 15 additions & 15 deletions include/spanningTree/pgr_mst.hpp
Expand Up @@ -62,22 +62,22 @@ class Pgr_mst {
this->m_tree_id.clear();
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
no_order(const G &graph) {
return no_ordering(graph);
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
dfs_order(const G &graph) {
return dfs_ordering(graph);
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
bfs_order(const G &graph) {
return bfs_ordering(graph);
}

std::vector<pgr_mst_rt> mst(const G &graph) {
std::vector<MST_rt> mst(const G &graph) {
m_suffix = "";
m_get_component = false;
m_distance = -1;
Expand All @@ -90,7 +90,7 @@ class Pgr_mst {
}


std::vector<pgr_mst_rt> mstBFS(
std::vector<MST_rt> mstBFS(
const G &graph,
std::vector<int64_t> roots,
int64_t max_depth) {
Expand All @@ -104,7 +104,7 @@ class Pgr_mst {
return bfs_order(graph);
}

std::vector<pgr_mst_rt> mstDFS(
std::vector<MST_rt> mstDFS(
const G &graph,
std::vector<int64_t> roots,
int64_t max_depth) {
Expand All @@ -118,7 +118,7 @@ class Pgr_mst {
return dfs_order(graph);
}

std::vector<pgr_mst_rt> mstDD(
std::vector<MST_rt> mstDD(
const G &graph,
std::vector<int64_t> roots,
double distance) {
Expand Down Expand Up @@ -167,11 +167,11 @@ class Pgr_mst {

private:
template <typename T>
std::vector<pgr_mst_rt> get_results(
std::vector<MST_rt> get_results(
T order,
int64_t p_root,
const G &graph) {
std::vector<pgr_mst_rt> results;
std::vector<MST_rt> results;

std::vector<double> agg_cost(graph.num_vertices(), 0);
std::vector<int64_t> depth(graph.num_vertices(), 0);
Expand Down Expand Up @@ -246,12 +246,12 @@ class Pgr_mst {
}
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
no_ordering(const G &graph) {
return get_results(m_spanning_tree.edges, 0, graph);
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
dfs_forest(const G &graph) {
boost::filtered_graph<B_G, InSpanning, boost::keep_all>
mstGraph(graph.graph, m_spanning_tree, {});
Expand All @@ -276,15 +276,15 @@ class Pgr_mst {
}


std::vector<pgr_mst_rt>
std::vector<MST_rt>
dfs_ordering(const G &graph) {
boost::filtered_graph<B_G, InSpanning, boost::keep_all>
mstGraph(graph.graph, m_spanning_tree, {});

if (m_roots.empty()) {
return dfs_forest(graph);
} else {
std::vector<pgr_mst_rt> results;
std::vector<MST_rt> results;
for (const auto root : m_roots) {
std::vector<E> visited_order;

Expand Down Expand Up @@ -318,9 +318,9 @@ class Pgr_mst {
}
}

std::vector<pgr_mst_rt>
std::vector<MST_rt>
bfs_ordering(const G &graph) {
std::vector<pgr_mst_rt> results;
std::vector<MST_rt> results;
/*
* order by bfs
*/
Expand Down

0 comments on commit 2a3d174

Please sign in to comment.