36# include <gtest/gtest.h>
72 attrs.
append(
Attr{
"info", std::to_string(p->get_info())});
80 for (
size_t i = 0; i < attrs.
size(); ++i)
81 if (attrs(i).name ==
"info")
82 p->get_info() = std::stoi(attrs(i).
value);
90 attrs.
append(
Attr{
"w", std::to_string(a->get_info())});
98 for (
size_t i = 0; i < attrs.
size(); ++i)
99 if (attrs(i).name ==
"w")
100 a->get_info() = std::stoi(attrs(i).
value);
111 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
112 items.
append(
"n" + std::to_string(it.get_curr()->get_info()));
113 for (
auto it = g.
get_arc_it(); it.has_curr(); it.next_ne())
115 auto * a = it.get_curr();
118 std::to_string(a->get_info()));
127 for (
int i = 0; i < 5; ++i)
140 class XmlGraphTest :
public ::testing::Test
145 void SetUp()
override
147 prefix = std::string(
"aleph_xml_graph_test_") +
148 ::testing::UnitTest::GetInstance()->current_test_info()->name() +
149 "_" + std::to_string(std::random_device{}()) +
"_";
152 std::string
file(
const std::string & name)
const
154 return (std::filesystem::temp_directory_path() / (prefix + name)).string();
157 void TearDown()
override
159 for (
const char * name : {
"owned.xml",
"shared.xml",
"copy.xml",
"names.xml"})
160 std::remove(
file(name).c_str());
215 struct NonCopyableWriter
218 NonCopyableWriter() =
default;
219 NonCopyableWriter(
const NonCopyableWriter &) =
delete;
220 NonCopyableWriter(NonCopyableWriter &&) =
default;
225 attrs.
append(
Attr{
"info", std::to_string(p->get_info())});
243 NonCopyableWriter nw;
270 xml.set_graph_name(
"network");
271 xml.set_node_name(
"vertex");
272 xml.set_arc_name(
"edge");
High-level sorting functions for Aleph containers.
WeightedDigraph::Node Node
size_t size_t int32_t value
size_t size() const noexcept
Return the current dimension of array.
T & append()
Allocate a new entry to the end of array.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Graph implemented with double-linked adjacency lists.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
_Graph_Node Node
The graph type.
_Graph_Arc Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Class that writes and reads a graph (in a very elementary way) as XML.
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
DynList< Node * > prefix(Node *root)
Return a list with preorder traversal of a tree.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
and
Check uniqueness with explicit hash + equality functors.
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
Arc of graph implemented with double-linked adjacency lists.
XML serialization for graphs.
TEST_F(XmlGraphTest, RoundTripWithOwnedFunctors)