return graph and node names
This commit is contained in:
parent
430314c9a4
commit
2e34757a1a
10
lib/Graph.ts
10
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user