/* File : Braid.java * Program : Handle Reduction Aimation - Applet * By Jean Fromentin * Copyright 2008 Jean Fromentin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ class Braid extends List{ public int handleType; public int strandNumber=4; public Node handleBegin; public Node handleEnd; public int handleBeginIndice; public int handleEndIndice; public int handleStrand; public int trivialNumber; public Braid(){} public Braid(String braidWord){ int length; int value; char letter; strandNumber=4; value=0; length=braidWord.length(); addLast(0); for(int i=0;i='a' && letter<='z'){ value=(int)(letter-'a')+1; if(value+1>strandNumber){ strandNumber=value+1; } } else if(letter>='A' && letter<='Z'){ value=-(int)(letter-'A')-1; if(-value+1>strandNumber){ strandNumber=-value+1; } } else{ value=0; } addLast(value); } addLast(0); } public void findHandle(){ Node handles[]=new Node[strandNumber]; int indices[]=new int[strandNumber]; int signs[]=new int[strandNumber]; int sign,value; boolean stop; int indice=0; for(int i=0;iMath.abs(indice)){ indice=value; } if(isEnd()){ stop=true; } else{ shift(); } } return indice; } }