38#include <gtest/gtest.h>
79 return g.insert_node(val);
84 return g.insert_arc(src, tgt, 1);
188 EXPECT_EQ(g.get_num_arcs(n1), 3) <<
"n1 should have degree 3";
189 EXPECT_EQ(g.get_num_arcs(n2), 3) <<
"n2 should have degree 3";
190 EXPECT_EQ(g.get_num_arcs(n3), 3) <<
"n3 should have degree 3";
191 EXPECT_EQ(g.get_num_arcs(n4), 3) <<
"n4 should have degree 3";
616 EXPECT_EQ(result.type, Eulerian_Type::Cycle);
621 for (
auto arc : result.path)
642 EXPECT_EQ(result.type, Eulerian_Type::Path);
664 EXPECT_EQ(result.type, Eulerian_Type::None);
690 EXPECT_EQ(result.type, Eulerian_Type::Cycle);
728 EXPECT_EQ(result.type, Eulerian_Type::None);
745 EXPECT_EQ(result.type, Eulerian_Type::Cycle);
761 EXPECT_EQ(result.type, Eulerian_Type::Path);
785 EXPECT_EQ(result.type, Eulerian_Type::Cycle);
795 ::testing::InitGoogleTest(&
argc,
argv);
Generic directed graph (digraph) wrapper template.
typename BaseGraph::Arc Arc
typename BaseGraph::Node Node
T & insert(const T &item)
Insert a new item by copy.
Finds and constructs an Eulerian path or cycle using Hierholzer's algorithm.
size_t size() const noexcept
Count the number of elements of the list.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Graph_Node< int > Node
The graph type.
Graph_Arc< int > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Tests whether a graph or digraph is Eulerian.
Arc * add_arc(Node *src, Node *tgt)
Arc * add_edge(Node *n1, Node *n2)
Eulerian graph detection and path/cycle finding.
TEST_F(EulerianUndirectedTest, EmptyGraph)
void add_edge(GT &g, const string &src, const string &tgt, int weight=1)
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Arc of graph implemented with double-linked adjacency lists.
TestDigraph::Arc * add_arc(TestDigraph &g, TestDigraph::Node *src, TestDigraph::Node *tgt, int value=0)
TestDigraph::Node * add_node(TestDigraph &g, int value)
void test(unsigned long n, gsl_rng *r)
Generic graph and digraph implementations.