Add bidi search

- Added g3 graph and one test
This commit is contained in:
mindfulminun committed 2022-11-14 03:49:14 -06:00
1 parent 14515278df
commit b83668ef07
3 files changed
+149 -12

No files matched your search

+14 -2
View File
@@ -1,7 +1,7 @@
import { g1, g2 } from '../tools/graph/_graph-samples.ts'
import { g1, g2, g3 } from '../tools/graph/_graph-samples.ts'
import { GraphSolver } from '../tools/graph/graph-solver.ts'
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"
import { Path } from "../tools/graph/graph.ts";
import { Path } from "../tools/graph/graph.ts"
// TODO: Add more tests!
@@ -39,6 +39,18 @@ Deno.test('GraphSolver::DFS w/ g1', () => {
)
})
Deno.test('GraphSolver::bidi', () => {
const G = g3()
const solver = new GraphSolver(G)
const path = solver.bidi(G.vertices.get('A')!, G.vertices.get('E')!)
assertPathsEqual(
path,
'ABCDE'.split(''),
'AB-BC-CD-DE'.split('-')
)
})
function assertPathsEqual<vData, eData>(
path: Path<vData, eData> | null | undefined,
expectedV: string[],