// Listing 1: TokenTest.java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.io.*;
class test {
public String authorName[];
public String nextauthorName[];
public String composedauthorName;
public int authorID[];
public int authorMatrix[][];
public String authorPaperInfo;
public String authorPaperExtraInfo;
public String authorPaperFullInfo[];
public int n;
public int noOfcluster;
public String clusterInfo[];
public String tempauthorData;
public static void main (String[] args) {
test tt = new test();
tt.dbTest();
}
void dbTest() {
int c,i,j,k,l=0,c1,p;
File fr;
FileInputStream inFile;
BufferedReader br;
StringTokenizer dataFile = null;
Boolean flag =false;
//Boolean f =false;
this.authorName = new String[1000];
this.authorMatrix = new int [1000][1000];
this.authorPaperFullInfo = new String[1000];
this.nextauthorName = new String[1000];
this.composedauthorName = null;
this.clusterInfo = new String[1000];
c=0;
c1=0;
try {
File newDistance = new File(“htm2″ + “.gml”);
BufferedWriter output = new BufferedWriter( new FileWriter(newDistance) );
output.write(“graph [");
fr = new File("hmri4.csv");
inFile = new FileInputStream(fr);
br = new BufferedReader(new InputStreamReader(inFile));
dataFile = new StringTokenizer(br.readLine(), "\t,\n");
this.noOfcluster=Integer.parseInt(dataFile.nextToken());
for (l=0;l<noOfcluster;l++){
dataFile = new StringTokenizer(br.readLine(), "\t,\n");
this.n=Integer.parseInt(dataFile.nextToken());
dataFile = new StringTokenizer(br.readLine(), "\t,\n");
this.clusterInfo[l]=dataFile.nextToken();
System.out.println("Cluster Info= "+this.clusterInfo[l]);
for (i=0;i<n;i++){
c1=0;
dataFile = new StringTokenizer(br.readLine(), "'");
this.tempauthorData =dataFile.nextToken();
/*
StringTokenizer st1 = new StringTokenizer(this.tempauthorData, ",");
while(st1.hasMoreTokens())
{
this.nextauthorName[c1] =st1.nextToken();
c1++;
}
*/
this.nextauthorName = this.tempauthorData.split(",\\s");
c1=this.nextauthorName.length;
for (j=0; j<c1; j++){
flag=false;
for(k=0;k<c;k++){
if(this.nextauthorName[j].compareToIgnoreCase(this.authorName[k])==0){
this.authorMatrix[i][j]=k;
this.authorName[c]=this.nextauthorName[j];
System.out.println(" pos[i]="+i+ " pos[j]= "+j+"Author No (old) = "+this.authorMatrix[i][j]+" Author Name = "+this.authorName[c]);
flag=true;
break;
}
}
if (flag==false){
this.authorName[c]=nextauthorName[j];
this.authorMatrix[i][j]=c;
System.out.println(" pos[i]="+i+ " pos[j]= "+j+"Author No (new) = "+this.authorMatrix[i][j]+" Author Name = "+this.authorName[c]);
// print nodes
output.write("\tnode [ \n");
output.write("\t\tid " + c +"\n");
output.write("\t\tlabel \"" + this.authorName[c] +"\"\n");
output.write("\t\tgraphics [\n");
output.write("\t\t\tx 10 \n");
output.write("\t\t\ty 20 \n");
output.write("\t\t\tw 80 \n");
output.write("\t\t\th 90 \n");
output.write("\t\t\ttype \"rectangle3d\" \n");
output.write("\t\t\tfill \"#CCFFFF\" \n");
output.write("\t\t]\n");
output.write("\t]\n");
c++;
}
}//j
this.authorPaperInfo =dataFile.nextToken();
this.authorPaperExtraInfo =dataFile.nextToken();
this.authorPaperFullInfo[i] = this.authorPaperInfo + this.authorPaperExtraInfo;
System.out.println("PaperInfo ID="+i+" PaperInfo= " +this.authorPaperFullInfo[i]);
// for(i=0;i<this.n;i++){
for(j=0;j<c1;j++){
for(p=1;p<c1-j;p++){
output.write("\tedge [\n");
output.write("\t\tsource " + this.authorMatrix[i][j] + "\n");
output.write("\t\ttarget " + this.authorMatrix[i][j+p] + "\n");
output.write("\t\tlabel \"" + this.authorPaperFullInfo[i] + "\"\n");
output.write("\t\tgraphics\n");
output.write("\t\t\t[\n");
output.write("\t\t\t]\n");
output.write("\t\tLabelGraphics\n");
output.write("\t\t\t[\n");
output.write("\t\t\t\tvisible 0\n");
output.write("\t\t\t]\n");
output.write("\t]\n");
}
}
// }
} //i
// System.out.println("No of author="+c);
// System.out.println("N="+n);
// System.out.println("C1="+c1);
/*
for(i=0;i<n;i++){
for(j=0;j<c1;j++){
for(p=1;p<c1;p++){
output.write("\tedge [\n");
output.write("\t\tsource " + this.authorMatrix[i][j] + "\n");
output.write("\t\ttarget " + this.authorMatrix[i][j+p] + "\n");
//output.write("\t\tlabel \"" + D[i][j] + "\"");
output.write("\t\tgraphics\n");
output.write("\t\t\t[\n");
output.write("\t\t\t]\n");
output.write("\t]\n");
}
}
}
*/
} //l
/*
for(i=0;i<c;i++){
output.write("\tnode [ \n");
output.write("\t\tid " + i +"\n");
output.write("\t\tlabel \"" + this.authorName[i] +"\"\n");
output.write("\t\tgraphics [\n");
output.write("\t\t\tx 10 \n");
output.write("\t\t\ty 20 \n");
output.write("\t\t\tw 80 \n");
output.write("\t\t\th 90 \n");
output.write("\t\t\ttype \"rectangle3d\" \n");
output.write("\t\t\tfill \"#CCFFFF\" \n");
output.write("\t\t]\n");
output.write("\t]\n");
}
*/
output.write("]\n");
if (output != null)
output.close();
} catch ( IOException e ) {
System.out.println( "i/o error: " + e );
}
} // end dbTest
} // end class