mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Add Prim.
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user