Interesting-Chinese postman problem

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
macan
New poster
Posts: 7
Joined: Sun Mar 06, 2005 9:33 pm

Interesting-Chinese postman problem

Post by macan »

hi,
i'm new in this "programming world" and i need help on basic graph algorithms, specialy on the basic problem: Chinese postman problem. It consist on calculating the minimum cost for traveling from one vertex going trough all the edges and returning back to the initial vertex.
The solution is calculating the cost of all edges and then add the cost of the minimum pair matching cost of the odd vertexs.
For now i have used the flouyd algorithm, but now i don't know how to calculate the minimum matching cost of the odd vertexs

Thanks in advanced
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

Hi,

You may use backtracking/recursion to find the minimum pair matching cost. :)

Yes I also like Chinese Postman Problem very much~
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
macan
New poster
Posts: 7
Joined: Sun Mar 06, 2005 9:33 pm

Post by macan »

Thanks, but I do not know anything about backtraking. I've searched for information but it's really difficult to understand the main objective of this recursion, 'cause if never heard of it.
I just ask for help on this topic (backtracking/recursion) and if there exists any basic algorithm to implement it in C, how it works (what's the input and what's the output), and how could implement this algorithm to this problem (minimum matching cost between the odd vertexs)

Thanks
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

Hi,

I actually mean trying all matchings, with pruning (= cutting hopeless branches).

FYI, 10296 Jogging Trails is a Chinese Postman task. The judge solution also uses this idea.

Google search "branch and bound" if you need more information on pruning.
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
macan
New poster
Posts: 7
Joined: Sun Mar 06, 2005 9:33 pm

Post by macan »

ok, i'm starting to get it.
So i should try out one combination, then start cutting hopeless branches.
For example:
node node cost
1 2 5
2 3 3
2 3 5
3 4 2
3 5 4

My first try is (only odd vertex)
1,2 4,5 cost=5+2+4=11
then if i try
1,5 the cost already is 12 then i won't try this kind of combinations
That's the idea, right?
But then how i make an algorithm to try out all the possible combinationts and not including the combinations that i know that are going to cost more than the better one i have in each iteration?
Is there any basic algorithm that alredy does it?
Thanks
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Observer wrote:You may use backtracking/recursion to find the minimum pair matching cost. :)
There are also poly-time algorithms for finding a minimum weight matching, but they're quite complicated.
Post Reply

Return to “Algorithms”