December 02, 2020
실제로,
Trees
자료구조가 포함되어있고, 그 안에는Linked List
가 포함되어있다고 함..
class Graph {
constructor(){
this.vertexes = {};
}
addVertex(vertex){
this.vertexes[vertex] = {value : vertex};
}
addEdge(vertex1, vertex2, weight){
this.vertexes[vertex1][vertex2] = weight;
this.vertexes[vertex2][vertex1] = weight;
}
}
const graph = new Graph;
graph.addVertex('일산서구')
graph.addVertex('일산동구')
graph.addVertex('덕양구')
graph.addEdge('일산서구', '일산동구', 1)
graph.addEdge('일산서구', '덕양구', 1)
graph.addEdge('일산동구', '덕양구', 2)
ex) A지역에서 B지역까지의 거리