|
-
Nov 17th, 2000, 05:45 AM
#1
Thread Starter
Lively Member
How do I say this?
Let's try...
I'm doing a program that finds a path between two given points. All points have an integer value, and they reside in an array, like this:
100 - 101
100 - 105
100 - 108
101 - 102
101 - 108
102 - 224
103 - 224
...
108 - 120
...
120 - 224
This means that from 100, the path goes either to 101, 105, or 108.
If the given start and end points were 100 - 224, the answer path would be 100-101-102-224 OR 100-108-120-224.
But how do I make this program?
Where do I start?
Thanks in advanks...
D
-
Nov 17th, 2000, 06:05 AM
#2
Fanatic Member
Are you looking for any path or the shortest path? You could do a brute force search on all possible paths but this rapidly becomes difficult if the number of nodes/chains in each path is even moderately large.
Few more details please, i.e. Number of nodes, limitations on the array, max array entries, length of the path etc.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 17th, 2000, 06:14 AM
#3
Lively Member
the easiest way is to use prolog (its backtracking facilities)
your paths will be stored as
path(100,101).
path(101,100).
path(101,105).
and so on
the function is
getpath(X,Y).
getpath(X,Y):- getpath(X,Z),print(X),print(" - "),print(Y),getpath(Z,Y).
to find the shortest path is NP complete problem which is best to solved in ECLIPSE prolog.
-
Nov 17th, 2000, 06:28 AM
#4
Thread Starter
Lively Member
Paulw: I'm kinda looking for any path. The Array(2D) have 110 x 3 elements. The path won't have more than 30 nodes.
Klintsovi: Prolog is something I don't know anything about. Please fill me in.
Thanks.
D
-
Nov 17th, 2000, 06:41 AM
#5
Fanatic Member
I'll think about this one. As Klitsovi says, this is a classic Network Path problem.
Somewhere, way back, I think I wrote some code to create a tree structure to do this. I'll have a look.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 17th, 2000, 09:39 AM
#6
Thread Starter
Lively Member
-
Nov 17th, 2000, 10:56 AM
#7
Fanatic Member
Nope. Too many beers at lunch. Probably be Monday - is that OK?
Basic approach is to define a structure with pointers to the next node, each node also has pointers to the next node etc. Each unique node is a destination so you can set up the start point (root node) and possible destinations, if you have found the destination you then 'walk' back through the pointers to find the route.
Is that clear.
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 18th, 2000, 05:59 PM
#8
Thread Starter
Lively Member
I'm starting to get the hang of it. I'm doing it backwards, kinda convinced that's the way to do it. Still some debugging left to do (endless loops etc.)
Beer at lunch rules.
D
-
Nov 20th, 2000, 05:01 AM
#9
Lively Member
Send us the code or the description of an algorithm it will be quite interesting to see the solution to the problem in VB
-
Nov 20th, 2000, 09:44 AM
#10
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|