Added graphing

This commit is contained in:
2017-05-23 11:35:35 +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;
}
}