Skip to content

Commit c03af61

Browse files
committed
Merge branch 'sb-graph-dev' into sb-graph-tearing
2 parents e0fcb2e + a9ba4ea commit c03af61

208 files changed

Lines changed: 10068 additions & 14525 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3rd-party/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ add_custom_target(
2121
)
2222

2323
add_dependencies(sbgraph 3rd-party-libs)
24+
25+
include(FetchContent)
26+
27+
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
28+
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
29+
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
30+
31+
FetchContent_Declare(
32+
google_benchmark
33+
GIT_REPOSITORY https://github.com/google/benchmark.git
34+
GIT_TAG v1.6.1
35+
)
36+
FetchContent_MakeAvailable(google_benchmark)

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,25 @@ install(
8181
COMPONENT sbgraph
8282
)
8383

84+
# Documentation
85+
set(DOC_PATHS "${CMAKE_CURRENT_SOURCE_DIR}")
86+
string(REPLACE ";" " " DOXYGEN_INPUT_DIR "${DOC_PATHS}")
87+
88+
set(DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
89+
90+
set(DOXYGEN_EXCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
91+
92+
set(DOXYGEN_MAINPAGE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
93+
94+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
95+
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
96+
8497
add_custom_target(doc
8598
COMMAND echo "Generating Project documentation."
99+
COMMAND doxygen "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
100+
#COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/doc
101+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
102+
COMMENT "Generating API documentation with Doxygen"
86103
)
87104

88-
add_dependencies(doc eval-doc sbg-doc util-doc)
89-
90105
set_target_properties(doc PROPERTIES EXCLUDE_FROM_ALL ON)

sbg/SBG.doxyfile renamed to Doxyfile.in

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PROJECT_LOGO =
6868
# entered, it will be relative to the location where doxygen was started. If
6969
# left blank the current directory will be used.
7070

71-
OUTPUT_DIRECTORY = ../doc/sbg
71+
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIR@
7272

7373
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096
7474
# sub-directories (in 2 levels) under the output directory of each output format
@@ -162,7 +162,7 @@ INLINE_INHERITED_MEMB = NO
162162
# shortest path that makes the file name unique will be used
163163
# The default value is: YES.
164164

165-
FULL_PATH_NAMES = YES
165+
FULL_PATH_NAMES = NO
166166

167167
# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
168168
# Stripping is only done if one of the specified strings matches the left-hand
@@ -174,7 +174,7 @@ FULL_PATH_NAMES = YES
174174
# will be relative from the directory where doxygen is started.
175175
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
176176

177-
STRIP_FROM_PATH =
177+
STRIP_FROM_PATH = YES
178178

179179
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
180180
# path mentioned in the documentation of a class, which tells the reader which
@@ -933,10 +933,7 @@ WARN_LOGFILE =
933933
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
934934
# Note: If this tag is empty the current directory is searched.
935935

936-
INPUT = sbg \
937-
sbg/util \
938-
sbg/graph_builders \
939-
.
936+
INPUT = @DOXYGEN_INPUT_DIR@
940937

941938
# This tag can be used to specify the character encoding of the source files
942939
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -976,13 +973,13 @@ INPUT_FILE_ENCODING =
976973
# provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
977974
# *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
978975

979-
FILE_PATTERNS =
976+
FILE_PATTERNS = *.cpp *.hpp *.md
980977

981978
# The RECURSIVE tag can be used to specify whether or not subdirectories should
982979
# be searched for input files as well.
983980
# The default value is: NO.
984981

985-
RECURSIVE = NO
982+
RECURSIVE = YES
986983

987984
# The EXCLUDE tag can be used to specify files and/or directories that should be
988985
# excluded from the INPUT source files. This way you can easily exclude a
@@ -991,7 +988,13 @@ RECURSIVE = NO
991988
# Note that relative paths are relative to the directory from which doxygen is
992989
# run.
993990

994-
EXCLUDE =
991+
EXCLUDE = @DOXYGEN_EXCLUDE_DIR@/3rd-party \
992+
@DOXYGEN_EXCLUDE_DIR@/autom4te.cache \
993+
@DOXYGEN_EXCLUDE_DIR@/build \
994+
@DOXYGEN_EXCLUDE_DIR@/deploy \
995+
@DOXYGEN_EXCLUDE_DIR@/install \
996+
@DOXYGEN_EXCLUDE_DIR@/lib \
997+
@DOXYGEN_EXCLUDE_DIR@/obj
995998

996999
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
9971000
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -1007,7 +1010,9 @@ EXCLUDE_SYMLINKS = NO
10071010
# Note that the wildcards are matched against the file with absolute path, so to
10081011
# exclude all test directories for example use the pattern */test/*
10091012

1010-
EXCLUDE_PATTERNS =
1013+
EXCLUDE_PATTERNS = */build/* \
1014+
*/cmake/* \
1015+
*/.git/*
10111016

10121017
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
10131018
# (namespaces, classes, functions, etc.) that should be excluded from the
@@ -1102,7 +1107,7 @@ FILTER_SOURCE_PATTERNS =
11021107
# (index.html). This can be useful if you have a project on for instance GitHub
11031108
# and want to reuse the introduction page also for the doxygen output.
11041109

1105-
USE_MDFILE_AS_MAINPAGE =
1110+
USE_MDFILE_AS_MAINPAGE = @DOXYGEN_MAINPAGE_DIR@/README.md
11061111

11071112
# The Fortran standard specifies that for fixed formatted Fortran code all
11081113
# characters from position 72 are to be considered as comment. A common
@@ -1137,7 +1142,7 @@ INLINE_SOURCES = NO
11371142
# Fortran comments will always remain visible.
11381143
# The default value is: YES.
11391144

1140-
STRIP_CODE_COMMENTS = YES
1145+
STRIP_CODE_COMMENTS = NO
11411146

11421147
# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
11431148
# entity all documented functions referencing it will be listed.

Makefile.in

Lines changed: 0 additions & 112 deletions
This file was deleted.

algorithms/matching/bfs_matching.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ bool BFSMatching::ExitCondition::full_match() { return full_match_; }
3737

3838
bool BFSMatching::ExitCondition::found_paths() { return found_paths_; }
3939

40+
bool BFSMatching::ExitCondition::isSatisfied()
41+
{
42+
return full_match_ || !found_paths_;
43+
}
44+
45+
// Algorithm -------------------------------------------------------------------
46+
4047
BFSMatching::BFSMatching() : M_(SET_FACT.createSet()), dsbg_()
4148
, direction_(Direction::kForward) {}
4249

@@ -157,31 +164,37 @@ BFSMatching::ExitCondition BFSMatching::step(const Set& right_vertices)
157164
// Calculate exit conditions
158165
Set matchedU = dsbg_.mapD().image(M_);
159166
bool full_match = right_vertices.difference(matchedU).isEmpty();
160-
bool found_paths = !M_.isEmpty();
167+
bool found_paths = !augmenting_edges.isEmpty();
161168

162169
return ExitCondition(full_match, found_paths);
163170
}
164171

165-
bool BFSMatching::ExitCondition::isSatisfied()
172+
void BFSMatching::init(const BipartiteSBG& bsbg)
166173
{
167-
return full_match_ || !found_paths_;
168-
}
174+
PWMap map1 = bsbg.map1().compact();
175+
PWMap map2 = bsbg.map2().compact();
169176

170-
void BFSMatching::init(const SBG& sbg)
171-
{
172-
dsbg_ = DSBG(sbg.V().compact(), sbg.Vmap().compact(), sbg.map2()
173-
, sbg.map1().compact(), sbg.Emap().compact(), sbg.subEmap().compact());
177+
Set Y = bsbg.Y();
178+
PWMap map1_toY = map1.restrict(map1.preImage(Y));
179+
PWMap map2_toY = map2.restrict(map2.preImage(Y));
180+
PWMap mapB = map1_toY.concatenation(map2_toY);
174181

175-
return;
182+
Set X = bsbg.X();
183+
PWMap map1_toX = map1.restrict(map1.preImage(X));
184+
PWMap map2_toX = map2.restrict(map2.preImage(X));
185+
PWMap mapD = map1_toX.concatenation(map2_toX);
186+
187+
dsbg_ = DSBG(bsbg.V().compact(), bsbg.Vmap().compact(), mapB, mapD
188+
, bsbg.Emap().compact(), bsbg.subEmap().compact());
176189
}
177190

178-
MatchData BFSMatching::calculate(const SBG& sbg)
191+
MatchData BFSMatching::calculate(const BipartiteSBG& bsbg)
179192
{
180-
Util::DEBUG_LOG << "Matching sbg: \n" << sbg << "\n\n";
193+
Util::DEBUG_LOG << "Matching bsbg: \n" << bsbg << "\n\n";
181194

182195
auto begin = std::chrono::high_resolution_clock::now();
183-
init(sbg);
184-
Set right_vertices = dsbg_.mapB().image();
196+
init(bsbg);
197+
Set right_vertices = bsbg.Y();
185198

186199
ExitCondition exit_cond(false, false);
187200
do {
@@ -192,7 +205,7 @@ MatchData BFSMatching::calculate(const SBG& sbg)
192205
end - begin);
193206
Util::SBG_LOG << "Total matching exec time: " << total.count() << " [μs]\n";
194207

195-
MatchData result(sbg, M_.compact(), exit_cond.full_match());
208+
MatchData result(bsbg, M_.compact(), exit_cond.full_match());
196209
Util::SBG_LOG << result << "\n\n";
197210

198211
return result;

algorithms/matching/bfs_matching.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "algorithms/matching/bfs_paths.hpp"
2828
#include "algorithms/matching/matching.hpp"
29+
#include "sbg/directed_sbg.hpp"
2930

3031
namespace SBG {
3132

@@ -50,7 +51,7 @@ class BFSMatching : public MatchStrategy {
5051
public:
5152
BFSMatching();
5253

53-
MatchData calculate(const SBG& sbg) override;
54+
MatchData calculate(const BipartiteSBG& bsbg) override;
5455

5556
private:
5657
/**
@@ -72,9 +73,9 @@ class BFSMatching : public MatchStrategy {
7273
};
7374

7475
/**
75-
* @brief Initializes data members determined by the input SBG.
76+
* @brief Initializes data members determined by the input bipartite SBG.
7677
*/
77-
void init(const SBG& sbg);
78+
void init(const BipartiteSBG& bsbg);
7879

7980
/**
8081
* @brief Performs an iteration of the algorithm. It looks up alternating
@@ -117,7 +118,7 @@ class BFSMatching : public MatchStrategy {
117118
*/
118119
Set edgesInPaths(const PWMap& smap, const Set& E) const;
119120

120-
DSBG dsbg_; ///< Input DSBG
121+
DSBG dsbg_; ///< Directed graph according to matching
121122
Set M_; ///< Matched edges
122123
Direction direction_;
123124
};

algorithms/matching/matching.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ std::ostream& operator<<(std::ostream& out, const Direction& direction)
4444
return out;
4545
}
4646

47-
MatchData::MatchData(SBG sbg, Set M, bool full_match)
48-
: sbg_(sbg), M_(M), full_match_(full_match) {}
47+
MatchData::MatchData(BipartiteSBG bsbg, Set M, bool full_match)
48+
: bsbg_(bsbg), M_(M), full_match_(full_match) {}
4949

50-
const SBG& MatchData::sbg() const { return sbg_; }
50+
const BipartiteSBG& MatchData::bsbg() const { return bsbg_; }
5151
const Set& MatchData::M() const { return M_; }
5252
const bool& MatchData::full_match() const { return full_match_; }
5353

@@ -74,9 +74,9 @@ MatchStrategy::MatchStrategy() {}
7474

7575
Matching::Matching(MatchStratPtr strat) : strategy_(std::move(strat)) {}
7676

77-
MatchData Matching::calculate(const SBG& sbg)
77+
MatchData Matching::calculate(const BipartiteSBG& bsbg)
7878
{
79-
return strategy_->calculate(sbg);
79+
return strategy_->calculate(bsbg);
8080
}
8181

8282
} // namespace LIB

0 commit comments

Comments
 (0)