30 #ifndef INCLUDE_LINEGRAPH_PGR_LINEGRAPH_HPP_
31 #define INCLUDE_LINEGRAPH_PGR_LINEGRAPH_HPP_
48 template <
class G,
typename T_V,
typename T_E>
51 typedef typename boost::graph_traits < G >::vertex_descriptor
V;
52 typedef typename boost::graph_traits < G >::edge_descriptor
E;
53 typedef typename boost::graph_traits < G >::vertex_iterator
V_i;
54 typedef typename boost::graph_traits < G >::out_edge_iterator
EO_i;
55 typedef typename boost::graph_traits < G >::in_edge_iterator
EI_i;
73 for (
auto vi = vertices(g.
graph).first;
74 vi != vertices(g.
graph).second; ++vi) {
76 log << (*vi) <<
": " <<
" out_edges_of(" << g.
graph[(*vi)] <<
"):";
77 for (boost::tie(out, out_end) = out_edges(*vi, g.
graph);
78 out != out_end; ++out) {
80 << g.
graph[*out].id <<
"=("
81 << g[g.
source(*out)].id <<
", "
82 << g[g.
target(*out)].id <<
")\t";
90 std::vector< Line_graph_rt >
92 std::vector< Line_graph_rt > results;
94 typename boost::graph_traits < G >::edge_iterator edgeIt, edgeEnd;
95 std::map < std::pair<int64_t, int64_t >,
Line_graph_rt > unique;
98 for (boost::tie(edgeIt, edgeEnd) = boost::edges(this->
graph);
99 edgeIt != edgeEnd; edgeIt++) {
101 auto e_source = this->
graph[this->
source(e)].vertex_id;
102 auto e_target = this->
graph[this->
target(e)].vertex_id;
104 if (unique.find({e_target, e_source}) != unique.end()) {
105 unique[std::pair<int64_t, int64_t>(e_target,
106 e_source)].reverse_cost = 1.0;
111 if (unique.find({e_target, e_source}) != unique.end()) {
112 unique[std::pair<int64_t, int64_t>(e_target,
113 e_source)].reverse_cost = 1.0;
126 unique[std::pair<int64_t, int64_t>(e_source, e_target)] =
edge;
128 for (
const auto &
edge : unique) {
129 results.push_back(
edge.second);
136 auto es = boost::edges(digraph.
graph);
137 for (
auto eit = es.first; eit != es.second; ++eit) {
141 digraph[boost::source(
edge, digraph.
graph)].id,
142 digraph[boost::target(
edge, digraph.
graph)].id,
152 template <
typename T>
160 auto vm_s = this->
get_V(source);
161 auto vm_t = this->
get_V(target);
163 boost::tie(e, inserted) =
164 boost::add_edge(vm_s, vm_t, this->
graph);
171 V_i vertexIt, vertexEnd;
172 EO_i e_outIt, e_outEnd;
173 EI_i e_inIt, e_inEnd;
177 for (boost::tie(vertexIt, vertexEnd) = boost::vertices(digraph.
graph);
178 vertexIt != vertexEnd; vertexIt++) {
179 auto vertex = *vertexIt;
182 for (boost::tie(e_outIt, e_outEnd) =
183 boost::out_edges(vertex, digraph.
graph);
187 for (boost::tie(e_inIt, e_inEnd) =
188 boost::in_edges(vertex, digraph.
graph);
189 e_inIt != e_inEnd; e_inIt++) {
195 (digraph.
graph[*e_inIt]).id,
196 (digraph.
graph[*e_outIt]).id);
204 auto v = add_vertex(this->
graph);
206 this->
graph[v].cp_members(vertex);
221 #endif // INCLUDE_LINEGRAPH_PGR_LINEGRAPH_HPP_