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
Finds and constructs an Eulerian path or cycle using Hierholzer's algorithm.
DynList< typename GT::Node * > find_node_sequence(GT &g)
Get the node sequence of the Eulerian path/cycle.
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.
A non-degenerate triangle defined by three points.
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.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
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)
Generic graph and digraph implementations.