-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from isadofschi/develop
v1.0.4
- Loading branch information
Showing
42 changed files
with
876 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/bin/* | ||
Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
@Chapter Installing and Loading the SmallCancellation Package | ||
@Section Compiling Binaries of the SmallCancellation Package | ||
@Section Loading the SmallCancellation Package | ||
|
||
@Chapter Small Cancellation Theory | ||
@Chapter Small Cancellation Theory: the classical conditions | ||
@Section Introduction | ||
@Section Pieces | ||
@Section Metric small cancellation conditions | ||
@Section Non-metric small cancellation conditions | ||
@Section Additional functions | ||
@Section Implementation details | ||
|
||
@Chapter More small cancellation conditions | ||
@Section Condition Tau' | ||
|
||
@Chapter Additional functions | ||
@Section Additional functions | ||
|
||
|
||
|
||
@Chapter Installing and Loading the SmallCancellation Package | ||
@Section Compiling Binaries of the SmallCancellation Package | ||
@Section Loading the SmallCancellation Package | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,3 @@ DeclareGlobalFunction("GroupSatisfiesCPrimeExternal"); | |
|
||
DeclareGlobalFunction("GetBoolFromOutput"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
######################################################################################## | ||
## | ||
## ttilde.gd SmallCancellation Package Iván Sadofschi Costa | ||
## | ||
|
||
#! @Chapter More small cancellation conditions | ||
#! @Section Condition Tau' | ||
|
||
#! Condition $\mathcal{T}'$ was introduced in <Cite Key="BMSC20" />. | ||
#! We give here the definition in terms of van Kampen diagrams. | ||
#! If $v$ is an interior vertex in a reduced diagram $D$, let $$d'_F(v)=\sum_{c\in v} \frac{\ell_1(c)+\ell_2(c)}{\ell_r(c)}$$ where the sum is over all corners at $v$, $\ell_r(c)$ is the length of the relator corresponding to the corner $c$ and $\ell_i(c)$ are the lenghts of the words written in the edges of the corner. | ||
#! A presentation $P$ satisfies $\mathcal{T}'$ if $2\leq d(v)-d'_F(v)$ for every interior vertex $v$ in every reduced diagram $D$ over $P$. | ||
#! If this inequality is strict we say that the presentation satisfies condition $\mathcal{T}'_{<}$. | ||
#! $$ $$ | ||
#! If $P$ is a finite presentations satisfying $\mathcal{T}'_{<}-C(3)$ then the group presented by $P$ is hyperbolic <Cite Key="BMSC20" Where="Theorem 3.3" />. | ||
#! A presentation without proper powers which satisfies condition $\mathcal{T}'$ is diagrammatically reducible (DR) <Cite Key="BMSC20" Where="Theorem 3.2" />. | ||
#! If $P$ satisfies $\mathcal{T'}-C'(\frac{1}{2})$ and the defining relators have the same length then $P$ satisfies a quadratic isoperimetric inequality and if in addition $P$ is finite, it has solvable conjugacy problem <Cite Key="BMSC20" Where="Theorem 4.2" />. | ||
|
||
#! @Arguments G | ||
#! @Description Given an FpGroup G gives the minimum of $d(v)-d'_F(v)$. | ||
#! Thus if the function returns a number greater than or equal to $2$ the group presentation satisfies $\mathcal{T}'$ and if the number is greater than $2$ it satisfies $\mathcal{T}'_{<}$. | ||
#! This function implements the algorithm in <Cite Key="BMSC20" />. | ||
#! For the moment the computation is done numerically using floating point numbers (this may be modified in a future version to do the computation exactly with rational numbers). External binaries need to be compiled. | ||
#! @BeginExampleSession | ||
#! @EndExampleSession | ||
DeclareGlobalFunction("GroupSatisfiesTauPrime"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
######################################################################################## | ||
## | ||
## ttilde.gi SmallCancellation Package Iván Sadofschi Costa | ||
## | ||
|
||
SaveGraphToFile:=function(n,edges,filename) | ||
# n is the number of vertices | ||
# vertices are numbered from 1 to n | ||
# each edge in edges is represented as a list [source, target, cost] | ||
local m,f,e; | ||
m:=Length(edges); | ||
f := IO_File(filename,"w"); | ||
IO_Write(f, n); | ||
IO_Write(f, " "); | ||
IO_Write(f, m); | ||
IO_Write(f, "\n"); | ||
for e in edges do | ||
IO_Write(f, e[1]); IO_Write(f, " "); IO_Write(f, e[2]); IO_Write(f, " "); IO_Write(f, e[3]); IO_Write(f, "\n"); | ||
od; | ||
IO_Flush(f); | ||
IO_Close(f); | ||
end;; | ||
|
||
ReadFloat:=function(filename) | ||
local file,f; | ||
file := IO_File(filename,"r"); | ||
f := Float(Chomp(IO_ReadLine(file))); | ||
IO_Close(file); | ||
return f; | ||
end;; | ||
|
||
|
||
InstallGlobalFunction(GroupSatisfiesTauPrime, function(G) | ||
# Esta funcion da el minimo de d-dtilde para el grupo G | ||
# el grupo cumple TTilde si devuelve >=2 | ||
local P,R_star,vertices,T,isPiece, | ||
d_pieces,d_relations,d_vertices, | ||
n_pieces,n_relations,n_vertices, | ||
p,q,r,l,i,i0,i1,j,j0,j1,j2,j0rot,k,v,s,t, | ||
ocurrences, | ||
trick_k,M1,n_vertices_1, | ||
e,edges,M,INF,girth, | ||
next, | ||
filename_in,filename_out,tmpdir,tTildeProgram,result; | ||
|
||
R_star:=SymmetrizedRelationSet(G); | ||
n_relations:= Length(R_star); | ||
T:=TrieOfPieces(G);; | ||
isPiece:=T[4];; | ||
P:=PiecesOfGroup(G); | ||
n_pieces := Length(P); | ||
INF := 10000; | ||
if n_pieces = 0 then # no pieces, we return INF | ||
Print("# The presentation has no pieces.\n"); | ||
return INF; | ||
fi; | ||
d_pieces:=NewDictionary(P[1],true); | ||
for i in [1..n_pieces] do | ||
AddDictionary(d_pieces,P[i],i); | ||
od; | ||
d_relations:=NewDictionary(R_star[1],true); | ||
for j in [1..n_relations] do | ||
AddDictionary(d_relations,R_star[j],j); | ||
od; | ||
ocurrences:=List([1..n_pieces], j-> []); | ||
for j in [1..n_relations] do | ||
r:=R_star[j]; | ||
for t in [1..Length(r)] do | ||
p:=Subword(r,1,t); | ||
if isPiece(LetterRepAssocWord(p)) then | ||
Add(ocurrences[LookupDictionary(d_pieces,p)],j); | ||
fi; | ||
od; | ||
od; | ||
edges:=[]; | ||
for r in R_star do | ||
l:=Length(r); | ||
j0:=LookupDictionary(d_relations,r); | ||
for s in [1..l] do | ||
p:=Subword(r,1,s); | ||
if isPiece(LetterRepAssocWord(p)) then | ||
i0:=LookupDictionary(d_pieces,p); | ||
for t in [1..l-s] do | ||
q:=Subword(r,s+1,s+t); | ||
if isPiece(LetterRepAssocWord(q)) then | ||
i1:=LookupDictionary(d_pieces,q^-1); | ||
j0rot:=LookupDictionary(d_relations, (p*q)^-1*r^-1*(p*q)); | ||
for j1 in ocurrences[LookupDictionary(d_pieces,q^-1)] do | ||
if j1<>j0rot then | ||
Add(edges, [ | ||
[j0,i0], | ||
[j1,i1], | ||
1-((Length(p)+Length(q))/l) ]); | ||
fi; | ||
od; | ||
fi; | ||
od; | ||
fi; | ||
od; | ||
od; | ||
vertices := Set( Concatenation(List(edges, e->e[1]), List(edges,e->e[2]))); | ||
d_vertices:=NewDictionary(vertices[1],true); | ||
n_vertices:=Length(vertices); | ||
for i in [1..n_vertices] do | ||
AddDictionary(d_vertices,vertices[i],i); | ||
od; | ||
# por ahora no nos preocupamos por el error numerico | ||
edges:=List(edges, e-> [ LookupDictionary(d_vertices,e[1]), LookupDictionary(d_vertices,e[2]), Float(e[3]) ] ); | ||
|
||
tTildeProgram := Filename(DirectoriesPackagePrograms("smallcancellation"), "tauexternal"); | ||
|
||
tmpdir := DirectoryTemporary();; | ||
filename_in:=Filename( tmpdir , "tmpIn" ); | ||
filename_out:=Filename( tmpdir , "tmpOut" ); | ||
|
||
SaveGraphToFile(n_vertices,edges,filename_in); | ||
Exec(Concatenation(tTildeProgram," ", filename_in , " " , filename_out)); | ||
result:= ReadFloat(filename_out); | ||
Exec(Concatenation("rm ",filename_in)); | ||
Exec(Concatenation("rm ",filename_out)); | ||
|
||
return result; | ||
end ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#include<iostream> | ||
#include<cstdio> | ||
#include<vector> | ||
#include<set> | ||
#include<algorithm> | ||
|
||
using namespace std; | ||
|
||
#define forn(i,n) for(int i =0 ; i < (int)(n);i++) | ||
#define forall(i,c) for(typeof((c).begin()) i = (c).begin();i != (c).end();i++) | ||
|
||
typedef double cost; | ||
typedef vector<int> vi; | ||
typedef pair<cost,int> edge; | ||
typedef vector< vector<edge > > Graph; | ||
|
||
#define INF 10000.0 | ||
|
||
vector<cost> dijkstra(Graph & g, int source, int target = -1){ | ||
vector<cost> D(g.size(),INF); | ||
D[source] = 0; | ||
set<edge> pq; | ||
pq.insert(make_pair(D[source],source)); | ||
while(!pq.empty()){ | ||
edge p = *pq.begin(); | ||
int u = p.second; | ||
pq.erase(pq.begin()); | ||
if(u == target) | ||
return D; | ||
forall(it,g[u]){ | ||
cost c = it->first; | ||
int v = it->second; | ||
if(D[v] > D[u]+c){ | ||
if(D[v] != INF){ | ||
pq.erase(make_pair(D[v],v)); | ||
} | ||
D[v] = D[u] + c; | ||
pq.insert(make_pair(D[v],v)); | ||
} | ||
} | ||
} | ||
return D; | ||
} | ||
|
||
Graph read_graph(char* filename){ | ||
int n,m; | ||
FILE* F = freopen(filename,"r", stdin); | ||
int ok = 1; | ||
ok &= scanf("%d", &n); | ||
Graph g(n); | ||
ok &= scanf("%d", &m); | ||
forn(i,m){ | ||
int v,w; | ||
cost c; | ||
ok &= scanf("%d",&v); | ||
ok &= scanf("%d",&w); | ||
ok &= scanf("%lf",&c); | ||
edge e = make_pair(c,w-1); | ||
g[v-1].push_back(e); | ||
} | ||
fclose(F); | ||
if(not (ok==1)) cerr << "Error reading graph"<<endl; | ||
return g; | ||
} | ||
|
||
// the graph obtained from G has vertex set V(G) x {0,..., k} | ||
#define code(v,i,k1) ((k1)*(v)+(i)) // code(v,i,k1) is the number of the vertex (v,i) in the new graph | ||
|
||
Graph trick(Graph &g, int k){ | ||
int n = g.size(); | ||
int k1 = k+1; | ||
vector< vector<edge> > g1 ( k1*n ); | ||
forn(v,n){ | ||
forall(it,g[v]){ | ||
edge e = *it; | ||
cost c = e.first; | ||
int w = e.second; | ||
forn(i,k){ | ||
g1[ code(v,i,k1) ].push_back( make_pair(c, code(w,i+1,k1))); | ||
} | ||
g1[ code(v,k,k1) ].push_back( make_pair(c, code(w,k,k1))); | ||
} | ||
} | ||
return g1; | ||
} | ||
|
||
cost shortest_cycle(Graph &g, int k){ | ||
// returns the minimum cost of a cycle in g having length at least k | ||
// (for k=1 this is the girth of g) | ||
int n = g.size(); | ||
Graph g1 = trick(g, k); | ||
int k1 = k+1; | ||
vector<double> girths(n); | ||
#pragma omp parallel for | ||
forn(v,n){ | ||
int vs = code(v,0,k1); | ||
int vt =code(v,k,k1); | ||
girths[v] = dijkstra(g1,vs,vt)[vt]; | ||
} | ||
double girth = INF; | ||
forn(v,n) | ||
girth = min(girth,girths[v]); | ||
return girth; | ||
} | ||
|
||
int main(int argc, char *argv[]){ | ||
char* filename_in =argv[1]; | ||
char* filename_out =argv[2]; | ||
Graph g = read_graph( filename_in); | ||
cost girth = shortest_cycle(g, 3); | ||
FILE * F = freopen(filename_out, "w", stdout); | ||
cout << girth << endl; | ||
fclose(F); | ||
return 0; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.