6#include <gtest/gtest.h>
55 ASSERT_NE(n,
nullptr);
56 EXPECT_EQ(n->get_info(), 42);
58 EXPECT_EQ(g.get_num_nodes(), 1u);
69 ASSERT_NE(n1,
nullptr);
70 ASSERT_NE(n2,
nullptr);
71 ASSERT_NE(n3,
nullptr);
89 EXPECT_EQ(found1, n1);
90 EXPECT_EQ(found2, n2);
103 EXPECT_EQ(found1, n1);
104 EXPECT_EQ(found2, n2);
116 EXPECT_EQ(found,
nullptr);
125 EXPECT_EQ(found,
nullptr);
141 ASSERT_NE(arc,
nullptr);
143 EXPECT_EQ(g.get_num_arcs(), 1u);
155 ASSERT_NE(arc,
nullptr);
156 EXPECT_EQ(arc->get_info(), 999);
189 EXPECT_EQ(found, arc);
204 EXPECT_EQ(found,
nullptr);
216 EXPECT_EQ(found,
nullptr);
233 EXPECT_EQ(g.get_num_nodes(), 1u);
236 EXPECT_EQ(found,
nullptr);
286 EXPECT_EQ(g.get_num_arcs(), 0u);
289 EXPECT_EQ(found,
nullptr);
320 const size_t n = 1000;
322 for (
size_t i = 0; i < n; ++i)
330 for (
size_t i = 0; i < n; i += 100)
333 EXPECT_NE(found,
nullptr);
341 const size_t n = 100;
342 std::vector<Node*>
nodes;
344 for (
size_t i = 0; i < n; ++i)
350 for (
size_t i = 0; i < n - 1; ++i)
363 std::vector<Node*>
nodes;
365 for (
size_t i = 0; i < n; ++i)
370 for (
size_t i = 0; i < n; ++i)
372 for (
size_t j = i + 1; j < n; ++j)
394 EXPECT_EQ(found, n1);
399 EXPECT_EQ(found,
nullptr);
411 ASSERT_NE(n2,
nullptr);
431 EXPECT_EQ(n1->get_info(), 42);
432 EXPECT_EQ(n2->get_info(), 42);
467 ASSERT_NE(arc,
nullptr);
468 EXPECT_EQ(g.get_src_node(arc), n);
469 EXPECT_EQ(g.get_tgt_node(arc), n);
WeightedDigraph::Node Node
Builds node and arc indices for fast lookup and retrieval.
size_t get_num_arcs() const
Returns the number of arcs the index contains.
GT_Node * search_node(GT_Node *p)
Looks up a node in the index.
GT_Arc * search_arc(GT_Node *src, GT_Node *tgt)
Looks up an arc in the index given its two nodes.
void remove_node(GT_Node *p)
Removes node p from the graph and from the index.
size_t get_num_nodes() const
Returns the number of nodes the index contains.
GT_Node * insert_node(const GT_Node_Type &info)
Creates a new node and inserts it into the graph and the index.
void remove_arc(GT_Arc *a)
Removes arc a from the graph and from the index.
GT_Arc * insert_arc(GT_Node *src, GT_Node *tgt, const GT_Arc_Type &info=GT_Arc_Type())
Creates a new arc between two nodes and inserts it into the graph and the index.
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)
Minimal std::expected-style result type for C++20.
DynArray< Graph::Node * > nodes
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
TEST_F(IndexGraphTest, Construction)
Main namespace for Aleph-w library functions.
bool are_equal(const GT &g1, const GT &g2)
Fast graph comparison.
Arc of graph implemented with double-linked adjacency lists.
Generic graph and digraph implementations.
Graph indexing utilities for O(log n) node/arc lookup.