38#include <gtest/gtest.h>
98 n0 =
g.insert_node(0);
99 n1 =
g.insert_node(1);
100 n2 =
g.insert_node(2);
102 g.insert_arc(
n0,
n1, 10);
103 g.insert_arc(
n1,
n2, 20);
104 g.insert_arc(
n2,
n1, 30);
272 std::set<int> values;
273 for (
size_t i = 0; i < 4; ++i)
274 values.insert(mat(
static_cast<long>(i)));
289 for (
size_t i = 0; i < 4; ++i)
291 if (mat(
static_cast<long>(i)) == 0)
idx0 = i;
292 if (mat(
static_cast<long>(i)) == 1)
idx1 = i;
308 for (
size_t i = 0; i < 4; ++i)
310 if (mat(
static_cast<long>(i)) == 0)
idx0 = i;
311 if (mat(
static_cast<long>(i)) == 2)
idx2 = i;
432 entry = arc->get_info();
442 long i0 = mat(n0),
i1 = mat(n1),
i2 = mat(n2);
530 long i0 = mat(n0),
i1 = mat(n1),
i2 = mat(n2),
i3 = mat(n3);
550 long i0 = mat(n0),
i2 = mat(n2);
565 EXPECT_EQ(
static_cast<int>(mat(n0, n1)), 1);
566 EXPECT_EQ(
static_cast<int>(mat(n0, n2)), 0);
618 long i0 = mat(n0),
i1 = mat(n1),
i2 = mat(n2);
635 long i0 = mat(n0),
i1 = mat(n1),
i2 = mat(n2);
674 for (
long i = 0; i < 3; ++i)
675 for (
long j = 0; j < 3; ++j)
683 for (
int i = 0; i < 4; ++i)
687 for (
int i = 0; i < 4; ++i)
688 for (
int j = i + 1; j < 4; ++j)
695 for (
long i = 0; i < 4; ++i)
696 for (
long j = 0; j < 4; ++j)
704 auto* n = g.insert_node(0);
705 g.insert_arc(n, n, 99);
710 EXPECT_EQ(mat(idx, idx)->get_info(), 99);
719 constexpr int N = 100;
722 std::vector<IntDigraph::Node*>
nodes(
N);
724 for (
int i = 0; i <
N; ++i)
725 nodes[i] = g.insert_node(i);
728 for (
int i = 0; i <
N - 1; ++i)
738 for (
int i = 0; i <
N - 1; ++i)
748 ::testing::InitGoogleTest(&
argc,
argv);
Auxiliary adjacency matrix with custom entry type.
void operate_all_arcs_list_graph()
Apply operation to all arcs from the graph.
void set_null_value(const Entry_Type &null) noexcept
Set the null value.
size_t get_num_nodes() const noexcept
Get number of nodes (matrix dimension)
void operate_all_arcs_matrix()
Apply operation to all matrix entries.
const Entry_Type & null_value() const noexcept
Get the null value.
GT & get_list_graph() noexcept
Get reference to underlying graph.
Bit matrix for graph connectivity.
size_t get_num_nodes() const noexcept
Get number of nodes (matrix dimension)
GT * get_list_graph() noexcept
Get pointer to associated graph (nullptr if none)
void set_list_graph(GT &g)
Associate with a graph.
Generic directed graph (digraph) wrapper template.
typename BaseGraph::Arc Arc
typename BaseGraph::Node Node
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.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Adjacency matrix mapped to an adjacency list graph.
GT & get_list_graph() noexcept
Get reference to underlying graph.
size_t get_num_nodes() const noexcept
Get number of nodes (matrix dimension)
Adjacency matrix storing copies of graph attributes.
const Arc_Type & null_value() const noexcept
Get the null value indicating no arc.
size_t get_num_nodes() const noexcept
Get number of nodes (matrix dimension)
DynArray< Graph::Node * > nodes
long index_array(long i, long j, long n) noexcept
Convert 2D matrix indices to 1D array index.
long checked_index_array(long i, long j, long n)
Validate and convert indices to linear index.
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.
void operator()(Ady_Mat< IntDigraph, int > &mat, IntDigraph::Node *src, IntDigraph::Node *tgt, long i, long j, int &entry)
void operator()(Ady_Mat< IntDigraph, int > &mat, IntDigraph::Arc *arc, long i, long j, int &entry)
Generic graph and digraph implementations.
Adjacency matrix representations for graphs.
TEST_F(MapMatrixGraphTest, Constructor)