Successfully reported this slideshow.
Upcoming SlideShare
×

# Giraph Travelling Salesman Example

3,574 views

Published on

Quick brute-force implementation of the Travelling Salesman Problem with Giraph

Published in: Technology, Education
• Full Name
Comment goes here.

Are you sure you want to Yes No
• I don't understand why you have added 10+33 at the last step between vertex 3 and 2.
I would have added 1+33 and yes it would get 109 as a result like the other path because edges weights are the same in both directions between vertexes and there is only one possible path in your exemple (that is not the reverse of another one).

Are you sure you want to  Yes  No

### Giraph Travelling Salesman Example

1. 1. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 10 12 12 32 32 1 33 33 31 31On the left, we will show the original graph, to know how to process each step
2. 2. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 10 12 12 32 321 33 33 31 31 Superstep 0 begins
3. 3. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 10 12 12 32 321 33 33 31 31Superstep 0 : we compute vertex n°1, nothing to do, it is not the source
4. 4. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 10 12 12 32 321 33 33 31 31 Superstep 0 : we compute vertex n°2, the source
5. 5. Giraph : Travelling Salesman Problem Superstep : 0 1 2 3 23 23 24 24 30 2,12+30 10 12 12 32 32 1 2,12+1 33 33 31 31The source sends all the possible paths and their values to the others nodes
6. 6. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 2,12+30 10 12 12 32 321 2,12+1 33 33 31 31 The source then votes to halt
7. 7. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 24 24 30 2,12+30 10 12 12 32 32 1 2,12+1 33 33 31 31Superstep 0 : we compute vertex n°3, nothing happens as it is not the source
8. 8. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 24 24 30 2,12+30 10 12 12 12 32 321 2,12+1 33 33 33 31 31 Superstep 1 begins
9. 9. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 24 24 30 2,12+30 10 12 12 12 32 321 2,12+1 33 33 33 31 31 Superstep 1 : we compute vertex n°1
10. 10. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 24 24 30 2,12+30 10 12 12 12 32 321 2,12+1 21,42+10+23 33 33 33 31 31 Superstep 1 : we compute vertex n°1
11. 11. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 24 24 30 2,12+30 10 12 12 12 32 321 2,12+1 21,42+10+23 33 33 33 31 31 Superstep 1 : we compute vertex n°3
12. 12. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 24 24 30 2,12+30 23,13+10+33 10 12 12 12 32 321 2,12+1 21,42+10+23 33 33 33 31 31 Superstep 1 : we compute vertex n°3
13. 13. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 24 30 2,12+30 23,13+10+33 10 12 12 12 12 321 2,12+1 21,42+10+23 33 33 33 33 31 Superstep 2 begins
14. 14. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 24 30 2,12+30 23,13+10+33 10 12 12 12 12 321 2,12+1 21,42+10+23 33 33 33 33 31 Superstep 2 : we compute vertex n°1
15. 15. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 24 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 321 2,12+1 21,42+10+23 33 33 33 33 31 Superstep 2 : we compute vertex n°1
16. 16. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 24 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 321 2,12+1 21,42+10+23 33 33 33 33 31 Superstep 2 : we compute vertex n°3
17. 17. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 24 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 321 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 31 Superstep 2 : we compute vertex n°3
18. 18. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 121 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 Superstep 3 begins
19. 19. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 121 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 Superstep 3 : we compute vertex n°1
20. 20. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 121 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 Superstep 3 : we compute vertex n°1 : votes to Halt
21. 21. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 12 1 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33Superstep 3 : we compute the source, reactivated by the messages received
22. 22. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 121 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33The source compares the values received and ﬁnds the minimum distance
23. 23. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 1091 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 and sets its value as the minimum
24. 24. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 1091 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 The source then votes to Halt
25. 25. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 1091 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33 Superstep 3 : we compute vertex n°3
26. 26. Giraph : Travelling Salesman Problem 0 1 2 3 23 23 23 23 23 30 2,12+30 23,13+10+33 231,56+30+23=109 10 12 12 12 12 1091 2,12+1 21,42+10+23 213,75+10+33=118 33 33 33 33 33Superstep 3 : we compute vertex n°3 : votes to Halt, ends the process