static Pattern transitionLine = Pattern.compile("\\W*\"?" + "([^\"]+)"
+ "\"?" + "\\W*" + "->" + "\\W*" + "\"?" + "([^\"]+)" + "\"?"
+ "\\W*" + "(\\[" + "(.*)" + "\\])?");
public static ClusterHead loadTreeFromDot(File input) throws IOException{
Graph g = new Graph();
BufferedReader in = new BufferedReader(new FileReader(input));
String line;
HashMap<String, Node> nodes = new HashMap<String, Node>();
while ((line = in.readLine()) != null) {
if (line.matches("^\\W*#.*$"))
continue;
Matcher m = definitionLine.matcher(line);
if (m.matches()) {
Matcher m2 = transitionLine.matcher(line);
if (m2.matches()) {
String s1 = m2.group(1);
String s2 = m2.group(2);
// String s3 = m2.group(3);
nodes.put(s1, new Node(s1));
nodes.put(s2, new Node(s2));
} else {
String s1 = m.group(1);
nodes.put(s1, new Node(s1));
}
}
}
for (String k : nodes.keySet()) {
g.addNode(nodes.get(k));
}
in = new BufferedReader(new FileReader(input));
while ((line = in.readLine()) != null) {