From 2e34757a1a749ade39258e5224ce494a7d25000c Mon Sep 17 00:00:00 2001
From: Timo Hocker <t-hocker@web.de>
Date: Mon, 27 Apr 2020 16:03:48 +0200
Subject: [PATCH] return graph and node names

---
 lib/Graph.ts | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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 {