Stream: allow edge attributes, autoclose nodes

This commit is contained in:
Timo Hocker
2020-06-05 11:46:58 +02:00
parent 920dc74d9c
commit b11b2f5f2b
5 changed files with 61 additions and 26 deletions

View File

@ -2,7 +2,7 @@
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of graphviz-builder which is released under MIT.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, May 2020
* Created by Timo Hocker <timo@scode.ovh>, June 2020
*/
import test from 'ava';
@ -37,6 +37,7 @@ const complex = `digraph foo {
foo_baz [label = "baz"]
foo_foo [label = "foo"]
foo_foo -> foo_baz
foo_foo -> foo_baz_asd [label = "edge attr"]
}
`;
@ -76,20 +77,19 @@ test ('complex stream graph', (t) => new Promise ((resolve) => {
stream.attributes ({ color: Color.gray, style: 'dotted' });
stream.end_graph ();
stream.end_graph ();
stream.create_node ('asd');
const asd = stream.create_node ('asd');
stream.attributes ({ label: 'asd' });
stream.end_node ();
stream.create_node ('test');
stream.attributes ({ style: 'bold', color: Color.gray });
stream.end_node ();
stream.end_graph ();
stream.create_node ('baz');
const baz = stream.create_node ('baz');
stream.attributes ({ label: 'baz' });
stream.end_node ();
stream.create_node ('foo');
const foo = stream.create_node ('foo');
stream.attributes ({ label: 'foo' });
stream.end_node ();
stream.create_edge (`${stream.path}_foo`, `${stream.path}_baz`);
stream.create_edge (foo, baz);
stream.create_edge (foo, asd);
stream.attributes ({ label: 'edge attr' });
stream.end_graph ();
stream.end ();
}));