more layout engines

This commit is contained in:
Timo Hocker
2020-04-28 11:26:21 +02:00
parent 6eb3dac397
commit da6c26e8e0
8 changed files with 24 additions and 2 deletions

View File

@ -17,6 +17,7 @@ export class Edge {
// eslint-disable-next-line @typescript-eslint/naming-convention
public toString (): string {
const attributes = [];
if (this.style)
attributes.push ({ name: 'style', value: this.style.toString () });
if (this.color)

View File

@ -14,6 +14,7 @@ export class Element {
public constructor (name: string, parent = '') {
const regex = /^[a-z_][a-z_0-9]+$/iu;
if (!regex.test (name))
throw new Error ('invalid name specified');
this.name = name;

View File

@ -1,4 +1,10 @@
export enum GraphLayouts {
neato= 'neato',
dot= 'dot'
neato = 'neato',
dot = 'dot',
circo = 'circo',
fdp = 'fdp',
sfdp = 'sfdp',
osage = 'osage',
twopi = 'twopi',
patchwork = 'patchwork'
}

View File

@ -20,6 +20,7 @@ export class Node extends Element {
const mapped_columns = this.table_contents
.map ((val) => `<td>${val.join ('</td><td>')}</td>`);
return `<table>\n <tr>${
mapped_columns.join ('</tr>\n <tr>')
}</tr>\n</table>`;
@ -28,6 +29,7 @@ export class Node extends Element {
// eslint-disable-next-line @typescript-eslint/naming-convention
public toString (): string {
const attributes = [];
if (this.label || this.is_table) {
attributes.push ({
name: 'label',
@ -51,6 +53,7 @@ export class Node extends Element {
'"',
'"'
];
return `${v.name}=${d[0]}${v.value}${d[1]}`;
})
.join (', ');