This algorithm is a consequence of the 'Solve system of linear inequalities' algorithm. The procedure rapidly finds the pathways across all of the points on the graph by resolving the system of linear inequalities to determine the coefficients of the
The algorithm promises a general and systematic way of solving graph problems.
To download the tool, select Code > Zip Download
on Github page or type in Command Prompt on Windows or Terminal on other operating systems as follows:
git clone https://github.com/Truongphi20/hamilpath.git
Move the terminal's working directory to the downloaded "hamilpath" directory (cd hamilpath
).
python .\findpath.py -h
Output:
usage: findpath.py [-h] [-t VECTORS] [-v] [-c CIRCUIT]
optional arguments:
-h, --help show this help message and exit
-t VECTORS, --vectors VECTORS
-v, --version show version
-c CIRCUIT, --circuit CIRCUIT
Circuit (c) or path (p)?
Suppose we need to find the hamiltonian path for the following graph:
In the graph we see the following vectors:
From those vectors, we run the algorithm to find the hamiltonian path with the following syntax:
python .\findpath.py -t AD,AB,BD,DC,CD,BC,CA
Output:
['ABDC', 'ABCD', 'CABD', 'DCAB', 'BDCA', 'BCAD']
As a result, the paths pass through all the points. Here we have 6 paths:
Furthermore, finding Hamiltonian Circuit could be done by adding -c
tag. As the following command.
python .\findpath.py -t AD,AB,BD,DC,CD,BC,CA -c c
Output:
['ABDCA']
So, the Hamiltonian circuit for the above example is:
For example, a graph has points
The
$$ \leftrightarrow {M_p} = \left( {\begin{array}{{20}{c}} 0&0&1&0\ 1&0&0&0 \end{array}} \right) + \left( {\begin{array}{{20}{c}} 0&0&0&1\ 0&0&1&0 \end{array}} \right) $$
From above, we see that the matrix is commutative. Although vectors are not commutative, their
From the above two properties, we can use them to establish inequalities based on the
The algorithm process goes through the following basic steps:
- Prepare a system of linear inequalities
- Solve and find the coefficients for the
$\phi$ -matrices of the vectors - Returns the results of the paths which pass through the points