souffle
2.0.2-371-g6315b36
ram
tests
max_matching_test.cpp
Go to the documentation of this file.
1
/*
2
* Souffle - A Datalog Compiler
3
* Copyright (c) 2020 The Souffle Developers. All rights reserved
4
* Licensed under the Universal Permissive License v 1.0 as shown at:
5
* - https://opensource.org/licenses/UPL
6
* - <souffle root>/licenses/SOUFFLE-UPL.txt
7
*/
8
9
/************************************************************************
10
*
11
* @file max_matching_test.cpp
12
*
13
* Test cases for the computation of maximum matching.
14
*
15
***********************************************************************/
16
17
#include "
tests/test.h
"
18
19
#include "
ram/analysis/Index.h
"
20
#include <set>
21
#include <string>
22
23
namespace
souffle::ram::analysis::test
{
24
25
class
TestMaxMatching
:
public
MaxMatching
{
26
public
:
27
TestMaxMatching
() :
MaxMatching
() {}
28
};
29
30
TEST
(Matching, StaticTest_1) {
31
MaxMatching
match;
32
33
match.
addEdge
(1, 7);
34
match.
addEdge
(1, 8);
35
match.
addEdge
(3, 7);
36
match.
addEdge
(3, 10);
37
match.
addEdge
(4, 9);
38
match.
addEdge
(5, 9);
39
match.
addEdge
(5, 10);
40
match.
addEdge
(6, 12);
41
42
match.
solve
();
43
int
num = match.
getNumMatchings
();
44
45
EXPECT_EQ
(num, 5);
46
}
47
48
TEST
(Matching, StaticTest_2) {
49
MaxMatching
match;
50
51
match.
addEdge
(1, 6);
52
match.
addEdge
(1, 7);
53
match.
addEdge
(2, 6);
54
match.
addEdge
(2, 10);
55
match.
addEdge
(3, 8);
56
match.
addEdge
(3, 9);
57
match.
addEdge
(4, 6);
58
match.
addEdge
(4, 10);
59
match.
addEdge
(5, 7);
60
match.
addEdge
(5, 9);
61
62
match.
solve
();
63
int
num = match.
getNumMatchings
();
64
65
EXPECT_EQ
(num, 5);
66
}
67
68
}
// namespace souffle::ram::analysis::test
souffle::ram::analysis::MaxMatching::solve
const Matchings & solve()
@Brief solve the maximum matching problem
Definition:
Index.cpp:248
Index.h
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition:
test.h:191
souffle::ram::analysis::test::TestMaxMatching
Definition:
max_matching_test.cpp:31
souffle::ram::analysis::test
Definition:
max_matching_test.cpp:23
souffle::ram::analysis::MaxMatching
Definition:
Index.h:112
souffle::ram::analysis::test::TEST
TEST(Matching, StaticTest_1)
Definition:
max_matching_test.cpp:36
test.h
souffle::ram::analysis::test::TestMaxMatching::TestMaxMatching
TestMaxMatching()
Definition:
max_matching_test.cpp:39
souffle::ram::analysis::MaxMatching::addEdge
void addEdge(Node u, Node v)
@Brief add an edge to the bi-partite graph
Definition:
Index.cpp:170
souffle::ram::analysis::MaxMatching::getNumMatchings
int getNumMatchings() const
@Brief get number of matches in the solution
Definition:
Index.h:142
Generated by
1.8.17