4 #include <boost/graph/graphviz.hpp> 14 typedef std::shared_ptr<float>
fptr_t;
15 typedef std::variant<iptr_t, fptr_t>
if_t;
25 return ptr == other.
ptr;
34 if (std::holds_alternative<iptr_t>(n.
ptr)) {
35 return (
size_t)(std::get<iptr_t>(n.
ptr).
get());
37 if (std::holds_alternative<fptr_t>(n.
ptr)) {
38 return (
size_t)(std::get<fptr_t>(n.
ptr).
get());
49 std::unordered_map<if_t, int> p2i;
53 if_t one = std::make_shared<int>(42);
54 if_t two = std::make_shared<float>(6.9);
55 if_t tre = std::make_shared<float>(33);
63 Assert(*std::get<1>(two) < *std::get<1>(tre));
65 Assert(*std::get<0>(one) == 42);
66 Assert(
nullptr == std::get_if<1>(&one));
73 auto v1 = g.vertex(one);
74 auto v2 = g.vertex(one);
80 auto verts = boost::vertices(g.graph());
81 Assert(verts.second-verts.first == 3);
85 indexed_graph_t
g2(g.graph());
87 for (
auto n :
g2.neighbors(two)) {
93 std::vector<std::string> names{
"one",
"two",
"tre"};
94 std::unordered_map<indexed_graph_t::vdesc_t, std::string> ids;
95 for (
auto u : boost::make_iterator_range(vertices(
g2.graph()))) {
96 ids[u] = names[ids.size()];
98 boost::default_writer
w;
99 boost::write_graphviz(std::cout,
102 boost::make_assoc_property_map(ids));
if_node_t(const fptr_t &f)
std::variant< iptr_t, fptr_t > if_t
if_node_t(const if_t &ift)
bool operator==(const if_node_t &other) const
std::shared_ptr< int > iptr_t
std::shared_ptr< float > fptr_t
std::size_t operator()(const if_node_t &n) const
if_node_t(const iptr_t &i)