Hamiltonian Path And Cycle
easy
1. You are given a graph and a src vertex. 2. You are required to find and print all hamiltonian paths and cycles starting from src. The cycles must end with "*" and paths with a "." Note -> A hamiltonian path is such which visits all vertices without visiting any twice. A hamiltonian path becomes a cycle if there is an edge between first and last vertex. Note -> Print in lexicographically increasing order.
Constraints
None
Format
Input
Input has been managed for you
Output
Check sample output
Example
Sample Input
7
9
0 1 10
1 2 10
2 3 10
0 3 10
3 4 10
4 5 10
5 6 10
4 6 10
2 5 10
0
Sample Output
0123456.
0123465.
0125643*
0346521*
Question Video