49#include <gtest/gtest.h>
73 vector<Graph::Node *> left(m);
74 for (
size_t i = 0; i < m; ++i)
78 vector<Graph::Node *> right(n);
79 for (
size_t j = 0; j < n; ++j)
83 for (
size_t i = 0; i < m; ++i)
84 for (
size_t j = 0; j < n; ++j)
101 vector<Graph::Node *>
nodes(n);
102 for (
size_t i = 0; i < n; ++i)
105 for (
size_t i = 0; i + 1 < n; ++i)
122 vector<Graph::Node *>
nodes(n);
123 for (
size_t i = 0; i < n; ++i)
126 for (
size_t i = 0; i < n; ++i)
142 for (
size_t i = 0; i < n; ++i)
204 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne())
207 for (
auto it = r.
get_it(); it.has_curr(); it.next_ne())
211 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne())
218 auto * arc = it.get_curr();
250 auto * arc = it.get_curr();
1035 vector<Graph::Node *> l1(3),
r1(3);
1036 for (
int i = 0; i < 3; ++i)
1038 for (
int i = 0; i < 3; ++i)
1040 for (
int i = 0; i < 3; ++i)
1041 for (
int j = 0; j < 3; ++j)
1045 vector<Graph::Node *> l2(2), r2(2);
1046 for (
int i = 0; i < 2; ++i)
1048 for (
int i = 0; i < 2; ++i)
1050 for (
int i = 0; i < 2; ++i)
1051 for (
int j = 0; j < 2; ++j)
1167 ::testing::InitGoogleTest(&
argc,
argv);
Graph create_complete_bipartite(size_t m, size_t n)
Creates a complete bipartite graph K_{m,n} Left partition: nodes 0..m-1 Right partition: nodes m....
Graph create_path_graph(size_t n)
Creates a path graph with n nodes: 0–1–2–...–n-1 Path graphs are always bipartite.
Graph create_disconnected_bipartite()
Creates two disconnected components.
Graph create_triangle()
Creates a triangle (K_3) - the simplest non-bipartite graph.
bool verify_bipartition(const Graph &g, const DynDlist< Graph::Node * > &l, const DynDlist< Graph::Node * > &r)
Verifies that a bipartition is valid:
Graph create_cycle_graph(size_t n)
Creates a cycle graph with n nodes: 0–1–2–...–n-1–0 Even cycles are bipartite, odd cycles are not.
bool verify_matching(const Graph &g, const DynDlist< Graph::Arc * > &matching)
Verifies that a matching is valid:
Graph create_star_graph(size_t n)
Creates a star graph with center and n leaves Star graphs are always bipartite.
Class that takes a bipartite graph and computes the partition sets.
Class for computing the maximum cardinality matching of a bipartite graph.
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
Dynamic doubly linked list with O(1) size and bidirectional access.
const size_t & size() const noexcept
Return the number of elements (constant time)
T & insert(const T &item)
Insert a new item by copy.
Dynamic set implemented using AVL binary search trees of type Avl_Tree<Key>.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
constexpr bool is_empty() const noexcept
Return true if list is empty.
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)
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Filtered iterator on all the arcs of a graph.
Arc of graph implemented with double-linked adjacency lists.
Bipartite graph detection and 2-coloring.
Generic graph and digraph implementations.