Skip to content

Commit cd13ab2

Browse files
authored
Merge pull request #49 from GordonSmith/SFDP
feat(sfdp): Add SFDP support
2 parents 65181db + c829af0 commit cd13ab2

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ _layoutEngine_ supports the following options:
140140
* circo
141141
* dot (default)
142142
* fdp
143+
* sfdp
143144
* neato
144145
* osage
145146
* patchwork
@@ -191,7 +192,11 @@ Convenience function that performs **dot** layout, is equivalent to `layout(dotS
191192

192193
<a name="fdp" href="#fdp">#</a> **fdp**(_dotSource_[, _outputFormat_][, _ext_]) · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/graphviz.ts "Source")
193194

194-
Convenience function that performs **circo** layout, is equivalent to `layout(dotSource, outputFormat, "fdp");`.
195+
Convenience function that performs **fdp** layout, is equivalent to `layout(dotSource, outputFormat, "fdp");`.
196+
197+
<a name="sfdp" href="#sfdp">#</a> **sfdp**(_dotSource_[, _outputFormat_][, _ext_]) · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/graphviz.ts "Source")
198+
199+
Convenience function that performs **sfdp** layout, is equivalent to `layout(dotSource, outputFormat, "sfdp");`.
195200

196201
<a name="neato" href="#neato">#</a> **neato**(_dotSource_[, _outputFormat_][, _ext_]) · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/graphviz.ts "Source")
197202

src/__tests__/graphviz.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ describe("graphviz", function () {
9898
expect(true).to.be.false;
9999
});
100100
});
101+
it("sfdp", function () {
102+
return graphviz.sfdp(dot, "svg").then(svg => {
103+
expect(svg).to.be.a("string");
104+
expect(svg).to.not.be.empty;
105+
}).catch(e => {
106+
expect(true).to.be.false;
107+
});
108+
});
101109
it("neato", function () {
102110
return graphviz.neato(dot, "svg").then(svg => {
103111
expect(svg).to.be.a("string");
@@ -160,6 +168,13 @@ describe("graphvizSync", function () {
160168
expect(svg).to.be.a("string");
161169
expect(svg).to.not.be.empty;
162170
});
171+
it("sfdp", function () {
172+
const svg = gvSync.sfdp(dot, "svg");
173+
expect(svg).to.be.a("string");
174+
expect(svg).to.not.be.empty;
175+
const svg2 = gvSync.fdp(dot, "svg");
176+
expect(svg).to.not.equal(svg2);
177+
});
163178
it("neato", function () {
164179
const svg = gvSync.neato(dot, "svg");
165180
expect(svg).to.be.a("string");

src/graphviz.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as graphvizlib from "../build/graphviz/graphvizlib/graphvizlib";
33
import { loadWasm } from "./util";
44

55
type Format = "svg" | "dot" | "json" | "dot_json" | "xdot_json" | "plain" | "plain-ext";
6-
type Engine = "circo" | "dot" | "fdp" | "neato" | "osage" | "patchwork" | "twopi";
6+
type Engine = "circo" | "dot" | "fdp" | "sfdp" | "neato" | "osage" | "patchwork" | "twopi";
77

88
interface Image {
99
path: string;
@@ -69,6 +69,9 @@ export const graphviz = {
6969
fdp(dotSource: string, outputFormat: Format = "svg", ext?: Ext): Promise<string> {
7070
return this.layout(dotSource, outputFormat, "fdp", ext);
7171
},
72+
sfdp(dotSource: string, outputFormat: Format = "svg", ext?: Ext): Promise<string> {
73+
return this.layout(dotSource, outputFormat, "sfdp", ext);
74+
},
7275
neato(dotSource: string, outputFormat: Format = "svg", ext?: Ext): Promise<string> {
7376
return this.layout(dotSource, outputFormat, "neato", ext);
7477
},
@@ -112,6 +115,10 @@ export class GraphvizSync {
112115
return this.layout(dotSource, outputFormat, "fdp", ext);
113116
}
114117

118+
sfdp(dotSource: string, outputFormat: Format = "svg", ext?: Ext): string {
119+
return this.layout(dotSource, outputFormat, "sfdp", ext);
120+
}
121+
115122
neato(dotSource: string, outputFormat: Format = "svg", ext?: Ext): string {
116123
return this.layout(dotSource, outputFormat, "neato", ext);
117124
}

0 commit comments

Comments
 (0)