Skip to content

Commit

Permalink
Merge pull request #1220 from NachiaVivias/edge-color-bipartite-case
Browse files Browse the repository at this point in the history
[テストケース] Edge Coloring of Bipartite Graph , 二部マッチングアルゴリズム向けのケース
  • Loading branch information
maspypy authored Aug 2, 2024
2 parents e7a5670 + e22ad55 commit 5847039
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
64 changes: 64 additions & 0 deletions graph/bipartite_edge_coloring/gen/from_issue1124.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <vector>
#include <iostream>
#include <algorithm>

#include "random.h"

using namespace std;

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int B = 11;
vector<pair<int, int> > edges;

// first matching
for (int i = 0; i <= B; i++) {
for (int j = 0; j < (1 << B); j++) {
edges.push_back({(i << B) + j, (i << B) + j});
}
}

for (int i = 0; i < B; i++) {
for (int j = 0; j < (1 << B); j++) {
edges.push_back({((i + 1) << B) + j, (i << B) + j});
edges.push_back({((i + 1) << B) + (j ^ (1 << i)), (i << B) + j});
}
}
for (int i = 0; i < (1 << B); i++) {
edges.push_back({((B + 1) << B) + i, (B << B) + i});
edges.push_back({((B + 1) << B) + i, (B << B) + i});
}
for (int i = 0; i < (1 << B); i++) {
edges.push_back({i, ((B + 1) << B) + i});
edges.push_back({i, ((B + 1) << B) + i});
}
for (int j = 0; j < (1 << B) / 3 * 3; j++) {
edges.push_back({((B + 1) << B) + j, ((B + 2) << B) + j / 3});
edges.push_back({((B + 2) << B) + j / 3, ((B + 1) << B) + j});
}
for (int j = (1 << B) / 3 * 3; j < (1 << B); j++) {
edges.push_back({((B + 1) << B) + j, ((B + 1) << B) + j});
}

int l = ((B + 2) << B) + (1 << B) / 3;
int r = ((B + 2) << B) + (1 << B) / 3;
int m = edges.size();

if (seed % 3 == 0) {
// shuffle
vector<int> new_idx_L(l), new_idx_R(r);
for (int i = 0; i < l; ++i) new_idx_L[i] = i;
for (int i = 0; i < r; ++i) new_idx_R[i] = i;
gen.shuffle(edges.begin(), edges.end());
gen.shuffle(new_idx_L.begin(), new_idx_L.end());
gen.shuffle(new_idx_R.begin(), new_idx_R.end());
for (auto& [a, b]: edges) a = new_idx_L[a], b = new_idx_R[b];
}
if (seed % 3 == 2) { reverse(edges.begin(), edges.end()); }

printf("%d %d %d\n", l, r, m);
for (auto edge: edges) { printf("%d %d\n", edge.first, edge.second); }
return 0;
}
54 changes: 54 additions & 0 deletions graph/bipartite_edge_coloring/gen/large_cycle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <vector>
#include <iostream>
#include <algorithm>

#include "random.h"
#include "../params.h"

using namespace std;

/*
3-regular bipartite graph,
like a benzene
______
// \\
// \\
\ /
\ ____ /
------
*/

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int h = min(M_MAX / 6, min(L_MAX, R_MAX)) * 2;
// int m = h * 3;

vector<pair<int,int>> edges;
for(int i=0; i<h; i++){
edges.push_back({ i, i });
edges.push_back({ i, i });
edges.push_back({ i, (i + 1) % h });
}

if (seed % 2 == 1) {
// shuffle
int l = h;
int r = h;
vector<int> new_idx_L(l), new_idx_R(r);
for (int i = 0; i < l; ++i) new_idx_L[i] = i;
for (int i = 0; i < r; ++i) new_idx_R[i] = i;
gen.shuffle(edges.begin(), edges.end());
gen.shuffle(new_idx_L.begin(), new_idx_L.end());
gen.shuffle(new_idx_R.begin(), new_idx_R.end());
for (auto& [a, b]: edges) a = new_idx_L[a], b = new_idx_R[b];
}

int m = int(edges.size());
printf("%d %d %d\n", h, h, m);
for (auto edge: edges) { printf("%d %d\n", edge.first, edge.second); }
return 0;
}
10 changes: 10 additions & 0 deletions graph/bipartite_edge_coloring/hash.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"example_00.in": "8e14807ee203e49dde929bb92a04f1536a744b10e6dfd233b68fc4f19db57a71",
"example_00.out": "532e524e72416b547880966effea56e1d8b48aa25fb66e94995b4a97caf72fbb",
"from_issue1124_00.in": "0ddfa4a206f161964ce84a1d419bcfbacb2479ad2f1778a52c91b00ae3a70e22",
"from_issue1124_00.out": "d109c4aaa305e6aaab6df5fc6c6e03a59347690de52d69143140d7ee53bb5d83",
"from_issue1124_01.in": "e38cfb089dca80081b27b84c5309caf17f3ed01c9e63106d4b2ad419bb3150f6",
"from_issue1124_01.out": "c8d62bb125f126ed54b7498c1069e3d69ce34d7859855d4b31be2dc7bb1d0d0c",
"from_issue1124_02.in": "cdf2f5ffeee5eedd4e2c3e223f96a15472d903736d741c426f1e0fe12a189463",
"from_issue1124_02.out": "90e7b3ab81bb8690c0875af3db578abfa5aa952c7b6915062c3921a24c46c688",
"large_cycle_00.in": "cfecfc7b319f2bf63c0de36e083d54b669c03b333197e706ea67e0ca389d7301",
"large_cycle_00.out": "c75a34af58f031baa2289f2de4549f7a76a26c19b11a822cda17c999fd6a6873",
"large_cycle_01.in": "92dd4abfeeb5abb737ebd6ca81001b156bd7fd76f00a33b1653b9be6d037f107",
"large_cycle_01.out": "3cfd9dacda36dd2b878e0741ffd20a2fcf52a2f0ed81444ad0a7021de2580af0",
"line_00.in": "851430b3e13b07d3c1832fa066480a887dda0250494007e34dfb36fef35b6020",
"line_00.out": "cdb04bdf43f74674df392ef5d798f9014ff0b7d9074899ebe7d770f7ba612e4e",
"line_01.in": "851430b3e13b07d3c1832fa066480a887dda0250494007e34dfb36fef35b6020",
Expand Down
6 changes: 6 additions & 0 deletions graph/bipartite_edge_coloring/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/393"
[[tests]]
name = "example.in"
number = 1
[[tests]]
name = "from_issue1124.cpp"
number = 3
[[tests]]
name = "large_cycle.cpp"
number = 2
[[tests]]
name = "random.cpp"
number = 10
Expand Down

0 comments on commit 5847039

Please sign in to comment.