3 #include <boost/function.hpp>
4 #include <boost/graph/adjacency_list.hpp>
5 #include <boost/graph/breadth_first_search.hpp>
6 #include <boost/graph/depth_first_search.hpp>
7 #include <boost/graph/graph_traits.hpp>
8 #include <boost/graph/graphviz.hpp>
9 #include <boost/graph/labeled_graph.hpp>
10 #include <boost/graph/properties.hpp>
11 #include <boost/property_map/property_map.hpp>
12 #include <boost/thread.hpp>
34 boost::property<boost::vertex_index_t, blk_hash_t, boost::property<boost::vertex_index1_t, uint64_t>>;
39 boost::adjacency_list<boost::setS, boost::hash_setS, boost::directedS, vertex_property_t, edge_property_t>;
40 using graph_t = boost::labeled_graph<adj_list_t, blk_hash_t, boost::hash_mapS>;
41 using vertex_t = boost::graph_traits<graph_t>::vertex_descriptor;
42 using edge_t = boost::graph_traits<graph_t>::edge_descriptor;
44 using edge_iter_t = boost::graph_traits<graph_t>::edge_iterator;
72 void getLeaves(std::vector<blk_hash_t> &tips)
const;
73 void drawGraph(std::string
const &filename)
const;
76 const std::map<uint64_t, std::unordered_set<blk_hash_t>> &non_finalized_blks);
103 :
Dag(dag_genesis_block_hash, node_addr) {}
122 template <
class Property1>
126 template <
class Vertex>
128 out <<
"[label=\"" <<
name[v].toString().substr(0, 8) <<
" "
136 template <
class Property>
140 template <
class Edge>
143 out <<
"[style=\"dashed\" dir=\"back\"]";
145 out <<
"[dir=\"back\"]";
Definition: key_manager.hpp:11
boost::property< boost::vertex_index_t, blk_hash_t, boost::property< boost::vertex_index1_t, uint64_t > > vertex_property_t
Definition: dag.hpp:34
virtual ~PivotTree()=default
graph_t graph_
Definition: dag.hpp:88
edge_label_writer(Property weight)
Definition: dag.hpp:139
boost::property_map< graph_t, boost::vertex_index_t >::const_type vertex_index_map_const_t
Definition: dag.hpp:48
PivotTree & operator=(PivotTree &&)=default
boost::property< boost::edge_index_t, uint64_t > edge_property_t
Definition: dag.hpp:35
boost::graph_traits< graph_t >::adjacency_iterator vertex_adj_iter_t
Definition: dag.hpp:45
bool computeOrder(const blk_hash_t &anchor, std::vector< blk_hash_t > &ordered_period_vertices, const std::map< uint64_t, std::unordered_set< blk_hash_t >> &non_finalized_blks)
Definition: dag.cpp:103
boost::property_map< graph_t, boost::vertex_index1_t >::type vertex_period_map_t
Definition: dag.hpp:52
void collectLeafVertices(std::vector< vertex_t > &leaves) const
Definition: dag.cpp:89
bool reachable(vertex_t const &from, vertex_t const &to) const
Definition: dag.cpp:173
void getLeaves(std::vector< blk_hash_t > &tips) const
Definition: dag.cpp:29
boost::property_map< graph_t, boost::edge_index_t >::const_type edge_index_map_const_t
Definition: dag.hpp:54
bool hasVertex(blk_hash_t const &v) const
Definition: dag.cpp:27
std::vector< blk_hash_t > getGhostPath(const blk_hash_t &vertex) const
Definition: dag.cpp:204
friend DagManager
Definition: dag.hpp:57
uint64_t getNumEdges() const
Definition: dag.cpp:25
bool addVEEs(blk_hash_t const &new_vertex, blk_hash_t const &pivot, std::vector< blk_hash_t > const &tips)
Definition: dag.cpp:37
boost::property_map< graph_t, boost::vertex_index_t >::type vertex_index_map_t
Definition: dag.hpp:49
Dag & operator=(Dag &&)=default
boost::graph_traits< graph_t >::edge_iterator edge_iter_t
Definition: dag.hpp:44
vertex_label_writer(Property1 name)
Definition: dag.hpp:125
boost::labeled_graph< adj_list_t, blk_hash_t, boost::hash_mapS > graph_t
Definition: dag.hpp:40
boost::graph_traits< graph_t >::vertex_iterator vertex_iter_t
Definition: dag.hpp:43
boost::property_map< graph_t, boost::vertex_index1_t >::const_type vertex_period_map_const_t
Definition: dag.hpp:51
Dag & operator=(const Dag &)=default
Dag(blk_hash_t const &dag_genesis_block_hash, addr_t node_addr)
Definition: dag.cpp:17
PivotTree(const PivotTree &)=default
void drawGraph(std::string const &filename) const
Definition: dag.cpp:77
void operator()(std::ostream &out, const Vertex &v) const
Definition: dag.hpp:127
boost::graph_traits< graph_t >::edge_descriptor edge_t
Definition: dag.hpp:42
Property1 name
Definition: dag.hpp:133
PivotTree & operator=(const PivotTree &)=default
boost::property_map< graph_t, boost::edge_index_t >::type edge_index_map_t
Definition: dag.hpp:55
Property weight
Definition: dag.hpp:150
friend DagManager
Definition: dag.hpp:101
PivotTree(blk_hash_t const &dag_genesis_block_hash, addr_t node_addr)
Definition: dag.hpp:102
boost::adjacency_list< boost::setS, boost::hash_setS, boost::directedS, vertex_property_t, edge_property_t > adj_list_t
Definition: dag.hpp:39
PivotTree(PivotTree &&)=default
boost::graph_traits< graph_t >::vertex_descriptor vertex_t
Definition: dag.hpp:41
void clear()
Definition: dag.cpp:87
uint64_t getNumVertices() const
Definition: dag.cpp:24
void operator()(std::ostream &out, const Edge &e) const
Definition: dag.hpp:141
Thread safe. Labelled graph.
Definition: dag.hpp:30
#define LOG_OBJECTS_DEFINE
Definition: logger.hpp:60