[pgrouting-dev] helpful(?) from end function for the tsp routing code

Dave Potts dave.potts at pinan.co.uk
Mon Jul 8 02:45:34 PDT 2013


Dear List

Currently the Travelling sales person code takes a 4+x4+ distance matrix 
of  distances between nodes in the range 0-x  and returns a list of node.

The attached function takes a sql query in the form

'select source,target,cost from xxxxxx'

where source and target can be any numerical values, the return is a 
list of the same node values.

For example
  id | source | target | cost
----+--------+--------+------
   1 |      1 |      2 |   30
   2 |      1 |      3 |   40
   3 |      1 |     42 |   10
   0 |      2 |      1 |   30
   5 |      2 |      3 |   60
   6 |      2 |     42 |   70
   7 |      3 |      1 |   40
   8 |      3 |      2 |   60
   9 |      3 |     42 |   90
  10 |     42 |      1 |   10
  11 |     42 |      2 |   70
  12 |     42 |      3 |   90

select pgr_mktspret('select source,target,cost  from edge5',42);
  pgr_mktspret
--------------
  (0,42)
  (1,1)
  (2,3)
  (3,2)
(4 rows)
select pgr_mktspret('select source,target,cost  from edge5',3,2);
  pgr_mktspret
--------------
  (0,3)
  (1,1)
  (2,42)
  (3,2)
(4 rows)



Its based on some sql code that Steve posted several days ago.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: tspmkmat.sql
Type: text/x-sql
Size: 6370 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/pgrouting-dev/attachments/20130708/11888c60/attachment.bin>


More information about the pgrouting-dev mailing list