mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Implemented M Coloring Problem (#1562)
* Implemented M Coloring Problem
* Implemented M Coloring Problem
* Switch to a functional approach instead of class-based.
Use proper JSDoc comments.
Refine the comments and remove redundancies.
* Updated Documentation in README.md
* Proper JSDoc comment
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
23
Backtracking/tests/MColoringProblem.test.js
Normal file
23
Backtracking/tests/MColoringProblem.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { mColoring } from '../MColoringProblem';
|
||||
|
||||
describe('MColoringProblem', () => {
|
||||
it('should color a triangle with 3 colors', () => {
|
||||
const graph = [
|
||||
[0, 1, 1],
|
||||
[1, 0, 1],
|
||||
[1, 1, 0]
|
||||
];
|
||||
const solution = mColoring(graph, 3);
|
||||
expect(solution).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should not color a triangle with 2 colors', () => {
|
||||
const graph = [
|
||||
[0, 1, 1],
|
||||
[1, 0, 1],
|
||||
[1, 1, 0]
|
||||
];
|
||||
const solution = mColoring(graph, 2);
|
||||
expect(solution).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user