Commit 9656f38f authored by Asal Asgari's avatar Asal Asgari
Browse files

Update graph_bench_fixtures.h

Added Benchmark to graphtraversals
parent 58f9850e
......@@ -140,6 +140,295 @@ namespace dte3603::predef::benchmarking::graph::fixtures
return {{B, C}, {B, E, C}, {B, E, F, C}, {D, E, C}, {D, E, F, C}};
}
};
class TreeDAG
: public detail::GoldGraphTemplate<detail::types::BidirectionalGraph> {
using Base = detail::GoldGraphTemplate<detail::types::BidirectionalGraph>;
VD A;
VD B;
VD C;
VD D;
VD E;
public:
TreeDAG()
{
// clang-format off
/*!
* A --> B --> C --> D
*
* |
* V
*
* E
*/
// clang-format on
A = boost::add_vertex(VP{.name = "A"}, m_graph);
B = boost::add_vertex(VP{.name = "B"}, m_graph);
C = boost::add_vertex(VP{.name = "C"}, m_graph);
D = boost::add_vertex(VP{.name = "D"}, m_graph);
E = boost::add_vertex(VP{.name = "E"}, m_graph);
// bgl has "implicit" alphanumeric child-ordering
boost::add_edge(A, B, EP{.distance = 1.}, m_graph);
boost::add_edge(B, C, EP{.distance = 1.}, m_graph);
boost::add_edge(B, E, EP{.distance = 1.}, m_graph);
boost::add_edge(C, D, EP{.distance = 1.}, m_graph);
}
~TreeDAG() override {}
VD const& a() const { return A; }
VD const& b() const { return B; }
VD const& c() const { return C; }
VD const& d() const { return D; }
VDVector dfsFromAGold() const { return {B, C, D, E}; }
VDVector bfsFromAGold() const { return {B, C, E, D}; }
};
class DAGOne
: public detail::GoldGraphTemplate<detail::types::BidirectionalGraph> {
using Base = detail::GoldGraphTemplate<detail::types::BidirectionalGraph>;
VD A;
VD B;
VD C;
VD D;
VD E;
VD F;
public:
DAGOne()
{
// clang-format off
/*!
* A --> B C
*
* ^ | ^ ^
* | V / |
*
* D --> E --> F
*/
// clang-format on
A = boost::add_vertex(VP{.name = "A"}, m_graph); // 0
B = boost::add_vertex(VP{.name = "B"}, m_graph); // 1
C = boost::add_vertex(VP{.name = "C"}, m_graph); // 2
D = boost::add_vertex(VP{.name = "D"}, m_graph); // 3
E = boost::add_vertex(VP{.name = "E"}, m_graph); // 4
F = boost::add_vertex(VP{.name = "F"}, m_graph); // 5
// bgl has "implicit" alphanumeric child-ordering
boost::add_edge(A, B, EP{.distance = 1.}, m_graph);
boost::add_edge(B, E, EP{.distance = 1.}, m_graph);
boost::add_edge(D, A, EP{.distance = 1.}, m_graph);
boost::add_edge(D, E, EP{.distance = 1.}, m_graph);
boost::add_edge(E, C, EP{.distance = 10.}, m_graph);
boost::add_edge(E, F, EP{.distance = 1.}, m_graph);
boost::add_edge(F, C, EP{.distance = 1.}, m_graph);
}
~DAGOne() override {}
VD const& a() const { return A; }
VD const& b() const { return B; }
VD const& c() const { return C; }
VD const& d() const { return D; }
VD const& e() const { return E; }
VD const& f() const { return F; }
VDVector dfsFromAGold() const { return {B, E, C, F}; }
VDVector dfsFromBGold() const { return {E, C, F}; }
VDVector dfsFromCGold() const { return {}; }
VDVector dfsFromDGold() const { return {A, B, E, C, F}; }
VDVector dfsFromEGold() const { return {C, F}; }
VDVector dfsFromFGold() const { return {C}; }
VDVector bfsFromAGold() const { return {B, E, C, F}; }
VDVector bfsFromBGold() const { return {E, C, F}; }
VDVector bfsFromCGold() const { return {}; }
VDVector bfsFromDGold() const { return {A, E, B, C, F}; }
VDVector bfsFromEGold() const { return {C, F}; }
VDVector bfsFromFGold() const { return {C}; }
VDVecVector shortestPathsAEGold() const { return {{B, E}}; }
VDVecVector shortestPathsACGold() const { return {{B, E, F, C}}; }
};
class DAGTwo
: public detail::GoldGraphTemplate<detail::types::BidirectionalGraph> {
using Base = detail::GoldGraphTemplate<detail::types::BidirectionalGraph>;
VD A;
VD B;
VD C;
VD D;
VD E;
VD F;
VD G;
VD H;
public:
DAGTwo()
{
// clang-format off
/*!
* H --> G
*
* ^ ^
* | |
*
* A --> B C
*
* ^ ^ ^ |
* | | / v
*
* D --> E --> F
*/
// clang-format on
A = boost::add_vertex(VP{.name = "A"}, m_graph); // 0
B = boost::add_vertex(VP{.name = "B"}, m_graph); // 1
C = boost::add_vertex(VP{.name = "C"}, m_graph); // 2
D = boost::add_vertex(VP{.name = "D"}, m_graph); // 3
E = boost::add_vertex(VP{.name = "E"}, m_graph); // 4
F = boost::add_vertex(VP{.name = "F"}, m_graph); // 5
G = boost::add_vertex(VP{.name = "G"}, m_graph); // 6
H = boost::add_vertex(VP{.name = "H"}, m_graph); // 7
// bgl has "implicit" alphanumeric child-ordering
boost::add_edge(A, B, EP{.distance = 1.}, m_graph);
boost::add_edge(B, H, EP{.distance = 1.}, m_graph);
boost::add_edge(C, F, EP{.distance = 1.}, m_graph);
boost::add_edge(C, G, EP{.distance = 1.}, m_graph);
boost::add_edge(D, A, EP{.distance = 1.}, m_graph);
boost::add_edge(D, E, EP{.distance = 1.}, m_graph);
boost::add_edge(E, B, EP{.distance = 1.}, m_graph);
boost::add_edge(E, C, EP{.distance = 1.}, m_graph);
boost::add_edge(E, F, EP{.distance = 1.}, m_graph);
boost::add_edge(G, H, EP{.distance = 1.}, m_graph);
}
~DAGTwo() override {}
VD const& a() const { return A; }
VD const& b() const { return B; }
VD const& c() const { return C; }
VD const& d() const { return D; }
VD const& e() const { return E; }
VD const& f() const { return F; }
VD const& g() const { return G; }
VD const& h() const { return H; }
VDVector dfsFromAGold() const { return {B, H}; }
VDVector dfsFromBGold() const { return {H}; }
VDVector dfsFromCGold() const { return {F, G, H}; }
VDVector dfsFromDGold() const { return {A, B, H, E, C, F, G}; }
VDVector dfsFromEGold() const { return {B, H, C, F, G}; }
VDVector dfsFromFGold() const { return {}; }
VDVector dfsFromGGold() const { return {H}; }
VDVector dfsFromHGold() const { return {}; }
VDVector bfsFromAGold() const { return {B, H}; }
VDVector bfsFromBGold() const { return {H}; }
VDVector bfsFromCGold() const { return {F, G, H}; }
VDVector bfsFromDGold() const { return {A, E, B, C, F, H, G}; }
VDVector bfsFromEGold() const { return {B, C, F, H, G}; }
VDVector bfsFromFGold() const { return {}; }
VDVector bfsFromGGold() const { return {H}; }
VDVector bfsFromHGold() const { return {}; }
VDVecVector shortestPathsAEGold() const { return {}; }
VDVecVector shortestPathsACGold() const { return {}; }
};
class DAGThree
: public detail::GoldGraphTemplate<detail::types::BidirectionalGraph> {
using Base = detail::GoldGraphTemplate<detail::types::BidirectionalGraph>;
VD A;
VD B;
VD C;
VD D;
VD E;
VD F;
public:
DAGThree()
{
// clang-format off
/*!
* A --> B --> C
*
* | | ^ ^
* V V / |
*
* D --> E --> F
*/
// clang-format on
A = boost::add_vertex(VP{.name = "A"}, m_graph); // 0
B = boost::add_vertex(VP{.name = "B"}, m_graph); // 1
C = boost::add_vertex(VP{.name = "C"}, m_graph); // 2
D = boost::add_vertex(VP{.name = "D"}, m_graph); // 3
E = boost::add_vertex(VP{.name = "E"}, m_graph); // 4
F = boost::add_vertex(VP{.name = "F"}, m_graph); // 5
// bgl has "implicit" alphanumeric child-ordering
boost::add_edge(A, B, EP{.distance = 1.}, m_graph);
boost::add_edge(A, D, EP{.distance = 2.}, m_graph);
boost::add_edge(B, C, EP{.distance = 4.}, m_graph);
boost::add_edge(B, E, EP{.distance = 2.}, m_graph);
boost::add_edge(D, E, EP{.distance = 1.}, m_graph);
boost::add_edge(E, C, EP{.distance = 2.}, m_graph);
boost::add_edge(E, F, EP{.distance = 1.}, m_graph);
boost::add_edge(F, C, EP{.distance = 1.}, m_graph);
}
~DAGThree() override {}
VD const& a() const { return A; }
VD const& b() const { return B; }
VD const& c() const { return C; }
VD const& d() const { return D; }
VD const& e() const { return E; }
VD const& f() const { return F; }
VDVector dfsFromAGold() const { return {B, C, E, F, D}; }
VDVector dfsFromBGold() const { return {C, E, F}; }
VDVector dfsFromCGold() const { return {}; }
VDVector dfsFromDGold() const { return {E, C, F}; }
VDVector dfsFromEGold() const { return {C, F}; }
VDVector dfsFromFGold() const { return {C}; }
VDVector bfsFromAGold() const { return {B, D, C, E, F}; }
VDVector bfsFromBGold() const { return {C, E, F}; }
VDVector bfsFromCGold() const { return {}; }
VDVector bfsFromDGold() const { return {E, C, F}; }
VDVector bfsFromEGold() const { return {C, F}; }
VDVector bfsFromFGold() const { return {C}; }
VDVecVector shortestPathsAEGold() const { return {{B, E}, {D, E}}; }
VDVecVector shortestPathsACGold() const
{
return {{B, C}, {B, E, C}, {B, E, F, C}, {D, E, C}, {D, E, F, C}};
}
};
} // namespace dags
......@@ -163,6 +452,12 @@ namespace dte3603::predef::benchmarking::graph::fixtures
} // namespace detail
using BenchDagOneF = detail::BenchmarkDagTemplateF<detail::dags::BenchDagOne>;
using TreeDagF = detail::BenchmarkDagTemplateF<detail::dags::TreeDAG>;
using DagOneF = detail::BenchmarkDagTemplateF<detail::dags::DAGOne>;
using DagThreeF = detail::BenchmarkDagTemplateF<detail::dags::DAGThree>;
using DagTwoF = detail::BenchmarkDagTemplateF<detail::dags::DAGTwo>;
} // namespace dte3603::predef::benchmarking::graph::fixtures
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment