• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding a particular pattern in a file

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's move this to Programming Diversions
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic