ExaTN
directed_boost_graph.hpp
1 
19 #ifndef EXATN_RUNTIME_DAG_HPP_
20 #define EXATN_RUNTIME_DAG_HPP_
21 
22 #include "tensor_graph.hpp"
23 #include "tensor_operation.hpp"
24 #include "tensor.hpp"
25 
26 #include <boost/graph/adjacency_list.hpp>
27 #include <boost/graph/dag_shortest_paths.hpp>
28 #include <boost/graph/dijkstra_shortest_paths.hpp>
29 #include <boost/graph/eccentricity.hpp>
30 #include <boost/graph/exterior_property.hpp>
31 #include <boost/graph/floyd_warshall_shortest.hpp>
32 #include <boost/graph/graph_traits.hpp>
33 #include <boost/graph/graphviz.hpp>
34 #include <boost/property_map/property_map.hpp>
35 
36 #include <type_traits>
37 #include <string>
38 #include <memory>
39 
40 using namespace boost;
41 
42 namespace exatn {
43 namespace runtime {
44 
46  std::shared_ptr<TensorOpNode> properties; //properties of the DAG node
47 };
48 
49 
50 using d_adj_list = adjacency_list<vecS, vecS, directedS, DirectedBoostVertex,
51  boost::property<boost::edge_weight_t, double>>;
52 
53 using DirectedGraphType = std::shared_ptr<d_adj_list>;
54 
55 using d_vertex_type = typename boost::graph_traits<adjacency_list<
56  vecS, vecS, directedS, DirectedBoostVertex,
57  boost::property<boost::edge_weight_t, double>>>::vertex_descriptor;
58 
59 using d_edge_type = typename boost::graph_traits<adjacency_list<
60  vecS, vecS, directedS, DirectedBoostVertex,
61  boost::property<boost::edge_weight_t, double>>>::edge_descriptor;
62 
63 static_assert(std::is_same<d_vertex_type,VertexIdType>::value,"Vertex id type mismatch!");
64 
65 
67 
68 public:
70  DirectedBoostGraph(const DirectedBoostGraph &) = delete;
71  DirectedBoostGraph & operator=(const DirectedBoostGraph &) = delete;
72  DirectedBoostGraph(DirectedBoostGraph &&) noexcept = default;
73  DirectedBoostGraph & operator=(DirectedBoostGraph &&) noexcept = default;
74  virtual ~DirectedBoostGraph() = default;
75 
76  VertexIdType addOperation(std::shared_ptr<TensorOperation> op) override;
77 
78  void addDependency(VertexIdType dependent,
79  VertexIdType dependee) override;
80 
81  bool dependencyExists(VertexIdType vertex_id1,
82  VertexIdType vertex_id2) override;
83 
84  TensorOpNode & getNodeProperties(VertexIdType vertex_id) override;
85 
86  std::size_t getNodeDegree(VertexIdType vertex_id) override;
87 
88  std::size_t getNumNodes() override;
89 
90  std::size_t getNumDependencies() override;
91 
92  std::vector<VertexIdType> getNeighborList(VertexIdType vertex_id) override;
93 
94  void computeShortestPath(VertexIdType startIndex,
95  std::vector<double> & distances,
96  std::vector<VertexIdType> & paths) override;
97 
98  void printIt() override;
99 
100  const std::string name() const override {
101  return "boost-digraph";
102  }
103 
104  const std::string description() const override {
105  return "Directed acyclic graph of tensor operations";
106  }
107 
108  std::shared_ptr<TensorGraph> clone() override {
109  return std::make_shared<DirectedBoostGraph>();
110  }
111 
112 protected:
113  DirectedGraphType dag_; //std::shared_ptr<d_adj_list>
114 };
115 
116 } // namespace runtime
117 } // namespace exatn
118 
119 #endif //EXATN_RUNTIME_DAG_HPP_
exatn::runtime::DirectedBoostGraph::clone
std::shared_ptr< TensorGraph > clone() override
Definition: directed_boost_graph.hpp:108
exatn
Definition: DriverClient.hpp:10
exatn::runtime::DirectedBoostVertex
Definition: directed_boost_graph.hpp:45
exatn::runtime::TensorOpNode
Definition: tensor_graph.hpp:49
exatn::runtime::DirectedBoostGraph
Definition: directed_boost_graph.hpp:66
exatn::runtime::TensorGraph
Definition: tensor_graph.hpp:139