Skip to content

Commit c59fe8b

Browse files
committed
TT_TT
1 parent db6721f commit c59fe8b

25 files changed

+2105
-33
lines changed

action.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const RestrictedNaturalAction::domain_type& RestrictedNaturalAction::domain() co
3434
RestrictedNaturalAction::RestrictedNaturalAction( Group G, const RestrictedNaturalAction::domain_type& S ) : PointAction<RestrictedNaturalAction,RestrictedNaturalAction::value_type,RestrictedNaturalAction::domain_type>( G ), Omega( S ) {
3535
}
3636

37+
RestrictedNaturalAction::RestrictedNaturalAction( Group G, RestrictedNaturalAction::domain_type&& S ) : PointAction<RestrictedNaturalAction,RestrictedNaturalAction::value_type,RestrictedNaturalAction::domain_type>( G ), Omega( std::move( S ) ) {
38+
}
39+
40+
3741
// ----------------------------------------------------------------
3842

3943
/*std::vector<std::vector<NaturalAction::value_type>> NaturalAction::calculateOrbits() const {
@@ -116,7 +120,11 @@ const RestrictedNaturalSetAction::domain_type& RestrictedNaturalSetAction::domai
116120
return Omega;
117121
}
118122

119-
RestrictedNaturalSetAction::RestrictedNaturalSetAction( Group G, domain_type D ) : SetAction<RestrictedNaturalSetAction,RestrictedNaturalSetAction::value_type,RestrictedNaturalSetAction::domain_type>( G, D[0].size() ) {
123+
RestrictedNaturalSetAction::RestrictedNaturalSetAction( Group G, const domain_type& D ) : SetAction<RestrictedNaturalSetAction,RestrictedNaturalSetAction::value_type,RestrictedNaturalSetAction::domain_type>( G, D[0].size() ) {
124+
Omega = D;
125+
}
126+
127+
RestrictedNaturalSetAction::RestrictedNaturalSetAction( Group G, domain_type&& D ) : SetAction<RestrictedNaturalSetAction,RestrictedNaturalSetAction::value_type,RestrictedNaturalSetAction::domain_type>( G, D[0].size() ) {
120128
Omega = std::move( D );
121129
}
122130

action.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Action {
3434
template<typename T = action_set<value_type>> T orbit( value_type seed ) const;
3535
const std::vector<std::vector<value_type>>& orbits() const;
3636
std::vector<std::vector<value_type>> calculateOrbits() const;
37-
Group anonymize() const;
37+
Group anonymize( std::map<value_type,int>* inv_map = nullptr ) const;
3838
bool isTransitive() const;
3939
bool isTrivial() const;
4040
Group kernel() const;
@@ -73,6 +73,7 @@ class RestrictedNaturalAction : public PointAction<RestrictedNaturalAction,int,s
7373
public:
7474
const domain_type& domain() const;
7575
RestrictedNaturalAction( Group G, const domain_type& S );
76+
RestrictedNaturalAction( Group G, domain_type&& S );
7677
};
7778

7879
template<typename A, typename value_type, typename domain_type, int k>
@@ -127,7 +128,8 @@ class RestrictedNaturalSetAction : public SetAction<RestrictedNaturalSetAction,a
127128
const domain_type& domain() const;
128129
RestrictedNaturalSetAction randomBlocksystem() const;
129130
RestrictedNaturalSetAction( const NaturalAction& );
130-
RestrictedNaturalSetAction( Group G, domain_type D );
131+
RestrictedNaturalSetAction( Group G, const domain_type& D );
132+
RestrictedNaturalSetAction( Group G, domain_type&& D );
131133
};
132134

133135
// ----------------------------------------------------------------
@@ -156,9 +158,11 @@ std::vector<std::vector<value_type>> Action<A,value_type,domain_type>::calculate
156158
for( const auto& x : a->domain() )
157159
elements[ x ] = i++;
158160
i = 0;
159-
for( const auto& x : a->domain() )
161+
for( const auto& x : a->domain() ) {
160162
for( const auto& g : gens )
161-
orbit_count -= uf.cup( i++, elements[ a->act(g,x) ] );
163+
orbit_count -= uf.cup( i, elements[ a->act(g,x) ] );
164+
i++;
165+
}
162166
std::vector<std::vector<value_type>> r( orbit_count );
163167
std::map<int,int> indices;
164168
i = 0;
@@ -168,6 +172,7 @@ std::vector<std::vector<value_type>> Action<A,value_type,domain_type>::calculate
168172
if( i == j )
169173
indices[j] = orbit_count++;
170174
r[indices[j]].push_back( x );
175+
i++;
171176
}
172177
return r;
173178
}
@@ -237,21 +242,25 @@ Group Action<A,value_type,domain_type>::kernel() const {
237242
}
238243

239244
template<typename A, typename value_type, typename domain_type>
240-
Group Action<A,value_type,domain_type>::anonymize() const {
245+
Group Action<A,value_type,domain_type>::anonymize( std::map<value_type,int>* inverse_map ) const {
241246
int n = static_cast<const A*>(this)->domain().size();
242247
Group S_n( new SymmetricGroup( n ) );
243-
std::map<value_type,int> inverse_map;
248+
bool own_map = false;
249+
if( not inverse_map )
250+
inverse_map = new std::map<value_type,int>();
244251
std::vector<Permutation> generators;
245252
int i = 0;
246253
for( const auto& x : static_cast<const A*>(this)->domain() )
247-
inverse_map[ x ] = i++;
254+
(*inverse_map)[ x ] = i++;
248255
for( const Permutation& sigma : group()->generators() ) {
249256
std::vector<int> generator(n);
250257
i = 0;
251258
for( const auto& x : static_cast<const A*>(this)->domain() )
252-
generator[i++] = inverse_map[ operator()( sigma, x ) ];
259+
generator[i++] = (*inverse_map)[ operator()( sigma, x ) ];
253260
generators.emplace_back( std::move( generator ) );
254261
}
262+
if( own_map )
263+
delete inverse_map;
255264
return Group( new Subgroup( S_n, generators ) );
256265
}
257266

align.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "align.h"
2+
3+
Permutation pullback( Permutation sigma_bar, const inv_gamma_t& inv_gamma, const gamma_t& gamma ) {
4+
int n = sigma_bar.degree();
5+
matrix<bool> M( n, n );
6+
for( int i : range(0,n) ) {
7+
int j = sigma_bar(i);
8+
for( int x : gamma[i] )
9+
for( int y : gamma[j] )
10+
M.at( x, y ) = true;
11+
}
12+
std::vector<int> matching = bipartiteMatching( M );
13+
if( std::find( matching.begin(), matching.end(), -1 ) != matching.end() )
14+
throw;
15+
return Permutation( std::move( matching ) );
16+
}

align.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
#include <map>
3+
#include "configuration.h"
4+
#include "ext.h"
5+
#include "permutation.h"
6+
7+
typedef std::map<std::vector<int>,int> inv_gamma_t;
8+
typedef std::deque<std::vector<int>> gamma_t;
9+
typedef int rtype2;
10+
11+
template<typename T>
12+
Either<rtype2,Empty> align( const T& Xx, const T& Xy ) {
13+
throw;
14+
return Empty();
15+
}
16+
17+
18+
Permutation pullback( Permutation sigma_bar, const inv_gamma_t& inv_gamma, const gamma_t& gamma );
19+
20+
/*
21+
template<>
22+
Either<rtype2,Empty> Align<ColoredPartition>( const ColoredPartition& Xx, const ColoredPartition& Xy, const inv_gamma_t& inv_gamma, const gamma_t& gamma ) {
23+
// 1.
24+
// TO DO: check alternating type
25+
Either<Permutation,Empty> r = Xx.getIsomorphism( Xy );
26+
if( r.isSecond() )
27+
return Empty();
28+
Permutation sigma_bar = r.getFirst();
29+
// 2.
30+
std::cout << pullback( sigma_bar, inv_gamma, gamma );
31+
return 0;
32+
}*/

block_test.cc

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#include <iostream>
2+
#include "permutation.h"
3+
#include "action.h"
4+
#include "group.h"
5+
#include "johnson.h"
6+
#include "configuration.h"
7+
#include "align.h"
8+
9+
10+
int main() {
11+
int n = 5;
12+
Group Sn( new SymmetricGroup( n ) );
13+
NaturalSetAction a( Sn, Sn->degree(), 2 );
14+
std::map<std::vector<int>,int> reverse_anonymize;
15+
Group G = a.anonymize( &reverse_anonymize );
16+
std::cout << G->generators() << std::endl;
17+
std::cout << "---" << std::endl;
18+
std::cout << reverse_anonymize << std::endl;
19+
std::cout << "---" << std::endl;
20+
NaturalAction G_action( G );
21+
auto blocks = G_action.systemOfImprimitivity();
22+
std::cout << blocks.domain() << std::endl;
23+
std::cout << "---" << std::endl;
24+
// do cameron magic
25+
std::deque<std::vector<int>> Gamma;
26+
for( auto x : range(0,n) ) {
27+
std::vector<int> v;
28+
for( auto t : a.domain() ) {
29+
if( std::find( t.begin(), t.end(), x ) != t.end() )
30+
v.push_back( reverse_anonymize[t] );
31+
}
32+
std::sort( v.begin(), v.end() );
33+
Gamma.emplace_back( std::move( v ) );
34+
}
35+
std::cout << Gamma << std::endl;
36+
RestrictedNaturalSetAction Gamma_action( G, Gamma );
37+
//auto johnson_blocks = blocks;
38+
//auto Sk = johnson_blocks.anonymize();
39+
//std::cout << johnson_blocks.domain() << std::endl;
40+
std::cout << "---" << std::endl;
41+
std::map<std::vector<int>,int> reverse_anonymize2;
42+
Group H = Gamma_action.anonymize( &reverse_anonymize2 );
43+
44+
NaturalAction H_action( H );
45+
std::cout << reverse_anonymize2 << std::endl;
46+
std::cout << "---" << std::endl;
47+
std::cout << H->generators() << std::endl;
48+
std::cout << "---" << std::endl;
49+
auto standard_blocks = JohnsonStandardBlocks( Gamma_action );
50+
std::cout << standard_blocks.domain() << std::endl;
51+
52+
std::cout << "-------------------------------" << std::endl;
53+
RelationalStructure conf1(
54+
std::vector<std::set<std::vector<int>>>({
55+
std::set<std::vector<int>>({
56+
std::vector<int>({0,0}),std::vector<int>({1,1}),std::vector<int>({2,2}),std::vector<int>({3,3}),std::vector<int>({4,4})
57+
}),
58+
std::set<std::vector<int>>({
59+
std::vector<int>({0,1}),std::vector<int>({1,0}),
60+
std::vector<int>({1,3}),std::vector<int>({3,1}),
61+
std::vector<int>({0,4}),std::vector<int>({4,0}),
62+
std::vector<int>({2,4}),std::vector<int>({4,2})
63+
}),
64+
std::set<std::vector<int>>({
65+
std::vector<int>({1,2}),std::vector<int>({2,1}),
66+
std::vector<int>({1,4}),std::vector<int>({4,1}),
67+
std::vector<int>({3,4}),std::vector<int>({4,3}),
68+
std::vector<int>({0,2}),std::vector<int>({2,0})
69+
}),
70+
std::set<std::vector<int>>({
71+
std::vector<int>({0,3}),std::vector<int>({3,0}),
72+
std::vector<int>({2,3}),std::vector<int>({3,2})
73+
})
74+
})
75+
, 5 );
76+
conf1.WeisfellerLeman();
77+
std::cout << conf1.relations() << std::endl;
78+
std::cout << "-------------------------------" << std::endl;
79+
RelationalStructure conf2(
80+
std::vector<std::set<std::vector<int>>>({
81+
std::set<std::vector<int>>({
82+
std::vector<int>({0,0}),std::vector<int>({1,1}),std::vector<int>({2,2}),std::vector<int>({3,3}),std::vector<int>({4,4})
83+
}),
84+
std::set<std::vector<int>>({
85+
std::vector<int>({0,1}),std::vector<int>({1,0}),
86+
std::vector<int>({0,2}),std::vector<int>({2,0}),
87+
std::vector<int>({0,4}),std::vector<int>({4,0}),
88+
std::vector<int>({1,2}),std::vector<int>({2,1})
89+
}),
90+
std::set<std::vector<int>>({
91+
std::vector<int>({1,3}),std::vector<int>({3,1}),
92+
std::vector<int>({2,4}),std::vector<int>({4,2}),
93+
std::vector<int>({1,4}),std::vector<int>({4,1}),
94+
std::vector<int>({3,4}),std::vector<int>({4,3})
95+
96+
}),
97+
std::set<std::vector<int>>({
98+
std::vector<int>({0,3}),std::vector<int>({3,0}),
99+
std::vector<int>({2,3}),std::vector<int>({3,2})
100+
})
101+
})
102+
, 5 );
103+
conf2.WeisfellerLeman();
104+
std::cout << conf2.relations() << std::endl;
105+
std::cout << "-------------------------------" << std::endl;
106+
FurstHopfcroftLuksTail fhlt;
107+
std::deque<std::pair<Permutation,Permutation>> generator_mapping;
108+
fhlt.create( H, G, )
109+
110+
//Permutation sigma = pullback( H->generators()[0], reverse_anonymize2, Gamma_action.domain() );
111+
//std::cout << sigma << std::endl;
112+
113+
return 0;
114+
}

0 commit comments

Comments
 (0)