47#include <gtest/gtest.h>
60using namespace testing;
75TEST(GraphNodeTest, DefaultConstruction)
82TEST(GraphNodeTest, ConstructionWithInfo)
88TEST(GraphNodeTest, CopyConstruction)
95TEST(GraphNodeTest, MoveConstruction)
102TEST(GraphNodeTest, CopyAssignment)
110TEST(GraphNodeTest, SelfAssignment)
117TEST(GraphNodeTest, ConstructionFromPointer)
128TEST(GraphArcTest, DefaultConstruction)
134TEST(GraphArcTest, ConstructionWithInfo)
140TEST(GraphArcTest, CopyConstruction)
147TEST(GraphArcTest, CopyAssignment)
155TEST(GraphArcTest, SelfAssignment)
175 EXPECT_EQ(g.get_num_nodes(), 0);
176 EXPECT_EQ(g.get_num_arcs(), 0);
177 EXPECT_FALSE(g.is_digraph());
182 EXPECT_EQ(dg.get_num_nodes(), 0);
183 EXPECT_EQ(dg.get_num_arcs(), 0);
184 EXPECT_TRUE(dg.is_digraph());
189 auto n = g.insert_node(10);
190 EXPECT_NE(n,
nullptr);
191 EXPECT_EQ(n->get_info(), 10);
192 EXPECT_EQ(g.get_num_nodes(), 1);
193 EXPECT_EQ(g.get_num_arcs(), 0);
198 vector<Graph::Node*>
nodes;
199 for (
int i = 0; i < 100; ++i)
200 nodes.push_back(g.insert_node(i));
202 EXPECT_EQ(g.get_num_nodes(), 100);
203 for (
int i = 0; i < 100; ++i)
204 EXPECT_EQ(
nodes[i]->get_info(), i);
209 auto n1 = g.insert_node(1);
210 auto n2 = g.insert_node(2);
211 auto a = g.insert_arc(n1, n2, 1.5);
213 EXPECT_NE(a,
nullptr);
214 EXPECT_EQ(a->get_info(), 1.5);
215 EXPECT_EQ(g.get_num_arcs(), 1);
216 EXPECT_EQ(g.get_src_node(a), n1);
217 EXPECT_EQ(g.get_tgt_node(a), n2);
222 auto n = g.insert_node(1);
223 auto a = g.insert_arc(n, n, 0.0);
225 EXPECT_NE(a,
nullptr);
226 EXPECT_EQ(g.get_num_arcs(), 1);
227 EXPECT_EQ(g.get_src_node(a), n);
228 EXPECT_EQ(g.get_tgt_node(a), n);
242 for (
int i = 0; i < 5; ++i)
249 auto n = g.get_first_node();
251 EXPECT_EQ(g.get_num_nodes(), 4);
256 vector<Graph::Node*>
nodes;
257 for (
auto it = g.get_node_it(); it.has_curr(); it.next())
258 nodes.push_back(it.get_curr());
264 EXPECT_EQ(g.get_num_arcs(), 3);
265 g.remove_node(
nodes[0]);
266 EXPECT_EQ(g.get_num_nodes(), 4);
267 EXPECT_EQ(g.get_num_arcs(), 1);
272 while (g.get_num_nodes() > 0)
273 g.remove_node(g.get_first_node());
275 EXPECT_EQ(g.get_num_nodes(), 0);
276 EXPECT_EQ(g.get_num_arcs(), 0);
304 EXPECT_EQ(g.get_num_arcs(), 2);
305 EXPECT_EQ(g.get_num_nodes(), 3);
313 EXPECT_EQ(g.get_num_arcs(), 0);
314 EXPECT_EQ(g.get_num_nodes(), 3);
319 g.disconnect_arc(a1);
320 EXPECT_EQ(g.get_num_arcs(), 2);
323 EXPECT_EQ(g.get_num_arcs(), 3);
340 for (
int i = 0; i < 5; ++i)
354 for (
auto it = g.get_node_it(); it.has_curr(); it.next())
363 for (
auto it = g.get_arc_it(); it.has_curr(); it.next())
372 for (
auto it = g.get_arc_it(
nodes[0]); it.has_curr(); it.next())
380 auto it = g.get_node_it();
384 EXPECT_TRUE(it.has_curr());
389 auto it = g.get_node_it();
391 EXPECT_TRUE(it.has_curr());
402 return n->get_info() % 20 == 0;
410 return a->get_info() > 0.25;
439 EXPECT_NE(arc,
nullptr);
440 EXPECT_EQ(arc->get_info(), 0.1);
446 EXPECT_EQ(arc,
nullptr);
452 EXPECT_NE(arc,
nullptr);
476 size_t orig_nodes = g.get_num_nodes();
477 size_t orig_arcs = g.get_num_arcs();
479 Graph moved(std::move(g));
482 EXPECT_EQ(g.get_num_nodes(), 0);
483 EXPECT_EQ(g.get_num_arcs(), 0);
488 size_t orig_nodes = g.get_num_nodes();
489 size_t orig_arcs = g.get_num_arcs();
492 moved = std::move(g);
503 size_t g1_nodes = g.get_num_nodes();
508 EXPECT_EQ(g.get_num_nodes(), g2_nodes);
514 size_t orig_nodes = g.get_num_nodes();
515 size_t orig_arcs = g.get_num_arcs();
519 EXPECT_EQ(g.get_num_nodes(), orig_nodes);
520 EXPECT_EQ(g.get_num_arcs(), orig_arcs);
527 EXPECT_EQ(
copy.get_num_nodes(), g.get_num_nodes());
528 EXPECT_EQ(
copy.get_num_arcs(), g.get_num_arcs());
531 auto n =
copy.insert_node(999);
532 copy.insert_arc(n, n, 99.0);
533 EXPECT_NE(
copy.get_num_nodes(), g.get_num_nodes());
534 EXPECT_NE(
copy.get_num_arcs(), g.get_num_arcs());
542 EXPECT_EQ(
copy.get_num_nodes(), g.get_num_nodes());
543 EXPECT_EQ(
copy.get_num_arcs(), g.get_num_arcs());
550 for (
int i = 0; i < 10; ++i)
553 size_t orig_nodes = g.get_num_nodes();
554 size_t orig_arcs = g.get_num_arcs();
576 for (
int i = 0; i < 5; ++i)
590 EXPECT_EQ(path.
size(), 0);
597 EXPECT_EQ(path.
size(), 1);
606 EXPECT_EQ(path.
size(), 2);
615 EXPECT_EQ(path.
size(), 2);
623 EXPECT_EQ(path.
size(), 2);
631 EXPECT_EQ(path.
size(), 2);
638 for (
size_t i = 0; i <
arcs.size(); ++i)
641 EXPECT_EQ(path.
size(), 5);
651 for (
size_t i = 0; i <
arcs.size(); ++i)
688 size_t node_count = 0;
692 EXPECT_EQ(node_count, 3);
701 auto node_list = path.
nodes();
702 EXPECT_EQ(node_list.size(), 3);
711 auto arc_list = path.
arcs();
712 EXPECT_EQ(arc_list.size(), 2);
722 EXPECT_EQ(
copy.size(), path.
size());
731 size_t orig_size = path.
size();
733 EXPECT_EQ(moved.
size(), orig_size);
743 EXPECT_EQ(removed,
nodes[2]);
744 EXPECT_EQ(path.
size(), 2);
764 EXPECT_EQ(removed,
nodes[0]);
765 EXPECT_EQ(path.
size(), 2);
770 auto loop_arc = g.insert_arc(
nodes[4],
nodes[0], 0.5);
798 vector<TestDigraph::Arc*>
arcs;
802 for (
int i = 0; i < 5; ++i)
803 nodes.push_back(
dg.insert_node(i));
816 EXPECT_EQ(path.
size(), 2);
824 EXPECT_EQ(path.
size(), 2);
832 EXPECT_EQ(path.
size(), 2);
840 EXPECT_EQ(path.
size(), 2);
856 EXPECT_THROW(g.get_first_node(), std::range_error);
862 EXPECT_THROW(g.get_first_arc(), std::range_error);
867 auto n1 = g.insert_node(1);
868 auto n2 = g.insert_node(2);
869 auto a = g.insert_arc(n1, n2, 1.0);
872 EXPECT_THROW(path.
append(a), std::domain_error);
877 auto n1 = g.insert_node(1);
878 auto n2 = g.insert_node(2);
879 auto n3 = g.insert_node(3);
880 auto a = g.insert_arc(n2, n3, 1.0);
883 EXPECT_THROW(path.
append(a), std::invalid_argument);
888 auto n1 = g.insert_node(1);
889 auto n2 = g.insert_node(2);
890 auto a = g.insert_arc(n1, n2, 1.0);
893 EXPECT_THROW(path.
insert(a), std::domain_error);
905 vector<TestDigraph::Arc*>
arcs;
909 for (
int i = 0; i < 4; ++i)
910 nodes.push_back(
dg.insert_node(i));
922 size_t out_count_0 = 0;
923 for (
auto it = dg.get_arc_it(
nodes[0]); it.has_curr(); it.next())
924 if (dg.get_src_node(it.get_curr()) ==
nodes[0])
926 EXPECT_EQ(out_count_0, 2);
929 size_t out_count_3 = 0;
930 for (
auto it = dg.get_arc_it(
nodes[3]); it.has_curr(); it.next())
931 if (dg.get_src_node(it.get_curr()) ==
nodes[3])
933 EXPECT_EQ(out_count_3, 0);
939 for (
auto it = dg.get_arc_it(
nodes[0]); it.has_curr(); it.next())
948 EXPECT_EQ(dg.get_src_node(
arcs[0]),
nodes[0]);
949 EXPECT_EQ(dg.get_tgt_node(
arcs[0]),
nodes[1]);
964 for (
int i = 1; i <= 5; ++i)
985 EXPECT_EQ(
sum, 10.0);
990 bool all_positive = forall_node<Graph>(g, [](
Graph::Node *n) {
991 return n->get_info() > 0;
993 EXPECT_TRUE(all_positive);
998 bool all_positive = forall_arc<Graph>(g, [](
Graph::Arc *a) {
999 return a->get_info() > 0;
1001 EXPECT_TRUE(all_positive);
1006 int sum = foldl_nodes<Graph, int>(g, 0, [](
const int & acc,
Graph::Node *n) {
1007 return acc + n->get_info();
1009 EXPECT_EQ(
sum, 150);
1014 double sum = foldl_arcs<Graph, double>(g, 0.0, [](
const double & acc,
Graph::Arc *a) {
1015 return acc + a->get_info();
1017 EXPECT_EQ(
sum, 10.0);
1027 EXPECT_FALSE(path.is_empty());
1028 EXPECT_EQ(path.get_first_node(),
nodes[0]);
1029 EXPECT_EQ(path.get_last_node(),
nodes[4]);
1039 EXPECT_TRUE(path.is_empty());
1056 for (
size_t i = 0; i < NUM_NODES; ++i)
1059 EXPECT_EQ(g.get_num_nodes(), NUM_NODES);
1064 vector<Graph::Node*>
nodes;
1065 for (
size_t i = 0; i < NUM_NODES; ++i)
1066 nodes.push_back(g.insert_node(
static_cast<int>(i)));
1068 std::mt19937
rng(42);
1069 std::uniform_int_distribution<size_t> dist(0, NUM_NODES - 1);
1071 for (
size_t i = 0; i < NUM_ARCS; ++i)
1073 size_t src = dist(
rng);
1074 size_t tgt = dist(
rng);
1075 g.insert_arc(
nodes[src],
nodes[tgt],
static_cast<double>(i));
1078 EXPECT_EQ(g.get_num_arcs(), NUM_ARCS);
1083 vector<Graph::Node*>
nodes;
1084 for (
size_t i = 0; i < 100; ++i)
1085 nodes.push_back(g.insert_node(
static_cast<int>(i)));
1087 EXPECT_EQ(g.get_num_nodes(), 100);
1090 for (
size_t i = 0; i < 50; ++i)
1091 g.remove_node(
nodes[i]);
1093 EXPECT_EQ(g.get_num_nodes(), 50);
1103 return a->get_info() > b->get_info();
1106 auto it = g.get_node_it();
1107 int prev = it.get_curr()->get_info();
1110 while (it.has_curr())
1112 EXPECT_GE(prev, it.get_curr()->get_info());
1113 prev = it.get_curr()->get_info();
1121 return a->get_info() > b->get_info();
1124 auto it = g.get_arc_it();
1125 double prev = it.get_curr()->get_info();
1128 while (it.has_curr())
1130 EXPECT_GE(prev, it.get_curr()->get_info());
1131 prev = it.get_curr()->get_info();
1139 struct Failing_Arc_Cmp
1146 if (++*calls == fail_at)
1147 throw std::runtime_error(
"comparison failed");
1148 return a->get_info() < b->get_info();
1152 struct Nothrow_Arc_Cmp
1156 return a->get_info() < b->get_info();
1166 std::vector<Graph::Arc *>
arcs;
1167 for (
auto it = g.get_arc_it(); it.has_curr(); it.next_ne())
1168 arcs.push_back(it.get_curr());
1169 ASSERT_GE(
arcs.size(), 4u);
1170 std::sort(
arcs.begin(),
arcs.end());
1173 g.sort_arcs(Failing_Arc_Cmp{&calls, 0});
1174 const int total = calls;
1175 for (
int k = 1;
k <= total; ++
k)
1178 EXPECT_THROW(g.sort_arcs(Failing_Arc_Cmp{&calls, k}), std::runtime_error);
1179 std::vector<Graph::Arc *> now;
1180 for (
auto it = g.get_arc_it(); it.has_curr(); it.next_ne())
1181 now.push_back(it.get_curr());
1182 std::sort(now.begin(), now.end());
1183 EXPECT_EQ(now,
arcs) <<
"call " <<
k;
1184 EXPECT_EQ(g.get_num_arcs(),
arcs.size());
1187 g.sort_arcs(Nothrow_Arc_Cmp());
1189 for (
auto it = g.get_arc_it(); it.has_curr(); it.next_ne())
1191 EXPECT_LE(prev, it.get_curr()->get_info());
1192 prev = it.get_curr()->get_info();
1195 Failing_Arc_Cmp failing{&calls, 0};
1196 Nothrow_Arc_Cmp nothrow;
1197 static_assert(not
noexcept(g.sort_arcs(failing)));
1198 static_assert(
noexcept(g.sort_arcs(nothrow)));
1203TEST(GraphCommonTest, GetControlBitsOfANode)
1220 std::unique_ptr<int>
value;
1222 explicit Owned(std::unique_ptr<int> v) noexcept :
value(std::move(v)) {}
1223 Owned(Owned &&) noexcept = default;
1224 Owned & operator=(Owned &&) noexcept = default;
1225 Owned(const Owned & o) : value(o.value ?
std::make_unique<
int>(*o.value) :
nullptr) {}
1226 Owned & operator=(
const Owned & o)
1228 value = o.value ? std::make_unique<int>(*o.value) : nullptr;
1236 static inline bool fail =
false;
1238 Fragile() =
default;
1239 explicit Fragile(
int v) noexcept :
value(v) {}
1243 throw std::runtime_error(
"copy failed");
1245 Fragile & operator=(
const Fragile &) =
default;
1251TEST(GraphCommonTest, EmplaceForwardsItsArguments)
1256 auto arc = g.
emplace_arc(a, b, std::make_unique<int>(3));
1257 EXPECT_EQ(*a->get_info().value, 1);
1258 EXPECT_EQ(*b->get_info().value, 2);
1259 EXPECT_EQ(*arc->get_info().value, 3);
1264TEST(GraphNodeTest, ACopyOfTheDataThatThrowsReachesTheCaller)
1266 static_assert(std::is_nothrow_constructible_v<Graph_Node<int>,
const int &>);
1267 static_assert(std::is_nothrow_constructible_v<Graph_Arc<int>,
const int &>);
1268 static_assert(not std::is_nothrow_constructible_v<Graph_Node<Fragile>,
1270 static_assert(not std::is_nothrow_constructible_v<Graph_Arc<Fragile>,
1274 const Fragile one(1), two(2);
1277 Fragile::fail =
true;
1278 EXPECT_THROW(g.
insert_node(one), std::runtime_error);
1279 EXPECT_THROW(g.
insert_arc(a, b, two), std::runtime_error);
1280 Fragile::fail =
false;
1289 bool operator()(
Graph::Node * p)
const noexcept {
return p->get_info() != 3; }
1294 bool operator()(
Graph::Arc * a)
const noexcept {
return a->get_info() != 1; }
1298 std::vector<double> arc_infos(
const G & g)
1300 std::vector<double> infos;
1302 infos.push_back(it.get_curr()->get_info());
1303 std::sort(infos.begin(), infos.end());
1311TEST(CopyGraphTest, CopiesTheArcsBetweenTheNodesThatItShows)
1325 EXPECT_EQ(arc_infos(tgt), (std::vector<double>{1, 4}));
1326 EXPECT_EQ(mapped_node<Graph>(a)->get_info(), 1);
1327 EXPECT_EQ(mapped_node<Graph>(b)->get_info(), 2);
1328 EXPECT_EQ(mapped_node<Graph>(c),
nullptr);
1332 EXPECT_EQ(arc_infos(tgt), (std::vector<double>{4}));
1336 auto x = dg.insert_node(1);
1337 auto y = dg.insert_node(2);
1338 auto z = dg.insert_node(3);
1339 dg.insert_arc(
y, x, 1);
1340 dg.insert_arc(x, z, 2);
1341 dg.insert_arc(z,
y, 3);
1342 struct Digraph_Not_Three
1344 bool operator()(
TestDigraph::Node * p)
const noexcept {
return p->get_info() != 3; }
1348 Digraph_Not_Three())(dtgt, dg);
1349 ASSERT_EQ(dtgt.get_num_arcs(), 1u);
1350 auto arc = dtgt.get_first_arc();
1351 EXPECT_EQ(dtgt.get_src_node(arc)->get_info(), 2);
1352 EXPECT_EQ(dtgt.get_tgt_node(arc)->get_info(), 1);
1357 template <
class A,
class B>
1358 constexpr bool can_swap =
requires (A & a, B & b) { a.swap(b); };
1363TEST(DigraphSwap, SwapsOnlyWithADigraph)
1365 static_assert(can_swap<TestDigraph, TestDigraph>);
1366 static_assert(not can_swap<TestDigraph, Graph>);
1367 static_assert(can_swap<Graph, Graph>);
1370 auto p = a.insert_node(1);
1371 auto q = a.insert_node(2);
1372 a.insert_arc(p, q, 1.0);
1376 EXPECT_TRUE(a.is_digraph());
1377 EXPECT_TRUE(b.is_digraph());
1378 EXPECT_EQ(a.get_num_nodes(), 1u);
1379 EXPECT_EQ(b.get_num_nodes(), 2u);
1380 EXPECT_EQ(b.get_num_arcs(), 1u);
1381 EXPECT_EQ(b.get_num_arcs(p), 1u);
1382 EXPECT_EQ(b.get_num_arcs(q), 0u);
1385 EXPECT_TRUE(moved.is_digraph());
1386 EXPECT_EQ(moved.get_num_arcs(), 1u);
1404 using G = TypeParam;
1412 G moved(std::move(g));
1419 other = std::move(moved);
1428 undirected.
swap(other);
1460 "Node_Iterator must satisfy BasicGraphIterator");
1462 "Arc_Iterator must satisfy BasicGraphIterator");
1464 "Node_Iterator must satisfy GraphNodeIterator");
1466 "Arc_Iterator must satisfy GraphArcIterator");
1470 "Digraph::Node_Iterator must satisfy BasicGraphIterator");
1472 "Digraph::Arc_Iterator must satisfy BasicGraphIterator");
1474TEST(ConceptsTest, NodeIteratorSatisfiesConcept)
1483 EXPECT_TRUE(it.has_curr());
1484 EXPECT_NE(it.get_curr(),
nullptr);
1486 EXPECT_TRUE(it.has_curr());
1488 EXPECT_FALSE(it.has_curr());
1491TEST(ConceptsTest, ArcIteratorSatisfiesConcept)
1500 EXPECT_TRUE(it.has_curr());
1501 EXPECT_NE(it.get_curr(),
nullptr);
1503 EXPECT_FALSE(it.has_curr());
1506TEST(ConceptsTest, NodeArcIteratorSatisfiesConcept)
1515 EXPECT_TRUE(it.has_curr());
1516 auto* arc = it.get_curr();
1517 EXPECT_NE(arc,
nullptr);
1520 auto* tgt = it.get_tgt_node();
1525template <BasicGraphIterator It>
1534TEST(ConceptsTest, ConceptConstrainedFunction)
1551 InitGoogleTest(&argc, argv);
1552 return RUN_ALL_TESTS();
size_t size_t int32_t value
Bit fields for nodes and arcs used for marking visit state during processing.
Generic directed graph (digraph) wrapper template.
typename BaseGraph::Node Node
void swap(Digraph &g) noexcept
Swap in constant time this digraph with g.
bool has_curr() const noexcept
Return true if the iterator has current item.
void next()
Advances the iterator to the next filtered element.
Arc for graphs implemented with simple adjacency lists.
bool has_curr() const noexcept
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
void swap(List_Graph &g) noexcept
Swap in constant time this with g
virtual void remove_arc(Arc *arc) noexcept
Remove an arc from the graph and free it.
Arc Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Graph class implemented with singly-linked adjacency lists.
Filtered iterator on the nodes of a graph.
Iterator on nodes and arcs of a path.
bool has_current_node() const noexcept
Return true if the iterator has a current node.
bool is_cycle() const
Return true if this is a cycle; throws if path is empty.
void insert(Arc *arc)
Insert an arc as the first of a path.
DynList< Arc * > arcs() const
Return a list with the arcs of a path (order, according to the path)
size_t size() const noexcept
Return the path length in nodes.
bool contains_node(Node *node) const noexcept
Return true if node belongs to the path.
void insert_directed(Node *p)
Insert a node at the beginning of a directed path.
Node * get_first_node() const
Return the first node of path; throws overflow_error if path is empty.
bool is_empty() const noexcept
Return true if the path is empty.
Arc * get_last_arc() const
Return the last arc of a path; throws overflow_error if the path is empty.
bool contains_arc(Arc *arc) const noexcept
Return true if arc belongs to the path.
Node * remove_first_node()
Remove the first node of a path.
Arc * get_first_arc() const
Return the first arc of path; throws overflow_error if path is empty.
void append(Arc *arc)
Append an arc to the path.
void append_directed(Node *p)
Append a node to a directed path.
DynList< Node * > nodes() const
Return a list with the nodes of path (order according to the path)
Node * get_last_node() const
Return the last node of path; throws overflow_error if path is empty.
Node * remove_last_node()
Remove the last node of path.
vector< TestDigraph::Node * > nodes
vector< TestDigraph::Arc * > arcs
vector< TestDigraph::Node * > nodes
vector< TestDigraph::Arc * > arcs
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
size_t num_arcs
data associated to the node. Access it with get_info()
Arc * emplace_arc(Node *src, Node *tgt, Args &&... args)
Insert a new arc in the graph by constructing its associated data in-place with the given args.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
bool is_digraph() const noexcept
Return true if the graph this is directed.
void set_digraph(bool val)
Temporal indication for preventing to other algorithms that an graph must be treated as a directed gr...
Node * emplace_node(Args &&... args)
Insert a new node in the graph by constructing it in-place with the given args.
Bit_Fields & get_control_bits(Node *node) const noexcept
Return a reference to control fields of node
constexpr size_t get_num_arcs() const noexcept
Return the number of arcs of the graph.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
vector< Graph::Node * > nodes
vector< Graph::Node * > nodes
vector< Graph::Arc * > arcs
static constexpr size_t NUM_ARCS
static constexpr size_t NUM_NODES
vector< Graph::Arc * > arcs
vector< Graph::Node * > nodes
Concept for basic graph iterators.
Concept for graph arc iterators.
Concept for graph node iterators.
DynArray< Graph::Node * > nodes
DynArray< Graph::Arc * > arcs
GT::Arc * search_arc(const GT &g, typename GT::Node *src, typename GT::Node *tgt, SA sa=SA()) noexcept(nothrow_arc_filter_v< GT, SA >)
Arc filtered searching given two nodes.
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
GT::Arc * search_directed_arc(const GT &g, typename GT::Node *src, typename GT::Node *tgt, SA sa=SA()) noexcept(nothrow_arc_filter_v< GT, SA >)
Searching of directed arc linking two nodes.
void clear_graph(GT &g)
Clean a graph: all its nodes and arcs are removed and freed.
#define NODE_BITS(p)
Get the control bits of a node.
Path< GT > find_path_depth_first(const GT &g, typename GT::Node *start_node, typename GT::Node *end_node)
Depth-first search of a path between two nodes.
Main namespace for Aleph-w library functions.
constexpr Bit_Column bits(const unsigned n)
Column of n bits without sign: the integers of [0, 2^n - 1].
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Filtered iterator on all the arcs of a graph.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
Node belonging to a graph implemented with a double linked adjacency list.
Iterator on all arcs of a graph.
bool operator()(Graph::Node *n) const noexcept
bool operator()(Graph::Arc *a) const noexcept
Array-based graph implementation.
Generic graph and digraph implementations.
::testing::Types< List_Graph< Graph_Node< int >, Graph_Arc< int > >, List_SGraph< Graph_Snode< int >, Graph_Sarc< int > >, Array_Graph< Graph_Anode< int >, Graph_Aarc< int > > > Undirected_Graph_Kinds
TYPED_TEST(DirectedFlag, GoesWithTheArcs)
TEST_F(GraphBasicTest, DefaultConstructorCreatesEmptyGraph)
size_t count_elements(It it)
TYPED_TEST_SUITE(DirectedFlag, Undirected_Graph_Kinds)
Simple graph implementation with adjacency lists.