class Map {
constructor() {
this.items = {};
}
has(key) {
return this.items.hasOwnProperty(key);
}
set(key, value) {
this.items[key] = value;
}
remove(key) {
if (!this.has(key)) { return false };
delete this.items[key];
}
get(key) {
return this.has(key) ? this.items[key] : undefined;
}
keys() {
return Object.keys(this.items);
}
values() {
return Object.values(this.items);
}
size() {
return this.keys().length;
}
clear() {
this.items = {};
}
}
function Graph() {
this.vertexes = []
this.edges = new Map()
Graph.prototype.addVertexes = function(v) {
this.vertexes.push(v)
thise.edges.set(v, [])
}
Graph.prototype.addEdges = function(v1, v2) {
this.edges.get(v1).push(v2)
this.edges.get(v2).push(v1)
}
Graph.initColor = function() {
let colors = []
for(vertex of vertexes) {
colors[color] = 'white'
}
return colors
}
}
console