summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-17 03:01:59 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-17 03:01:59 +0100
commite292fa26f0bbb8a82f6ec8d0b24f61e144f62206 (patch)
tree6acec205155c5f0e4a53be0b14feb8f53638cebc
parent4e378cb7f808bf1f7b0b601e6b6635cb8bdc45c1 (diff)
downloadtsp-e292fa26f0bbb8a82f6ec8d0b24f61e144f62206.tar.gz
tsp-e292fa26f0bbb8a82f6ec8d0b24f61e144f62206.tar.bz2
* Add method to generate a random path
-rwxr-xr-xtsp.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tsp.py b/tsp.py
index 5b7d7fc..5eb81d4 100755
--- a/tsp.py
+++ b/tsp.py
@@ -189,6 +189,11 @@ class Context:
best = path
return best
+ def random_path (self):
+ path = range (0, self.count)
+ random.shuffle (path)
+ return Path (self, path)
+
class Algo:
context = None