PGROUTING  3.2
lengauerTarjanDominatorTree_driver.cpp File Reference
#include <string>
#include <sstream>
#include <deque>
#include <vector>
#include <algorithm>
#include "cpp_common/identifiers.hpp"
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "c_types/pgr_ltdtree_rt.h"
#include "drivers/dominator/lengauerTarjanDominatorTree_driver.h"
#include "dominator/pgr_lengauerTarjanDominatorTree_driver.hpp"
Include dependency graph for lengauerTarjanDominatorTree_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_LTDTree (pgr_edge_t *data_edges, size_t total_edges, int64_t root_vertex, pgr_ltdtree_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_LTDTree()

void do_pgr_LTDTree ( pgr_edge_t data_edges,
size_t  total_edges,
int64_t  root_vertex,
pgr_ltdtree_rt **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 51 of file lengauerTarjanDominatorTree_driver.cpp.

59  {
60  std::ostringstream log;
61  std::ostringstream notice;
62  std::ostringstream err;
63 
64 
65  try {
66  pgassert(total_edges != 0);
67  pgassert(!(*log_msg));
68  pgassert(!(*notice_msg));
69  pgassert(!(*err_msg));
70  pgassert(!(*return_tuples));
71  pgassert(*return_count == 0);
72 
73  std::string logstr;
74 
75 /***********************Working with graph**************************/
76 
77  graphType gType = DIRECTED;
78  pgrouting::DirectedGraph digraph(gType);
79  digraph.insert_edges(data_edges, total_edges);
80  std::vector<pgr_ltdtree_rt> results;
82  results = fn_LTDTree.pgr_ltdtree(digraph, root_vertex);
83 
84  logstr += fn_LTDTree.get_log();
85  log << logstr;
86 
87  auto count = results.size();
88 
89  if (count == 0) {
90  (*return_tuples) = NULL;
91  (*return_count) = 0;
92  notice << "No result found";
93  *log_msg = log.str().empty()?
94  *log_msg :
95  pgr_msg(log.str().c_str());
96  *notice_msg = notice.str().empty()?
97  *notice_msg :
98  pgr_msg(notice.str().c_str());
99  return;
100  }
101  (*return_tuples) = pgr_alloc(count, (*return_tuples));
102  for (size_t i = 0; i < count; i++) {
103  *((*return_tuples) + i) = results[i];
104  }
105  (*return_count) = count;
106 
107  pgassert(*err_msg == NULL);
108  *log_msg = log.str().empty()?
109  *log_msg :
110  pgr_msg(log.str().c_str());
111  *notice_msg = notice.str().empty()?
112  *notice_msg :
113  pgr_msg(notice.str().c_str());
114  } catch (AssertFailedException &except) {
115  (*return_tuples) = pgr_free(*return_tuples);
116  (*return_count) = 0;
117  err << except.what();
118  *err_msg = pgr_msg(err.str().c_str());
119  *log_msg = pgr_msg(log.str().c_str());
120  } catch (std::exception &except) {
121  (*return_tuples) = pgr_free(*return_tuples);
122  (*return_count) = 0;
123  err << except.what();
124  *err_msg = pgr_msg(err.str().c_str());
125  *log_msg = pgr_msg(log.str().c_str());
126  } catch(...) {
127  (*return_tuples) = pgr_free(*return_tuples);
128  (*return_count) = 0;
129  err << "Caught unknown exception!";
130  *err_msg = pgr_msg(err.str().c_str());
131  *log_msg = pgr_msg(log.str().c_str());
132  }
133 }

References DIRECTED, pgrouting::Pgr_messages::get_log(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_alloc(), pgr_free(), pgrouting::functions::Pgr_LTDTree< G >::pgr_ltdtree(), pgr_msg(), and AssertFailedException::what().

Referenced by process().

pgrouting::functions::Pgr_LTDTree
Definition: pgr_lengauerTarjanDominatorTree_driver.hpp:53
pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
pgrouting::functions::Pgr_LTDTree::pgr_ltdtree
std::vector< pgr_ltdtree_rt > pgr_ltdtree(G &graph, int64_t root)
Definition: pgr_lengauerTarjanDominatorTree_driver.hpp:58
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
AssertFailedException::what
virtual const char * what() const
Definition: pgr_assert.cpp:67
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::Pgr_messages::get_log
std::string get_log() const
get_log
Definition: pgr_messages.cpp:36
graphType
graphType
Definition: graph_enum.h:30
DIRECTED
@ DIRECTED
Definition: graph_enum.h:30
pgr_free
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139