diff --git a/Backtracking/Hamiltonean Cycles/Code.java b/Backtracking/Hamiltonean Cycles/Code.java new file mode 100644 index 00000000..76c564cd --- /dev/null +++ b/Backtracking/Hamiltonean Cycles/Code.java @@ -0,0 +1,102 @@ +//A Hamiltonian cycle is a cycle in an undirected or directed graph that visits each vertex exactly once. +// import visualization libraries { +import org.algorithm_visualizer.*; +import java.util.Random; +// } + +class Main { + // define tracer variables { + GraphTracer graphTracer=new GraphTracer("GraphTracer"); + LogTracer logTracer = new LogTracer("Console"); + // } + int n=8; + int x[]; + int found=0; + int vis[]; + int[][] adjacencyMatrix; + void ham(int k) { + while(true) + { + nextVal(k); + if(x[k]==-1) + return; + if(k==n-1) + { + graphTracer.visit(x[0],x[k]); + graphTracer.delay(); + found=1; + //Printint the cycle{ + for(int i=0;i pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy