61 #include <boost/config.hpp> 62 #include <boost/graph/adjacency_list.hpp> 63 #include <boost/graph/breadth_first_search.hpp> 64 #include <boost/graph/filtered_graph.hpp> 65 #include <boost/graph/graph_utility.hpp> 66 #include <boost/graph/graphviz.hpp> 67 #include <boost/graph/strong_components.hpp> 68 #include <boost/graph/topological_sort.hpp> 69 #include <boost/version.hpp> 88 boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS,
100 (*this)[boost::graph_bundle] = g_info;
110 size_t index = boost::num_vertices(*
this);
111 boost::graph_traits<boost_raw_graph>::vertex_descriptor new_v = boost::add_vertex(*
this);
112 (*this)[new_v] = v_info;
113 boost::get(boost::vertex_index_t(), *
this)[new_v] =
index;
117 inline void RemoveVertex(boost::graph_traits<boost_raw_graph>::vertex_descriptor v)
119 boost::remove_vertex(v, *
this);
121 boost::get(boost::vertex_index_t(), *
this);
122 boost::graph_traits<boost_raw_graph>::vertex_iterator v_it, v_it_end;
124 for(boost::tie(v_it, v_it_end) = boost::vertices(*
this); v_it != v_it_end; v_it++, index++)
126 index_map[*v_it] =
index;
130 inline boost::graph_traits<boost_raw_graph>::edge_descriptor
131 AddEdge(boost::graph_traits<boost_raw_graph>::vertex_descriptor src,
132 boost::graph_traits<boost_raw_graph>::vertex_descriptor tgt,
const EdgeInfoRef e_info)
134 boost::graph_traits<boost_raw_graph>::edge_descriptor e;
136 boost::tie(e, found) = boost::edge(src, tgt, *
this);
137 THROW_ASSERT(not found,
"Trying to insert an already existing edge");
138 boost::tie(e, found) = boost::add_edge(src, tgt, e_info, *
this);
143 inline void RemoveEdge(boost::graph_traits<boost_raw_graph>::edge_descriptor e)
145 boost::remove_edge(boost::source(e, *
this),
boost::target(e, *
this), *
this);
148 inline void RemoveEdge(boost::graph_traits<boost_raw_graph>::vertex_descriptor src,
149 boost::graph_traits<boost_raw_graph>::vertex_descriptor tgt)
151 boost::graph_traits<boost_raw_graph>::edge_descriptor e;
153 boost::tie(e, found) = boost::edge(src, tgt, *
this);
155 boost::remove_edge(boost::source(e, *
this),
boost::target(e, *
this), *
this);
166 template <
class info_
object,
class Graph>
176 "Function get_raw_edge_info: the edges associated with the graph used are not derived from " 177 "info_object\n\tCheck the actual type of info_object and the type of the edge of Graph");
178 return GetPointer<info_object>(info);
187 template <
class info_
object,
class Graph>
191 THROW_ASSERT(!info || dynamic_cast<const info_object*>(info) !=
nullptr,
192 "Function Cget_raw_edge_info: the edges associated with the graph used are not derived from " 193 "info_object\n\tCheck the actual type of info_object and the type of the edge of Graph");
194 return info ?
dynamic_cast<const info_object*
>(info) :
nullptr;
197 #define GET_RAW_EDGE_INFO(data, edge_info, edge_index) get_edge_info<edge_info>(edge_index, *(data)) 199 #define CGET_RAW_EDGE_INFO(data, edge_info, edge_index) Cget_edge_info<edge_info>(edge_index, *(data)) 236 #if BOOST_VERSION >= 104600 238 boost::listS, boost::listS, boost::bidirectionalS,
239 boost::property<boost::vertex_index_t,
std::size_t,
240 boost::property<boost::vertex_color_t, boost::default_color_type, NodeInfoRef>>,
244 boost::listS, boost::listS, boost::undirectedS,
245 boost::property<boost::vertex_index_t,
std::size_t,
246 boost::property<boost::vertex_color_t, boost::default_color_type, NodeInfoRef>>,
249 #define boost_CGetOpGraph_property(graph_arg) (graph_arg)[boost::graph_bundle] 261 typedef boost::graph_property_tag
kind;
266 typedef boost::adjacency_list<
267 boost::listS, boost::listS, boost::bidirectionalS,
268 boost::property<boost::vertex_index_t,
std::size_t,
269 boost::property<boost::vertex_color_t, boost::default_color_type, NodeInfoRef>>,
273 typedef boost::adjacency_list<
274 boost::listS, boost::listS, boost::undirectedS,
275 boost::property<boost::vertex_index_t,
std::size_t,
276 boost::property<boost::vertex_color_t, boost::default_color_type, NodeInfoRef>>,
280 #define boost_CGetOpGraph_property(graph_arg) boost::get_property(graph_arg, graph_info_t()) 310 inline boost::graph_traits<graphs_collection>::edge_descriptor
311 AddSelector(
const boost::graph_traits<graphs_collection>::edge_descriptor edge,
const int selector)
313 (*this)[edge].selector |= selector;
322 inline boost::graph_traits<graphs_collection>::edge_descriptor
323 AddSelector(
const boost::graph_traits<graphs_collection>::vertex_descriptor source,
324 const boost::graph_traits<graphs_collection>::vertex_descriptor
target,
const int selector)
326 boost::graph_traits<graphs_collection>::edge_descriptor edge;
328 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
330 AddSelector(edge, selector);
338 inline void RemoveSelector(boost::graph_traits<graphs_collection>::edge_descriptor edge)
340 (*this)[edge].selector = 0;
348 inline void RemoveSelector(boost::graph_traits<graphs_collection>::edge_descriptor edge,
const int selector)
350 (*this)[edge].selector = (*this)[edge].selector & ~selector;
356 inline void RemoveSelector(boost::graph_traits<graphs_collection>::vertex_descriptor source,
357 boost::graph_traits<graphs_collection>::vertex_descriptor
target,
const int selector)
359 boost::graph_traits<graphs_collection>::edge_descriptor edge;
361 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
363 RemoveSelector(edge, selector);
373 return (*
this)[e].selector;
381 virtual boost::graph_traits<boost_graphs_collection>::vertex_descriptor
AddVertex(
const NodeInfoRef info);
391 inline boost::graph_traits<graphs_collection>::edge_descriptor
392 AddEdge(boost::graph_traits<graphs_collection>::vertex_descriptor,
393 boost::graph_traits<graphs_collection>::vertex_descriptor,
const int)
396 return boost::graph_traits<graphs_collection>::edge_descriptor();
407 inline boost::graph_traits<graphs_collection>::edge_descriptor
409 boost::graph_traits<graphs_collection>::vertex_descriptor
target,
const int selector,
412 boost::graph_traits<graphs_collection>::edge_descriptor edge;
414 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
415 THROW_ASSERT(not inserted,
"Trying to add an already existing edge");
416 boost::add_edge(source, target,
EdgeProperty(selector), *
this);
417 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
418 AddSelector(source, target, selector);
419 (*this)[edge].info = info;
427 virtual void RemoveVertex(boost::graph_traits<boost_graphs_collection>::vertex_descriptor v);
435 inline bool ExistsEdge(
const boost::graph_traits<graphs_collection>::vertex_descriptor source,
436 const boost::graph_traits<graphs_collection>::vertex_descriptor
target)
const 438 boost::graph_traits<graphs_collection>::edge_descriptor edge;
440 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
446 std::deque<boost::graph_traits<graphs_collection>::edge_descriptor> toBeRemoved;
447 boost::graph_traits<graphs_collection>::edge_iterator ei0, ei0_end;
448 for(boost::tie(ei0, ei0_end) =
boost::edges(*
this); ei0 != ei0_end; ++ei0)
450 if((*
this)[*ei0].selector == 0)
452 toBeRemoved.push_back(*ei0);
455 for(
auto e0 : toBeRemoved)
457 boost::remove_edge(e0, *
this);
479 inline boost::graph_traits<undirected_boost_graphs_collection>::vertex_descriptor
AddVertex()
481 size_t index = boost::num_vertices(*
this);
482 boost::graph_traits<undirected_boost_graphs_collection>::vertex_descriptor v = boost::add_vertex(*
this);
483 boost::get(boost::vertex_index_t(), *
this)[v] =
index;
491 inline void RemoveVertex(boost::graph_traits<undirected_boost_graphs_collection>::vertex_descriptor v)
493 boost::remove_vertex(v, *
this);
495 boost::get(boost::vertex_index_t(), *
this);
496 boost::graph_traits<undirected_boost_graphs_collection>::vertex_iterator v_it, v_it_end;
498 for(boost::tie(v_it, v_it_end) = boost::vertices(*
this); v_it != v_it_end; v_it++, index++)
500 index_map[*v_it] =
index;
511 return (*
this)[e].selector;
521 (*this)[e].selector = selector;
534 template <
class info_
object,
class Graph>
552 template <
class info_
object,
class Graph>
559 #define SET_NODE_INFO_REF(data, NodeInfo, obj, vertex_index) set_node_info<NodeInfo>(vertex_index, obj, *(data)) 561 #define GET_NODE_INFO_REF(data, NodeInfo, vertex_index) Cget_node_infoRef<NodeInfo>(vertex_index, *(data)) 570 template <
class info_
object,
class Graph>
579 "Function get_node_info: the vertices associated with the graph used are not derived from " 580 "info_object\n\tCheck the actual type of info_object and the type of the node of Graph");
581 return GetPointer<info_object>(info);
591 template <
class info_
object,
class Graph>
592 const info_object*
Cget_node_info(
typename boost::graph_traits<Graph>::vertex_descriptor v,
const Graph& g)
595 THROW_ASSERT(!info || dynamic_cast<const info_object*>(info) !=
nullptr,
596 "Function Cget_node_info: the nodes associated with the graph used are not derived from " 597 "info_object\n\tCheck the actual type of info_object and the type of the node of Graph");
598 return info ?
dynamic_cast<const info_object*
>(info) :
nullptr;
601 #define GET_NODE_INFO(data, NodeInfo, vertex_index) get_node_info<NodeInfo>(vertex_index, *(data)) 603 #define CGET_NODE_INFO(data, NodeInfo, vertex_index) Cget_node_info<NodeInfo>(vertex_index, *(data)) 612 template <
class info_
object,
class Graph>
622 "Function get_edge_info: the edges associated with the graph used are not derived from " 623 "info_object\n\tCheck the actual type of info_object and the type of the edge of Graph");
624 return GetPointer<info_object>(info);
633 template <
class info_
object,
class Graph>
636 const EdgeInfo* info = g[e].info.get();
637 THROW_ASSERT(!info || dynamic_cast<const info_object*>(info) !=
nullptr,
638 "Function Cget_edge_info: the edges associated with the graph used are not derived from " 639 "info_object\n\tCheck the actual type of info_object and the type of the edge of Graph");
640 return info ?
dynamic_cast<const info_object*
>(info) :
nullptr;
643 #define GET_EDGE_INFO(data, edge_info, edge_index) get_edge_info<edge_info>(edge_index, *(data)) 645 #define CGET_EDGE_INFO(data, edge_info, edge_index) Cget_edge_info<edge_info>(edge_index, *(data)) 650 template <
typename Graph>
673 : all(
false), subset(_subset)
682 bool operator()(
const typename boost::graph_traits<Graph>::vertex_descriptor& v)
const 690 return (subset.find(v) != subset.end());
698 template <
typename Graph>
738 const CustomUnorderedSet<
typename boost::graph_traits<Graph>::vertex_descriptor>& _subgraph_vertices)
739 : selector(_selector), g(_g), subgraph_vertices(_subgraph_vertices), empty(
false)
743 template <
typename Edge>
748 return selector & (*g)[e].selector;
752 typename boost::graph_traits<Graph>::vertex_descriptor u, v;
753 u = boost::source(e, *g);
755 if((selector & (*g)[e].selector) && subgraph_vertices.find(v) != subgraph_vertices.end() &&
756 subgraph_vertices.find(u) != subgraph_vertices.end())
771 struct graph :
public boost::filtered_graph<boost_graphs_collection, SelectEdge<boost_graphs_collection>,
772 SelectVertex<boost_graphs_collection>>
780 inline const NodeInfoConstRef
781 CGetNodeInfo(
typename boost::graph_traits<graphs_collection>::vertex_descriptor node)
const 795 typename boost::graph_traits<graphs_collection>::vertex_descriptor
target)
798 typename boost::graph_traits<graphs_collection>::edge_descriptor edge;
799 boost::tie(edge, found) = boost::edge(source, target, *
this);
801 return GetEdgeInfo(edge);
810 inline const EdgeInfoConstRef
811 CGetEdgeInfo(
typename boost::graph_traits<graphs_collection>::vertex_descriptor source,
812 typename boost::graph_traits<graphs_collection>::vertex_descriptor
target)
const 815 typename boost::graph_traits<graphs_collection>::edge_descriptor edge;
816 boost::tie(edge, found) = boost::edge(source, target, *
this);
818 return CGetEdgeInfo(edge);
829 THROW_ASSERT(info,
"Info not associated with the edge");
838 inline EdgeInfoConstRef
CGetEdgeInfo(
typename boost::graph_traits<graphs_collection>::edge_descriptor edge)
const 840 const EdgeInfoConstRef info = (*this)[edge].info;
841 THROW_ASSERT(info,
"Info not associated with the edge");
858 template <
typename VertexWriterTemplate,
typename EdgeWriterTemplate,
typename GraphWriterTemplate>
859 void InternalWriteDot(
const std::string& file_name,
const VertexWriterConstRef vertex_writer,
860 const EdgeWriterConstRef edge_writer,
const GraphWriterConstRef graph_writer)
const 862 std::ofstream file_stream(file_name.c_str());
863 boost::write_graphviz(file_stream, *
this, *(GetPointer<VertexWriterTemplate>(vertex_writer)),
864 *(GetPointer<EdgeWriterTemplate>(edge_writer)),
865 *(GetPointer<GraphWriterTemplate>(graph_writer)));
892 const CustomUnorderedSet<boost::graph_traits<graphs_collection>::vertex_descriptor>& vertices)
904 friend boost::graph_traits<graph>::vertex_descriptor
VERTEX(
const boost::graph_traits<graph>::vertices_size_type,
908 virtual ~
graph() =
default;
913 bool is_in_subset(
const boost::graph_traits<graph>::vertex_descriptor v)
const 915 return m_vertex_pred(v);
943 inline int GetSelector(
const boost::graph_traits<graphs_collection>::vertex_descriptor source,
944 const boost::graph_traits<graphs_collection>::vertex_descriptor
target)
const 947 typename boost::graph_traits<graphs_collection>::edge_descriptor edge;
948 boost::tie(edge, found) = boost::edge(source, target, *
this);
959 strongly_connected_components)
const 961 std::map<boost::graph_traits<graphs_collection>::vertex_descriptor,
size_t> temp_vertex_to_component;
962 boost::associative_property_map<std::map<boost::graph_traits<graphs_collection>::vertex_descriptor,
size_t>>
963 vertex_to_component(temp_vertex_to_component);
964 boost::strong_components(*
this, vertex_to_component);
965 boost::graph_traits<graph>::vertex_iterator vertex_it, vertex_end;
966 for(boost::tie(vertex_it, vertex_end) = boost::vertices(*
this); vertex_it != vertex_end; vertex_it++)
968 const size_t strongly_connected_component = vertex_to_component[*vertex_it];
969 strongly_connected_components[strongly_connected_component].insert(*vertex_it);
977 boost::bfs_visitor<>* vis)
const 979 boost::breadth_first_search(*
this, node, visitor(*vis));
989 boost::topological_sort(*
this, std::back_inserter(sorted_vertices));
996 void TopologicalSort(std::list<boost::graph_traits<graphs_collection>::vertex_descriptor>& sorted_vertices)
const 998 boost::topological_sort(*
this, std::front_inserter(sorted_vertices));
1004 bool IsReachable(
const boost::graph_traits<graphs_collection>::vertex_descriptor
x,
1005 const boost::graph_traits<graphs_collection>::vertex_descriptor y)
const 1007 std::list<boost::graph_traits<graphs_collection>::vertex_descriptor> running_vertices;
1009 running_vertices.push_back(x);
1010 encountered_vertices.insert(x);
1011 while(not running_vertices.empty())
1013 const boost::graph_traits<graphs_collection>::vertex_descriptor current = running_vertices.front();
1014 running_vertices.pop_front();
1015 boost::graph_traits<graph>::out_edge_iterator oe, oe_end;
1016 for(boost::tie(oe, oe_end) = boost::out_edges(current, *
this); oe != oe_end; oe++)
1018 const boost::graph_traits<graphs_collection>::vertex_descriptor
target =
boost::target(*oe, *
this);
1023 if(encountered_vertices.find(target) == encountered_vertices.end())
1025 encountered_vertices.insert(target);
1026 running_vertices.push_back(target);
1075 template <
typename VertexWriterTemplate,
typename EdgeWriterTemplate>
1077 const EdgeWriterConstRef edge_writer)
const 1079 std::ofstream file_stream(file_name.c_str());
1080 boost::write_graphviz(file_stream, *
this, *(GetPointer<VertexWriterTemplate>(vertex_writer)),
1081 *(GetPointer<EdgeWriterTemplate>(edge_writer)));
1090 inline bool ExistsEdge(
const boost::graph_traits<graphs_collection>::vertex_descriptor source,
1091 const boost::graph_traits<graphs_collection>::vertex_descriptor
target)
const 1093 boost::graph_traits<graphs_collection>::edge_descriptor edge;
1095 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
1105 inline boost::graph_traits<graphs_collection>::edge_descriptor
1106 CGetEdge(
const boost::graph_traits<graphs_collection>::vertex_descriptor source,
1107 const boost::graph_traits<graphs_collection>::vertex_descriptor
target)
const 1109 boost::graph_traits<graphs_collection>::edge_descriptor edge;
1111 boost::tie(edge, inserted) = boost::edge(source, target, *
this);
1112 THROW_ASSERT(inserted,
"Edge does not exist in this graph");
1116 #if BOOST_VERSION >= 104200 1125 #if BOOST_VERSION >= 104600 1130 struct filtered_graph_property_selector
1132 template <
class FilteredGraph,
class Property,
class Tag>
1135 using Graph =
typename FilteredGraph::graph_type;
1136 using Map = property_map<Graph, Tag>;
1138 using const_type =
typename Map::const_type;
1143 struct vertex_property_selector<filtered_graph_tag>
1145 using type = detail::filtered_graph_property_selector;
1148 struct edge_property_selector<filtered_graph_tag>
1150 using type = detail::filtered_graph_property_selector;
1160 :
public boost::filtered_graph<undirected_boost_graphs_collection, SelectEdge<undirected_boost_graphs_collection>,
1161 SelectVertex<undirected_boost_graphs_collection>>
1176 template <
typename UVertexWriterTemplate,
typename UEdgeWriterTemplate>
1177 void InternalWriteDot(
const std::string& file_name,
const UVertexWriterConstRef uvertex_writer,
1178 const UEdgeWriterConstRef uedge_writer)
const 1180 std::ofstream file_stream(file_name.c_str());
1181 boost::write_graphviz(file_stream, *
this, *(GetPointer<UVertexWriterTemplate>(uvertex_writer)),
1182 *(GetPointer<UEdgeWriterTemplate>(uedge_writer)));
1211 const CustomUnorderedSet<boost::graph_traits<undirected_boost_graphs_collection>::vertex_descriptor>& vertices)
1224 friend boost::graph_traits<ugraph>::vertex_descriptor
VERTEX(
const boost::graph_traits<ugraph>::vertices_size_type,
1233 bool is_in_subset(
const boost::graph_traits<ugraph>::vertex_descriptor v)
const 1235 return m_vertex_pred(v);
1257 #if BOOST_VERSION >= 104200 1269 template <
typename Graph>
1287 bool operator()(
const typename boost::graph_traits<Graph>::edge_descriptor first,
1288 const typename boost::graph_traits<Graph>::edge_descriptor second)
const 1290 if(boost::source(first, *g) < boost::source(second, *g))
1294 if(boost::source(first, *g) > boost::source(second, *g))
1303 using vertex = boost::graph_traits<graph>::vertex_descriptor;
1305 #define NULL_VERTEX boost::graph_traits<graph>::null_vertex() 1306 using VertexIterator = boost::graph_traits<graph>::vertex_iterator;
1328 size_t hash_value = 0;
1329 boost::hash_combine(hash_value, edge.m_source);
1330 boost::hash_combine(hash_value, edge.m_target);
1336 template <
typename H>
1339 return H::combine(h, m.m_source, m.m_target);
1342 using uvertex = boost::graph_traits<ugraph>::vertex_descriptor;
1344 #define NULL_UVERTEX boost::graph_traits<ugraph>::null_vertex() 1347 using UGCvertex = boost::graph_traits<undirected_graphs_collection>::vertex_descriptor;
1348 #define NULL_UGCVERTEX boost::graph_traits<undirected_graphs_collection>::null_vertex() 1368 inline boost::graph_traits<graph>::vertex_descriptor
VERTEX(
const boost::graph_traits<graph>::vertices_size_type i,
1380 inline boost::graph_traits<ugraph>::vertex_descriptor
VERTEX(
const boost::graph_traits<ugraph>::vertices_size_type i,
1386 template <
class Graph>
1387 void ADD_UEDGE(
typename boost::graph_traits<Graph>::vertex_descriptor
A,
1388 typename boost::graph_traits<Graph>::vertex_descriptor
B,
int selector,
Graph& g)
1392 boost::tie(e, inserted) = boost::edge(A, B, g);
1395 g[e].selector = g[e].selector | selector;
1399 boost::add_edge(A, B, selector, g);
1421 VertexWriter(
const graph* _graph,
const int _detail_level) : printing_graph(_graph), detail_level(_detail_level)
1435 virtual void operator()(std::ostream& out,
const vertex& v)
const = 0;
1460 : printing_graph(_printing_graph), selector(printing_graph->GetSelector()), detail_level(_detail_level)
1474 virtual void operator()(std::ostream& out,
const EdgeDescriptor& edge)
const = 0;
1496 : printing_graph(_printing_graph), detail_level(_detail_level)
1509 virtual void operator()(std::ostream& out)
const = 0;
1531 : printing_ugraph(_printing_ugraph), detail_level(_detail_level)
1545 virtual void operator()(std::ostream& out,
const uvertex& v)
const = 0;
1570 : printing_ugraph(_printing_ugraph), selector(printing_ugraph->GetSelector()), detail_level(_detail_level)
1584 virtual void operator()(std::ostream& out,
const UEdgeDescriptor& edge)
const = 0;
NodeInfoRef & Cget_node_infoRef(typename boost::graph_traits< Graph >::vertex_descriptor v, Graph &g)
Function returning the reference to the edge information associated with the specified edge...
Functor used to write the content of the edges to a dotty file.
boost::graph_traits< ugraph >::edge_iterator UEdgeIterator
edge_iterator definition.
int GetSelector() const
Return the selector of this graph.
info_object * get_raw_edge_info(typename boost::graph_traits< Graph >::edge_descriptor e, Graph &g)
Function returning the edge information associated with the specified edge.
boost::graph_traits< ugraph >::in_edge_iterator UInEdgeIterator
in_edge_iterator definition.
UVertexWriter(const ugraph *_printing_ugraph, const int _detail_level)
Constructor.
#define boost_CGetOpGraph_property(graph_arg)
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
absl::node_hash_set< _Value, _Hash, _Pred, _Alloc > UnorderedSetStdStable
const int detail_level
The detail level.
int selector
The selector associated with the edge.
VertexWriter(const graph *_graph, const int _detail_level)
Constructor.
void RemoveVertex(boost::graph_traits< boost_raw_graph >::vertex_descriptor v)
const ParameterConstRef parameters
Set of input parameters.
const graph * printing_graph
The graph to be printed.
const graph * printing_graph
The graph to be printed.
boost::graph_traits< graphs_collection >::edge_descriptor AddEdge(boost::graph_traits< graphs_collection >::vertex_descriptor, boost::graph_traits< graphs_collection >::vertex_descriptor, const int)
Add an edge to this graph FIXME: this should be pure virtual.
boost::graph_traits< boost_raw_graph >::vertex_descriptor AddVertex(const NodeInfoRef v_info)
ugraph(undirected_graphs_collection *g, const int _selector)
Standard constructor.
This algorithm is to find coloring of a graph Algorithm: Let G = (V,E) be a graph with vertices v_1...
boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property< boost::vertex_index_t, std::size_t, NodeInfoRef >, EdgeInfoRef, GraphInfoRef > boost_raw_graph
const int detail_level
The deail level; if one, tate of the graph is printed.
const int detail_level
The detail level (i.e., how much information has to be included)
EdgeProperty()
Default constructor.
EdgeInfoRef GetEdgeInfo(typename boost::graph_traits< graphs_collection >::vertex_descriptor source, typename boost::graph_traits< graphs_collection >::vertex_descriptor target)
Get the edge property.
void GetStronglyConnectedComponents(std::map< size_t, UnorderedSetStdStable< boost::graph_traits< graphs_collection >::vertex_descriptor >> &strongly_connected_components) const
Compute the strongly connected components of the graph.
RawGraph(GraphInfoRef g_info)
Constructor.
boost::graph_traits< ugraph >::vertex_iterator UVertexIterator
vertex_iterator definition.
EdgeWriter(const graph *_printing_graph, const int _detail_level)
Constructor.
ltedge(const Graph *_g)
The constructors.
void BreadthFirstSearch(const boost::graph_traits< graphs_collection >::vertex_descriptor node, boost::bfs_visitor<> *vis) const
Compute the breadth first search.
void InternalWriteDot(const std::string &file_name, const VertexWriterConstRef vertex_writer, const EdgeWriterConstRef edge_writer, const GraphWriterConstRef graph_writer) const
Print the graph in dot format.
boost::graph_traits< ugraph >::edge_descriptor UEdgeDescriptor
edge definition.
int GetSelector(const edge_descriptor e) const
Return the selectors associated with an edge.
void RemoveVertex(boost::graph_traits< undirected_boost_graphs_collection >::vertex_descriptor v)
Remove a vertex from this graph.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
exceptions managed by PandA
const EdgeInfoConstRef CGetEdgeInfo(typename boost::graph_traits< graphs_collection >::vertex_descriptor source, typename boost::graph_traits< graphs_collection >::vertex_descriptor target) const
Get the edge property.
int GetSelector(const boost::graph_traits< graphs_collection >::vertex_descriptor source, const boost::graph_traits< graphs_collection >::vertex_descriptor target) const
Return the selectors associated with an edge.
int GetSelector(const edge_descriptor e) const
Return the selectors associated with an edge.
Definition of hash function for EdgeDescriptor.
The property associated with edge.
EdgeInfoRef info
The info associated with an edge.
bool ExistsEdge(const boost::graph_traits< graphs_collection >::vertex_descriptor source, const boost::graph_traits< graphs_collection >::vertex_descriptor target) const
Check if an edge exists.
SelectEdge()
Default constructor.
info_object * get_node_info(typename boost::graph_traits< Graph >::vertex_descriptor v, Graph &g)
Function returning the node information associated with the specified node.
SelectVertex(const CustomUnorderedSet< typename boost::graph_traits< Graph >::vertex_descriptor > &_subset)
Constructor.
boost::graph_traits< graph >::vertex_descriptor VERTEX(const boost::graph_traits< graph >::vertices_size_type i, const graph &g)
Given a filtered graph and an index returns the vertex exploiting the boost::vertex applied on the or...
void RemoveSelector(boost::graph_traits< graphs_collection >::edge_descriptor edge)
Remove all the selectors of an edge from this graph.
bool all
True if all the vertices have to be selected.
NodeInfoRef GetNodeInfo(typename boost::graph_traits< graphs_collection >::vertex_descriptor node)
FIXME: this method should become protected and called by equivalent method in subclasses Get the node...
Custom graph property: GraphInfo.
bool operator()(const Edge &e) const
void RemoveEdge(boost::graph_traits< boost_raw_graph >::vertex_descriptor src, boost::graph_traits< boost_raw_graph >::vertex_descriptor tgt)
Functor used to sort edges.
boost::graph_traits< boost_raw_graph >::edge_descriptor AddEdge(boost::graph_traits< boost_raw_graph >::vertex_descriptor src, boost::graph_traits< boost_raw_graph >::vertex_descriptor tgt, const EdgeInfoRef e_info)
~RawGraph()=default
Destructor.
graphs_collection(GraphInfoRef info, const ParameterConstRef _parameters)
Constructor of graph.
boost::graph_traits< graphs_collection >::edge_descriptor AddSelector(const boost::graph_traits< graphs_collection >::vertex_descriptor source, const boost::graph_traits< graphs_collection >::vertex_descriptor target, const int selector)
Add a selector to an existing edge.
void ADD_UEDGE(typename boost::graph_traits< Graph >::vertex_descriptor A, typename boost::graph_traits< Graph >::vertex_descriptor B, int selector, Graph &g)
SelectVertex()
Constructor to select all the vertices.
const graph * printing_graph
The graph to be printed.
boost::graph_traits< ugraph >::vertex_descriptor uvertex
vertex definition.
boost::graph_traits< graph >::edge_iterator EdgeIterator
edge_iterator definition.
void RemoveEdge(boost::graph_traits< boost_raw_graph >::edge_descriptor e)
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
const ugraph * printing_ugraph
The graph to be printed.
bool is_in_subset(const boost::graph_traits< ugraph >::vertex_descriptor v) const
return true in case the vertex is a vertex of the subgraph.
EdgeInfoRef GetEdgeInfo(typename boost::graph_traits< graphs_collection >::edge_descriptor edge) const
Get the edge property.
unsigned map[NUM_VERTICES]
Predicate functor object used to select the proper set of edges.
Functor used to write the content of the property of a graph to a dotty file.
void RemoveSelector(boost::graph_traits< graphs_collection >::vertex_descriptor source, boost::graph_traits< graphs_collection >::vertex_descriptor target, const int selector)
Remove an edge from this graph.
boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property< boost::vertex_index_t, std::size_t, boost::property< boost::vertex_color_t, boost::default_color_type, NodeInfoRef > >, EdgeProperty, GraphProperty > boost_graphs_collection
Functor used to write the content of a vertex to dotty file.
bool empty
true when the subvertices set is empty
void RemoveSelector(boost::graph_traits< graphs_collection >::edge_descriptor edge, const int selector)
Remove an edge from this graph.
const NodeInfoConstRef CGetNodeInfo(typename boost::graph_traits< graphs_collection >::vertex_descriptor node) const
Get the node property.
Base class description of data information associated with each node of a graph.
void SetSelector(edge_descriptor e, const int selector)
Set the selector associated with an edge.
const int selector
selector
refcount< EdgeInfo > EdgeInfoRef
RefCount type definition of the edge_info class structure.
redefinition of set to manage ordered/unordered structures
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
const int selector
The selector of the graph to be printed.
graph(graphs_collection *g, const int _selector)
Standard constructor.
General class used to describe a graph in PandA.
boost::graph_traits< graphs_collection >::edge_descriptor CGetEdge(const boost::graph_traits< graphs_collection >::vertex_descriptor source, const boost::graph_traits< graphs_collection >::vertex_descriptor target) const
Returns the edge connecting two vertices; throw error if it does not exist.
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
const info_object * Cget_node_info(typename boost::graph_traits< Graph >::vertex_descriptor v, const Graph &g)
Function returning the node information associated with the specified node.
const int detail_level
The detail level.
Base class storing user data information.
const info_object * Cget_edge_info(typename boost::graph_traits< Graph >::edge_descriptor e, const Graph &g)
Function returning the edge information associated with the specified edge.
boost::graph_traits< graphs_collection >::edge_descriptor AddSelector(const boost::graph_traits< graphs_collection >::edge_descriptor edge, const int selector)
Add a selector to an existing edge.
Functor used to write the content of a vertex to dotty file.
refcount< NodeInfo > NodeInfoRef
RefCount type definition of the NodeInfo class structure.
Base class for graph property.
GraphInfoRef GetGraphInfo()
FIXME: this method should become protected and called by equivalent method in subclasses Get the grap...
ugraph(undirected_graphs_collection *g, const int _selector, const CustomUnorderedSet< boost::graph_traits< undirected_boost_graphs_collection >::vertex_descriptor > &vertices)
Sub-graph constructor.
boost::graph_property_tag kind
typedef defining graph_info_t as graph object
Template definition of refcount.
void TopologicalSort(std::list< boost::graph_traits< graphs_collection >::vertex_descriptor > &sorted_vertices) const
Compute the topological order of the graph.
const info_object * Cget_raw_edge_info(typename boost::graph_traits< Graph >::edge_descriptor e, const Graph &g)
Function returning the edge information associated with the specified edge.
GraphWriter(const graph *_printing_graph, const int _detail_level)
Constructor.
Base class description of data information associated with each edge of a graph.
CustomUnorderedSet< typename boost::graph_traits< Graph >::vertex_descriptor > subgraph_vertices
The vertices of subgraph.
bool operator()(const typename boost::graph_traits< Graph >::vertex_descriptor &v) const
Operator to check if a vertex has to be selected.
bool IsReachable(const boost::graph_traits< graphs_collection >::vertex_descriptor x, const boost::graph_traits< graphs_collection >::vertex_descriptor y) const
Compute if vertex y is reachable from x.
EdgeProperty(int _selector)
Constructor with selector.
bool is_in_subset(const boost::graph_traits< graph >::vertex_descriptor v) const
return true in case the vertex is a vertex of the subgraph.
int selector
The selector associated with the filtered graph.
SelectEdge(const int _selector, Graph *_g)
Constructor for filtering only on selector.
Functor used to write the content of the edges to a dotty file.
const GraphInfoConstRef CGetGraphInfo() const
FIXME: this method should become protected and called by equivalent method in subclasses Get the grap...
int GetSelector(const edge_descriptor e) const
Return the selectors associated with an edge.
void ReverseTopologicalSort(std::deque< boost::graph_traits< graphs_collection >::vertex_descriptor > &sorted_vertices) const
Compute the reverse topological order of the graph.
SelectEdge(const int _selector, Graph *_g, const CustomUnorderedSet< typename boost::graph_traits< Graph >::vertex_descriptor > &_subgraph_vertices)
Constructor for filtering also on vertices.
General class used to describe a graph in PandA.
Predicate functor object used to select the proper set of vertexes.
int GetSelector(const edge_descriptor e) const
Return the selectors associated with an edge.
EdgeProperty(const int _selector, EdgeInfoRef _info)
Constructor with selector and property.
UEdgeWriter(const ugraph *_printing_ugraph, const int _detail_level)
Constructor.
bool operator()(const typename boost::graph_traits< Graph >::edge_descriptor first, const typename boost::graph_traits< Graph >::edge_descriptor second) const
Redefinition of binary operator as less than.
undirected_graphs_collection * collection
The graph collection.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
void set_node_info(typename boost::graph_traits< Graph >::vertex_descriptor v, const refcount< info_object > &obj, Graph &g)
Function returning the node information associated with the specified node.
int GetSelector() const
Return the selector of this graph.
boost::graph_traits< undirected_graphs_collection >::vertex_descriptor UGCvertex
vertex definition for undirected_graphs_collection.
REF_FORWARD_DECL(NodeInfo)
const int detail_level
The detail level.
boost::adjacency_list< boost::listS, boost::listS, boost::undirectedS, boost::property< boost::vertex_index_t, std::size_t, boost::property< boost::vertex_color_t, boost::default_color_type, NodeInfoRef > >, EdgeProperty, GraphProperty > undirected_boost_graphs_collection
const int selector
The selector of the graph to be printed.
info_object * get_edge_info(typename boost::graph_traits< Graph >::edge_descriptor e, Graph &g)
Function returning the edge information associated with the specified edge.
boost::graph_traits< ugraph >::out_edge_iterator UOutEdgeIterator
out_edge_iterator definition.
void InternalWriteDot(const std::string &file_name, const VertexWriterConstRef vertex_writer, const EdgeWriterConstRef edge_writer) const
Print the graph in dot format FIXME: this method should become protected and called by WriteDot...
CustomUnorderedSet< typename boost::graph_traits< Graph >::vertex_descriptor > subset
The set of vertices to be considered.
x
Return the smallest n such that 2^n >= _x.
boost::property< graph_info_t, GraphInfoRef > GraphProperty
const int selector
selector
boost::graph_traits< graphs_collection >::edge_descriptor InternalAddEdge(boost::graph_traits< graphs_collection >::vertex_descriptor source, boost::graph_traits< graphs_collection >::vertex_descriptor target, const int selector, const EdgeInfoRef info)
Add an edge to this graph FIXME: this should be protected.
size_t operator()(EdgeDescriptor edge) const
graphs_collection * collection
The graph collection.
EdgeInfoConstRef CGetEdgeInfo(typename boost::graph_traits< graphs_collection >::edge_descriptor edge) const
Get the edge property.
CONSTREF_FORWARD_DECL(EdgeInfo)
boost::graph_traits< undirected_boost_graphs_collection >::vertex_descriptor AddVertex()
Add a vertex to this graph.
const ugraph * printing_ugraph
The graph to be printed.
graph(graphs_collection *g, const int _selector, const CustomUnorderedSet< boost::graph_traits< graphs_collection >::vertex_descriptor > &vertices)
Sub-graph constructor.
bool ExistsEdge(const boost::graph_traits< graphs_collection >::vertex_descriptor source, const boost::graph_traits< graphs_collection >::vertex_descriptor target) const
Check if an edge exists.
H AbslHashValue(const H &h, const EdgeDescriptor &m)
void InternalWriteDot(const std::string &file_name, const UVertexWriterConstRef uvertex_writer, const UEdgeWriterConstRef uedge_writer) const
Print the graph in dot format.
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...