src/main/java/org/nyu/crypto/service/FrequencyDiGraphGenerator.java
public void generateFrequencyDigraph(int length) {

        String[] messages = new String[length];
        for (int i =0; i<length; i++) {
            messages[i] = messageGenerator.generateMessage();
        }
        double[][] freq = digraphService.createFrequencyDigraph(messages);
        /*ClassLoader classLoader = getClass().getClassLoader();
        File file = new File(classLoader.getResource("resources").getFile() + "/frequency_digraph.txt");*/
        try{
            DecimalFormat df = new DecimalFormat("#.#####");
            df.setRoundingMode(RoundingMode.CEILING);
            /*File file = new File("resources/frequency_digraph1.txt");
            if (file.createNewFile()) {
                System.out.println("File is created!");
            } else {
                System.out.println("File already exists.");
            }
            FileWriter fw = new FileWriter(file);
            */for (int row = 0; row < 27; row++) {
                for (int col = 0; col < 27; col++) {
                    double val = freq[row][col];
                    System.out.print(df.format(freq[row][col]) + " ");
                }
                System.out.println();
            }
            //fw.close();
        } catch(Exception e) {
            e.printStackTrace();
        }
        //return digraphService.createFrequencyDigraph(messages);
    }
/**
     * This function needs the number of messages to calculate the digraph
     * @param length
     * @return
     */
This function needs the number of messages to calculate the digraph
@param length
@return
This function needs the number of messages to calculate the digraph @param length @return
public void generateFrequencyDigraph(int length) {
        String[] messages = new String[length];
        for (int i =0; i<length; i++) {
            messages[i] = messageGenerator.generateMessage();
        }
        double[][] freq = digraphService.createFrequencyDigraph(messages);
        /*ClassLoader classLoader = getClass().getClassLoader();
        File file = new File(classLoader.getResource("resources").getFile() + "/frequency_digraph.txt");*/
        try{
            DecimalFormat df = new DecimalFormat("#.#####");
            df.setRoundingMode(RoundingMode.CEILING);
            /*File file = new File("resources/frequency_digraph1.txt");
            if (file.createNewFile()) {
                System.out.println("File is created!");
            } else {
                System.out.println("File already exists.");
            }
            FileWriter fw = new FileWriter(file);
            */for (int row = 0; row < 27; row++) {
                for (int col = 0; col < 27; col++) {
                    double val = freq[row][col];
                    System.out.print(df.format(freq[row][col]) + " ");
                }
                System.out.println();
            }
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
public void generateFrequencyDigraph ( int length ) { String [ ] messages = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { messages [ i ] = messageGenerator . generateMessage ( ) ; } double [ ] [ ] freq = digraphService . createFrequencyDigraph ( messages ) ; /*ClassLoader classLoader = getClass().getClassLoader();
        File file = new File(classLoader.getResource("resources").getFile() + "/frequency_digraph.txt");*/ try { DecimalFormat df = new DecimalFormat ( "#.#####" ) ; df . setRoundingMode ( RoundingMode . CEILING ) ; /*File file = new File("resources/frequency_digraph1.txt");
            if (file.createNewFile()) {
                System.out.println("File is created!");
            } else {
                System.out.println("File already exists.");
            }
            FileWriter fw = new FileWriter(file);
            */ for ( int row = 0 ; row < 27 ; row ++ ) { for ( int col = 0 ; col < 27 ; col ++ ) { double val = freq [ row ] [ col ] ; System . out . print ( df . format ( freq [ row ] [ col ] ) + " " ) ; } System . out . println ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } }
This function needs the number of messages to calculate the digraph
 @param length
 @return
This function needs the number of messages to calculate the digraph @param length @return
//fw.close(); //return digraphService.createFrequencyDigraph(messages);