Ocean
Loading...
Searching...
No Matches
TestClusteringSpectral.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTMATH_TEST_CLUSTERING_SPECTRAL_H
9#define META_OCEAN_TEST_TESTMATH_TEST_CLUSTERING_SPECTRAL_H
10
12
14
16
17#include "ocean/math/Matrix.h"
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestMath
26{
27
28/**
29 * This class implements a test for ClusteringSpectral.
30 * @ingroup testmath
31 */
32class OCEAN_TEST_MATH_EXPORT TestClusteringSpectral
33{
34 public:
35
36 /**
37 * Executes all tests.
38 * @param testDuration Number of seconds for each test
39 * @param selector The test selector
40 * @return True, if succeeded
41 */
42 static bool test(const double testDuration, const TestSelector& selector);
43
44 /**
45 * Tests the clustering of a graph which is composed of well separated groups.
46 * @param testDuration Number of seconds for each test, with range (0, infinity)
47 * @return True, if succeeded
48 */
49 static bool testSeparatedGroups(const double testDuration);
50
51 protected:
52
53 /**
54 * Creates the affinity matrix of a graph in which the elements of the same group are strongly connected and the elements of different groups are almost unconnected.
55 * @param groupIndices The group to which each element belongs, at least one element
56 * @param numberGroups The number of groups, with range [1, infinity)
57 * @param randomGenerator The random generator to be used
58 * @return The resulting symmetric affinity matrix with non-negative elements
59 */
60 static Matrix createAffinityMatrix(const Indices32& groupIndices, const unsigned int numberGroups, RandomGenerator& randomGenerator);
61
62 /**
63 * Returns whether the clusters are exactly the groups of the elements, in any order.
64 * @param clusters The clusters to be checked, each holding the indices of its elements
65 * @param groupIndices The group to which each element belongs, at least one element
66 * @param numberGroups The number of groups, with range [1, infinity)
67 * @return True, if so
68 */
69 static bool clustersMatchGroups(const std::vector<Indices32>& clusters, const Indices32& groupIndices, const unsigned int numberGroups);
70};
71
72}
73
74}
75
76}
77
78#endif // META_OCEAN_TEST_TESTMATH_TEST_CLUSTERING_SPECTRAL_H
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements a test for ClusteringSpectral.
Definition TestClusteringSpectral.h:33
static bool test(const double testDuration, const TestSelector &selector)
Executes all tests.
static bool clustersMatchGroups(const std::vector< Indices32 > &clusters, const Indices32 &groupIndices, const unsigned int numberGroups)
Returns whether the clusters are exactly the groups of the elements, in any order.
static bool testSeparatedGroups(const double testDuration)
Tests the clustering of a graph which is composed of well separated groups.
static Matrix createAffinityMatrix(const Indices32 &groupIndices, const unsigned int numberGroups, RandomGenerator &randomGenerator)
Creates the affinity matrix of a graph in which the elements of the same group are strongly connected...
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
The namespace covering the entire Ocean framework.
Definition Accessor.h:15