<Day8- 圖 graph>
//尚未完成 期末考後補齊
function Graph(){
let vertices = []
let adjList = new Dictionary()
this.addVertex = function(v){
vertices.push(v)
adjList.set(v, [])
}
this.addEdge = function(v, w){
adjList.set(v).push(w)
adjList.set(w).push(v)
}
//BFS
let initializeColor = function(){
let color = []
for (var i = 0; i < vertices.length; i++) {
color[vertices[i]] = 'white'
}
return color
}
}
參考資料: