Question: Your program should accept two command ine arguments Argument 1 is an ingut file name, and argument 2 is an output tie name Your program
Your program should accept two command ine arguments Argument 1 is an ingut file name, and argument 2 is an output tie name Your program will first construct an undirected gaph G bned on parameters specified in the nput. The graph will represent a muli-dimensional space, and the irst input line specifies the number of dimensions N. Your program is only requined to handle the canes N 2 and N-3, but you can earn estra credt if your program abo workes for arbaryNs12. The second ingut line and each vertex can be considered as a tuple X-- where Ofor each dimension 1sisN You may assume that the number of vertioes will be at most 4096 Next there will be one or more additional input ines, and each ch ngut ine specifies some offsets 4; ?? that will be used to add unweghted edges tothegraph these ofhetsls,?","J can be considered as a vector that spectes the pattern of e ges that be added. Mathematically, graph G will have an edge between vertex Vvwi) and vertex W (wthere exists any permutation of the dimensions(.-N)suchthatw":do for each dimension 1 sjSN. The graghs G thar comrespond to some example input tiles ane shown below 01.11.2 02.12.2 Hint: you can arrange the list of vertices linearly uning owmqjor ordler or column-major order Then you can use a one-dimensional array rather than a muti-dmensional aay After your program reads the inputs and builds graph &it shouid print a line that shows the number of vertices and the number of edges in graph G Next your program wll use breadth-first seanch to compute the length of each shortest path (based on numer of edges) from each root or start vertex v each destination vertex w Alternatively, you may use Diykstra's algorithm to compube these shortest paths Finally, the remaining output lines will show the number of shomepats har haveeach finite lengh Each of these output lines displays a distinct finite pestive path distance [in ascending ordert, along with the number of vertex pairs (V. W) such that the shortest path from V to W ha exactly that length (number of edge). Here are the output files that cormespond to the previously ven input Sles. For esample, the graph G constructed for inputo.tt has 9 vertices and 12 edges R also has 24 vertex pairs at dstane 1,28vertex parit distance 2, 16vete par, at Land 4 vertex pars at distance 4 9 12 1 24 2 28 3 16 1 28 4 20 Map vertices , 2,) into the range from 0 t L1 2- -Check all permutanions more efficiently via sorting. Check pesitives and negative differences together using absolute value. Your program should accept two command ine arguments Argument 1 is an ingut file name, and argument 2 is an output tie name Your program will first construct an undirected gaph G bned on parameters specified in the nput. The graph will represent a muli-dimensional space, and the irst input line specifies the number of dimensions N. Your program is only requined to handle the canes N 2 and N-3, but you can earn estra credt if your program abo workes for arbaryNs12. The second ingut line and each vertex can be considered as a tuple X-- where Ofor each dimension 1sisN You may assume that the number of vertioes will be at most 4096 Next there will be one or more additional input ines, and each ch ngut ine specifies some offsets 4; ?? that will be used to add unweghted edges tothegraph these ofhetsls,?","J can be considered as a vector that spectes the pattern of e ges that be added. Mathematically, graph G will have an edge between vertex Vvwi) and vertex W (wthere exists any permutation of the dimensions(.-N)suchthatw":do for each dimension 1 sjSN. The graghs G thar comrespond to some example input tiles ane shown below 01.11.2 02.12.2 Hint: you can arrange the list of vertices linearly uning owmqjor ordler or column-major order Then you can use a one-dimensional array rather than a muti-dmensional aay After your program reads the inputs and builds graph &it shouid print a line that shows the number of vertices and the number of edges in graph G Next your program wll use breadth-first seanch to compute the length of each shortest path (based on numer of edges) from each root or start vertex v each destination vertex w Alternatively, you may use Diykstra's algorithm to compube these shortest paths Finally, the remaining output lines will show the number of shomepats har haveeach finite lengh Each of these output lines displays a distinct finite pestive path distance [in ascending ordert, along with the number of vertex pairs (V. W) such that the shortest path from V to W ha exactly that length (number of edge). Here are the output files that cormespond to the previously ven input Sles. For esample, the graph G constructed for inputo.tt has 9 vertices and 12 edges R also has 24 vertex pairs at dstane 1,28vertex parit distance 2, 16vete par, at Land 4 vertex pars at distance 4 9 12 1 24 2 28 3 16 1 28 4 20 Map vertices , 2,) into the range from 0 t L1 2- -Check all permutanions more efficiently via sorting. Check pesitives and negative differences together using absolute value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
