diff --git a/lib/Graph.ts b/lib/Graph.ts index a09399c..399441f 100644 --- a/lib/Graph.ts +++ b/lib/Graph.ts @@ -46,24 +46,26 @@ export class Graph extends Element { .replace (/^\s+$/gmu, ''); } - public add_node (constructor: ((g: Node) => void) | string): void { + public add_node (constructor: ((g: Node) => void) | string): string { if (typeof constructor === 'string') { this.nodes.push (new Node (constructor, this.full_name, constructor)); - return; + return this.nodes[this.nodes.length - 1].full_name; } const node = new Node ('unnamed', this.full_name); constructor (node); this.nodes.push (node); + return node.full_name; } - public add_graph (constructor: ((g: Graph) => void) | string): void { + public add_graph (constructor: ((g: Graph) => void) | string): string { if (typeof constructor === 'string') { this.children.push (new Graph (constructor, this.full_name)); - return; + return this.children[this.children.length - 1].full_name; } const graph = new Graph ('unnamed', this.full_name); constructor (graph); this.children.push (graph); + return graph.full_name; } public add_edge (origin: string, target: string): void {