diff --git a/test/dfsAllPaths.1.approved.txt b/test/dfsAllPaths.1.approved.txt new file mode 100644 index 00000000..e69de29b diff --git a/test/dfsAllPaths.2.approved.txt b/test/dfsAllPaths.2.approved.txt new file mode 100644 index 00000000..19b0cf37 --- /dev/null +++ b/test/dfsAllPaths.2.approved.txt @@ -0,0 +1,17 @@ +[ + [ + "f", + "e", + "d", + "c", + "b", + "a" + ], + [ + "f", + "e", + "d", + "c", + "a" + ] +] diff --git a/test/dfsAllPaths.ts b/test/dfsAllPaths.ts new file mode 100644 index 00000000..49c54baf --- /dev/null +++ b/test/dfsAllPaths.ts @@ -0,0 +1,41 @@ +import { MultiGraph } from "graphology"; +import { dfsAllPaths } from "../src/graphUtils"; +import { testGraph } from "./testUtils"; + +require("approvals").mocha(); + +function verify(sol: any) { + this.verifyAsJSON(sol, { + reporters: ["tortoisemerge"], + appendEOL: true, + normalizeLineEndingsTo: "\r\n", + }); +} + +describe("dfsAllPaths", function () { + it("1", function () { + const g = new MultiGraph(); + g.addNode("A"); + g.addNode("B"); + + g.addEdge("A", "B", { dir: "up", field: "up" }); + + const paths = dfsAllPaths(g, "A"); + + verify.call(this, paths); + // this.verifyAsJSON(paths, { + // reporters: ["tortoisemerge"], + // appendEOL: true, + // normalizeLineEndingsTo: "\r\n", + // }); + }); + + it("2", function () { + const g = testGraph(); + const paths = dfsAllPaths(g, "a"); + + verify.call(this, paths); + }); +}); + +export {}; diff --git a/test/getReflexiveClosure.1.approved.txt b/test/getReflexiveClosure.1.approved.txt new file mode 100644 index 00000000..94165c5d --- /dev/null +++ b/test/getReflexiveClosure.1.approved.txt @@ -0,0 +1,28 @@ +{ + "allowSelfLoops": true, + "attributes": {}, + "directedSelfLoopCount": 0, + "directedSize": 2, + "edges": { + "0. (A)->(B)": { + "dir": "up", + "field": "up" + }, + "0. (B)->(A)": { + "dir": "down", + "field": "down" + } + }, + "implementation": "graphology", + "multi": true, + "nodes": { + "A": {}, + "B": {} + }, + "order": 2, + "selfLoopCount": 0, + "size": 2, + "type": "mixed", + "undirectedSelfLoopCount": 0, + "undirectedSize": 0 +} diff --git a/test/getReflexiveClosure.ts b/test/getReflexiveClosure.ts new file mode 100644 index 00000000..cbf0b6e7 --- /dev/null +++ b/test/getReflexiveClosure.ts @@ -0,0 +1,25 @@ +import { MultiGraph } from "graphology"; +import { getReflexiveClosure } from "../src/graphUtils"; +import { testHiers, verify } from "./testUtils"; + +require("approvals").mocha(); + +describe("getReflexiveClosure", function () { + it("1", async function () { + const userHiers = testHiers(); + + const g = new MultiGraph(); + g.addNode("A"); + g.addNode("B"); + + g.addEdge("A", "B", { dir: "up", field: "up" }); + + const closed = getReflexiveClosure(g, userHiers); + + const gStr = closed.inspect(); + + verify.call(this, gStr); + }); +}); + +export {};