Add Prim.

This commit is contained in:
Oleksii Trekhleb
2018-05-07 12:45:10 +03:00
parent 50df3bf717
commit cad8ccd9bb
9 changed files with 194 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
import LinkedList from '../linked-list/LinkedList';
export default class GraphVertex {
/**
* @param {*} value
*/
constructor(value) {
if (value === undefined) {
throw new Error('Graph vertex must have a value');
@@ -37,6 +40,13 @@ export default class GraphVertex {
return edges.map(neighborsConverter);
}
/**
* @return {GraphEdge[]}
*/
getEdges() {
return this.edges.toArray().map(linkedListNode => linkedListNode.value);
}
/**
* @param {GraphEdge} requiredEdge
* @returns {boolean}