S
streamkid
hello..
i have the following problem to solve, which is part of mst problem.
i have some nodes (ie cities if you like), and each city is connected
with some other. we don't know which city is connected with what other
city, except for the 1st level (direct connections from city to city).
i want to build the complete map of what is connected to what.
let's say that i have:
city A, connected to: D, F
city B, connected to: A, C,
city C, connected to: D,
starting from city D, i find out that it's connected to C.
C is also connected to B and directly. We set also true that D is
connected to B.
Since B is connected To A, D must know that it's also connected to
whichother cities A is connected with.
And So on..
As you can see, there is a recursive "thing" in this process.
I 'm wondering how to implement it.. I thought of building a function
that would recursively calls its self, and does what i described with
words above.
And for each step deeper it will go, it won't check if the current
node is also connected with past-checked nodes..
I hope you get what i mean.. Can't describe it better :|
If you think that it could be done better/easier with another way,
tell me!
i have the following problem to solve, which is part of mst problem.
i have some nodes (ie cities if you like), and each city is connected
with some other. we don't know which city is connected with what other
city, except for the 1st level (direct connections from city to city).
i want to build the complete map of what is connected to what.
let's say that i have:
city A, connected to: D, F
city B, connected to: A, C,
city C, connected to: D,
starting from city D, i find out that it's connected to C.
C is also connected to B and directly. We set also true that D is
connected to B.
Since B is connected To A, D must know that it's also connected to
whichother cities A is connected with.
And So on..
As you can see, there is a recursive "thing" in this process.
I 'm wondering how to implement it.. I thought of building a function
that would recursively calls its self, and does what i described with
words above.
And for each step deeper it will go, it won't check if the current
node is also connected with past-checked nodes..
I hope you get what i mean.. Can't describe it better :|
If you think that it could be done better/easier with another way,
tell me!