Skip to content

Commit

Permalink
fix parsing cluster subgraph (fix #112)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Niederhauser <ghuder5@gmx.ch>
  • Loading branch information
nidi3 committed May 17, 2019
1 parent 239d37a commit f68fd87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ private MutableGraph subgraph(boolean directed) {
if (token.type == SUBGRAPH) {
nextToken();
if (token.type == ID) {
sub.setName(label(token).toString());
final String name = label(token).toString();
if (name.startsWith("cluster_")) {
sub.setName(name.substring(8));
sub.setCluster(true);
} else {
sub.setName(name);
}
nextToken();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,10 @@ void multiLinkAttr() throws IOException {
assertEquals(mutGraph().add(a, b),
Parser.read("graph { edge[color=red, width=1] a -- b edge[color=blue, a=b] a -- b }"));
}

@Test
void cluster() throws IOException {
assertEquals(mutGraph().add(mutGraph("sub").setCluster(true)),
Parser.read("graph { subgraph cluster_sub {} }"));
}
}

0 comments on commit f68fd87

Please sign in to comment.