Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding a particular pattern in a file

 
sina sinchen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:



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

[ October 10, 2005: Message edited by: sina sinchen ]
[ October 10, 2005: Message edited by: Mark Spritzler ]
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move this to Programming Diversions
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic