/* By A Sahu IIT Guwahati * asahu@iitg.ac.in * * Program to generate Maze (Grid/Mesh with some faulty nodes) file for testing * * $g++ generateMaze.cpp -o generateMaze * * $ ./generateMaze Height:int Width:int FaultProbability:fp<0,1> SrcX SrcY DstX DstY * Example $./generateMaze 10 10 0.3 1 1 9 9 * * It generate "Mazedata.pl" file which contain facts for prolog for Maze (Grid/Mesh with some faulty nodes) * It also generate graph1.png, which shows the connectivity of Maze * The source node and destination node * * This code require graphviz. If graphviz is not available in your system * please install it * #yum install graphviz * or * $sudo apt-get install graphviz * */ #include #include #include using namespace std; int Width, Height; ofstream MazeData, MazeGraph; int **F; void Link(int i, int j, int k, int l){ if(F[k][l]!=1){ //No link to Faulty Node MazeData<<"\nmazelink("<"< SrcX SrcY DstX DstY\n"; exit(1); } Width=atoi(argv[1]); Height=atoi(argv[2]); FaultProbability=atof(argv[3]); srcX=atoi(argv[4]); srcY=atoi(argv[5]); dstX=atoi(argv[6]); dstY=atoi(argv[7]); MazeData.open("mazedata.pl"); MazeGraph.open("MazeGraph.dot"); MazeGraph<<"\ndigraph G {\n"; // Create F the Fault array F = (int **) malloc (sizeof(int*)*Height); for(i=0;i