Spaces:
Sleeping
Sleeping
| /** | |
| * Copyright (c) 2017~2019, OBCon Inc. | |
| * All rights reserved. | |
| */ | |
| /** | |
| * @file | |
| * @copyright 2017~2019, OBCon Inc. | |
| * @author gye hyun james kim [pnuskgh@gmail.com] | |
| */ | |
| class VERTEX { //--- 정점 (노드) | |
| constructor(data) { | |
| this.data = data; | |
| this.degree = 0; //--- 챠수 : 정점에 연결된 간선의 수 | |
| } | |
| } | |
| class EDGE { //--- 간선 | |
| constructor(left, right, weight=0, isDirected=true) { | |
| this.left = left; | |
| this.right = right; | |
| this.weight = weight; //--- 가중치 | |
| this.isDirected = isDirected; //--- true. 방향성 있음 (left -> right) | |
| } | |
| } | |
| class Graph { //--- FIFO (First In First Out) | |
| constructor(isDirected=true) { | |
| this.vertexs = []; | |
| this.edges = []; | |
| this.isDirected = isDirected; //--- true. 방향성 있음 | |
| } | |
| addVertex(vertex) { | |
| // this.vertexs.push(new VERTEX(data)); | |
| } | |
| addEdge(vertex1, vertex2, weight=0) { | |
| } | |
| removeVertex(vertex) { | |
| } | |
| removeEdge(vertex1, vertex2) { | |
| } | |
| //--- BFS (Breadth-First search, 너비 우선 검색) | |
| traverseBFS(vertex, callback) { | |
| } | |
| //--- DFS (Depth-First search, 깊이 우선 검색) | |
| traverseDFS(vertex, callback) { | |
| } | |
| //--- 다익스트라 알고리즘 | |
| //--- 가중치를 고려하여 최단 경로 계산 | |
| Dijkstra(source) { | |
| } | |
| //--- 위상 정렬 | |
| topologicalSortUtil(v, visited, stack) { | |
| } | |
| } | |
| module.exports = Graph; | |