Added graphing

This commit is contained in:
2017-05-23 11:35:28 +02:00
parent adf6391c84
commit e6e2521112
2 changed files with 41 additions and 5 deletions
+33
View File
@@ -0,0 +1,33 @@
package com.imegumii;
/**
* Created by kenny on 18-5-2017.
*/
public class Graph {
public static String generateGraphString(Automata<String> a)
{
String text = "digraph finite_state_machine {\nrankdir=LR;\nsize=\"8,5\";\nnode [shape = doublecircle];";
for(String s : a.eindStates){
text += s + " ";
}
text += ";\nnode [shape = circle];\n";
for(Transition<String> t : a.transistions)
{
String s = "";
if(t.symbol == Transition.EPSILON)
s = "$";
else
s = t.symbol + "";
text += t.vanState + " -> " + t.naarState + " [ label = \"" + s + "\"];\n";
}
text += "}";
return text;
}
}
+8 -5
View File
@@ -105,13 +105,16 @@ public class Main {
RegExp expr3 = new RegExp("c");
RegExp expr4 = new RegExp("d");
RegExp expr5 = expr1.ster();
RegExp expr6 = expr3.plus();
RegExp expr5 = expr1.of(expr2);
RegExp expr6 = expr3.of(expr4);
RegExp expr7 = expr5.punt(expr6);
NDFA<String> test = ThompsonConverter.Convert(expr7);
test.printTransitions();
RegExp expr8 = expr7.ster();
NDFA<String> test = ThompsonConverter.Convert(expr8);
System.out.println(Graph.generateGraphString(test));
}
public static void Practicum4() {
@@ -146,7 +149,7 @@ public class Main {
// testreg.testLanguage();
System.out.println("Zo moet het dus, nu onze beurt.");
// System.out.println("Zo moet het dus, nu onze beurt.");
// Practicum1();