Skip to content

Implement a Hamiltonian path algorithm, and Design a tour for visiting all cities of a country. (PHP)

License

Notifications You must be signed in to change notification settings

BaseMax/HamiltonianPathProblemPHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Hamiltonian Path Problem

Find a Hamiltonian path in a graph.

Implement a Hamiltonian path algorithm, and Design a tour for visiting all cities of a country. (PHP)

Using

$ php hamiltonian-path-problem.php

Example

If your start city is Kashan and you want to visit all cities only once and again back to Kashan.

$cities = [];
$cities[] = ["name" => "kashan", "points" => [0, 0]];
$cities[] = ["name" => "tehran", "points" => [1, 1]];
$cities[] = ["name" => "mashhad", "points" => [2, 2]];
$cities[] = ["name" => "tabriz", "points" => [3, 3]];
$cities[] = ["name" => "qom", "points" => [4, 4]];
$cities[] = ["name" => "shiraz", "points" => [5, 5]];
$cities[] = ["name" => "ahvaz", "points" => [6, 6]];
$cities[] = ["name" => "qazvin", "points" => [7, 7]];
$cities[] = ["name" => "khoramabad", "points" => [8, 8]];
$cities[] = ["name" => "yazd", "points" => [9, 9]];
$cities[] = ["name" => "sari", "points" => [10, 10]];

$res = HamiltonianPath($cities, $cities[0]);

So it's the output of the program:

  • Kashan
  • Tehran
  • Mashhad
  • Tabriz
  • Qom
  • Shiraz
  • Ahvaz
  • Qazvin
  • Khoramabad
  • Yazd
  • Sari
  • Kashan

About

Implement a Hamiltonian path algorithm, and Design a tour for visiting all cities of a country. (PHP)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages