Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2003, 05:35 PM
Registered User
Join Date: Oct 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jtdang77 Send a message via MSN to jtdang77 Send a message via Yahoo to jtdang77
Default How to Write a Infinite Loop Detection

Hi All,

New to this forum and I am looking for help to write an
algorithm to detect infinite loop. Below is the situation:

Field A Field B
joe reuben
reuben dave
dave josh
row man
john row
row john

In this situation all data in FIELD A will go to FIELD B.
Here field A can mean like an email alias and field
B is the email address to forward to within a 1 domain (@domain.com).

So from here can see that there is an infinite loop
at john -> row -> john or vice versa row->john->row
where as joe->reuben->dave->josh is not an infinite loop
because whoever alias josh belongs to will receive the
email (assuming a different box, and josh does not forward to
anyone else)

So given this two fields from a db table, how can I
write an algorithm to ensure all aliases and email forward
does not create and infinite loop and stop keep forwarding in

Thanks for your help,


Reply With Quote
  #2 (permalink)  
Old October 15th, 2003, 03:44 AM
Friend of Wrox
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts

Well, this is not a trivial question. There are several approches, and probably more than I will point at here. I will suggest two.

What you are facing is really a graph problem. If you know about graph theory you might want to study some of the algorithms in this area. I think that you might be able to modify the Bellman-Ford algorithm, however this solution is somewhat tricky, and isn't advisable unless you have got huge amounts of data, and care a lot about performance.

The other approach could be something like the following... For each relation (FieldA - FieldB) you follow the path from from FieldA to FieldB and any relation in which FieldB is the sender (typically recursive), and so on. If you discover the original sender there must be a cycle.

When do you stop following the path?! Well, I think you can stop when your path is longer than the number of relations in the table, since in worst case each relation connects to some other relation and finally all relations are connected, so you will have to go this far. But some path may go forever even though it doesn't return to the original sender since another relation might cause an infinite loop. This is why you have to stop the path finder manually.

You don't have to post your question in several different lists, and some might even say don't post in several...

Hope this helps


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
infinite loop smilesmita Pro PHP 1 December 21st, 2007 10:44 AM
problem of infinite loop sarah lee ASP.NET 1.0 and 1.1 Basics 19 December 14th, 2006 09:26 AM
problem getting out of infinite loop and incremtin method VB How-To 0 April 28th, 2006 11:45 PM
Infinite timer? acdsky VBScript 1 June 17th, 2004 02:59 PM
Infinite Loop Detection jtdang77 Classic ASP Basics 0 October 14th, 2003 05:32 PM

All times are GMT -4. The time now is 10:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.