Hallo everybody,
I have a file which indicates a link between 2 persons(column 1&2) and column3 is their relation.
FILE:
1 2 1
2 3 1
1 3 1
3 4 1
3 5 1
4 5 1
5 4 1
6 7 1
6 8 1
7 8 1
7 8 2
SO i have here 8 persons(their links in coumn1&2) with relation1 as regulation and relation2 as interaction(column3).
I wrote a program which searches for the links between 3 persons in the following way:
if we consider 3 persons(a
pattern) 1,2,3 then there should be a link between (1,2)(1,3)&(2,3) and the relation should be always1(regulation).Then the output should be those 3 persons(1,2,3).
*If there exists a reverselink between (2,1) and also when a link has both the relations(1&2-regulation and interaction)then the pattern should be ignored
For example in the case of 3,4,5.we have (3,4)(3,5)&(4,5) with the relation 1 and we also have a reverse regulation(5,4). In this case 3,4,5 shouldnot be counted.
Also6,7,8.Links (6,7)(6,8)&(7,8)all with relation 1 but at the lastline we also have a link (7,8)with a relation2.So it should also be ignored.
My program:
code:
--------------------------------------------------------------------------------
import java.io.*;import java.util.*;import java.lang.String.*;public class analysis8 { public analysis8() throws Exception { int A1=0; //int B1=0;int C1=0; int [][]x = new int[11][2];int j = 0;int k=0; int m=0;int q=0; PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("E:/Final_files/output.txt"))); { int ln=0;int ln1=0;int count=0;
String line,line1,A,B = " "; String value[] =new String[200]; String values[] =new String[200]; BufferedReader b1 = new BufferedReader(new FileReader("E:/Final_files/Transreg.txt")); LineNumberReader l = new LineNumberReader(b1); while(true) { line = l.readLine();if (line==null) break; StringTokenizer st = new StringTokenizer(line); ln = l.getLineNumber(); if (ln>=1) { //p.println(); int i = 0; while(st.hasMoreTokens()) { value[i] = st.nextToken(); x[j][i] = Integer.parseInt(value[i]);//p.print(x[j][i]+"\t"); i++; } j++; } }b1.close();//p.close(); for(int a=1; a<=9; a++){ for (int b=1; b<=9; b++){ for (int c=1; c<=9; c++){int B1=0;int C1=0; int B1R=0; int C1R=0; int A1R=0; int B1R1=0; int C1R1=0; for (j=0; j<=11;j++) { if(x[j][2]==1) if((a==x[j][0])&& (b== x[j][1])) { A1=a; B1=b; for(m=0;m<=11;m++) {if(x[m][2]==1) if((a==x[m][0])&& (c== x[m][1])) { A1=a; C1=c; for (k=0; k<=11;k++) {if(x[k][2]==1) if((B1==x[k][0])&& (C1== x[k][1])) { B1R=B1; C1R=C1; for (q=0; q<=11;q++){ if((B1R!=x[q][0])&& (A1!= x[q][1])){ if((C1R!=x[q][0])&& (A1!= x[q][1])){ if((C1R!=x[q][0])&& (B1R!= x[q][1])){ A1R=A1;B1R1=B1R;C1R1=C1R; /*if((C1==x[k][0])&& (B1== x[k][1])) if(B1!=0&&C1!=0) {p.println(A1+"\t"+C1+"\t"+B1);}*/ }}}} if(B1R!=0&&C1R!=0) {p.println(A1R+"\t"+B1R1+"\t"+C1R1);} } }}} } }}}}p.close(); } } public static void main(String s[]) throws Exception { new analysis8(); }}
--------------------------------------------------------------------------------
THe original file which I have used as input has around 1300 persons and almost 6000 rows(links).Computational time is too much and also the baove program gives the output which considers reverse regulation.Which shouldnot happen?
Kindly correct my code running the sample input file given above.
The output should be 1,2,3 in the above case.
Thanx in advance