Repository navigation
Input Output
Input/Output files consist of .dot files, which contain the following:
- Initial initiation line
- Middle lines consisting of node and edge declaration and their respective weights (A (
- End line
Input .dot files will be in standard text. Therefore, rules must be applied to capture .dot file elements and to check whether they are in a valid format. These rules include:
- Lines for the .dot input file must be exactly matching as declared regex
- Specifically, lines must match any existing tab, space, symbols that are declared in regex
- Application operation will abort otherwise
Regex matching includes:
-
First line must match the format (
digraph "{NAME}" {) -
Middle lines must match the format (
{NODE-NAME} [Weight=x]; -
Last line must match the format (
}) -
Special case containing details of the graph currently will be ignored
-
In general, Java constants have been used to refer to the regex specifics mentioned above:
private static final String RGX_NODE = "\t([a-zA-Z0-9]+)\t \\[Weight=([0-9]+)];";
private static final String RGX_EDGE = "\t([a-zA-Z0-9]+) -> ([a-zA-Z0-9]+)\t \\[Weight=([0-9]+)];";
private static final String RGX_FIRST_LINE = "digraph \".*\" \\{";
private static final String RGX_STARTGRAPH_LINE = "\tgraph \\[.*";
private static final String RGX_ENDGRAPH_LINE = "\t\\];";I/O command line consist of getting input arguments via the command line. This in it-self is not hard, though the majority of the code goes into checking/validating and parsing the input correctly so that the other classes can use the input given by the user. Initially, the input arguments from main() are passed to our method validateAndParseInput(), which is taken care of by the IO object.
This method primarily focuses on:
-
Checking and ensuring that the number of processors on your computer do not exceed the input amount
-
Checking to see if the input and output paths are relative or absolute paths and passing those paths adequately to the IO object for reading and writing.
-
Checking to see if file extensions have been given, in the case that they are not file extensions are added
-
Checking to see if the arguments are in the right order and the usage of the Jar file is correct
-
Generally -> To get the user command line + to parse into separate sections for evaluation:
File parentFolder = file.getParentFile();
if(parentFolder != null){
parentPath = parentFolder.getAbsolutePath();
}
String[] fileNameSplit = file.getName().split("\\.");
nameOfInputFile = parentPath + "/" + file.getName();
nameOfOutputFile = fileNameSplit[0] + "-output.dot";
nameOfOutputFile = parentPath + "/" + nameOfOutputFile;