| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,14 @@ | |||
| 1 | 1 | export default class Graph { | |
| 2 | 2 | /** | |
| 3 | - * @param isDirected {boolean} | ||
| 3 | + * @param {boolean} isDirected | ||
| 4 | 4 | */ | |
| 5 | 5 | constructor(isDirected = false) { | |
| 6 | 6 | this.vertices = {}; | |
| 7 | 7 | this.isDirected = isDirected; | |
| 8 | 8 | } | |
| 9 | 9 | ||
| 10 | 10 | /** | |
| 11 | - * @param newVertex {GraphVertex} | ||
| 11 | + * @param {GraphVertex} newVertex | ||
| 12 | 12 | * @returns {Graph} | |
| 13 | 13 | */ | |
| 14 | 14 | addVertex(newVertex) { | |
@@ -18,15 +18,15 @@ export default class Graph { | |||
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | /** | |
| 21 | - * @param vertexKey {string} | ||
| 21 | + * @param {string} vertexKey | ||
| 22 | 22 | * @returns GraphVertex | |
| 23 | 23 | */ | |
| 24 | 24 | getVertexByKey(vertexKey) { | |
| 25 | 25 | return this.vertices[vertexKey]; | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | 28 | /** | |
| 29 | - * @param edge {GraphEdge} | ||
| 29 | + * @param {GraphEdge} edge | ||
| 30 | 30 | * @returns {Graph} | |
| 31 | 31 | */ | |
| 32 | 32 | addEdge(edge) { | |
@@ -62,16 +62,16 @@ export default class Graph { | |||
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | 64 | /** | |
| 65 | - * @param startVertex {GraphVertex} | ||
| 66 | - * @param endVertex {GraphVertex} | ||
| 65 | + * @param {GraphVertex} startVertex | ||
| 66 | + * @param {GraphVertex} endVertex | ||
| 67 | 67 | */ | |
| 68 | 68 | findEdge(startVertex, endVertex) { | |
| 69 | 69 | const vertex = this.getVertexByKey(startVertex.getKey()); | |
| 70 | 70 | return vertex.findEdge(endVertex); | |
| 71 | 71 | } | |
| 72 | 72 | ||
| 73 | 73 | /** | |
| 74 | - * @param vertexKey {string} | ||
| 74 | + * @param {string} vertexKey | ||
| 75 | 75 | * @returns {GraphVertex} | |
| 76 | 76 | */ | |
| 77 | 77 | findVertexByKey(vertexKey) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | export default class GraphEdge { | |
| 2 | 2 | /** | |
| 3 | - * @param startVertex {GraphVertex} | ||
| 4 | - * @param endVertex {GraphVertex} | ||
| 5 | - * @param weight {number} | ||
| 3 | + * @param {GraphVertex} startVertex | ||
| 4 | + * @param {GraphVertex} endVertex | ||
| 5 | + * @param {number} [weight=1] | ||
| 6 | 6 | */ | |
| 7 | 7 | constructor(startVertex, endVertex, weight = 1) { | |
| 8 | 8 | this.startVertex = startVertex; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ export default class GraphVertex { | |||
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | 15 | /** | |
| 16 | - * @param edge {GraphEdge} | ||
| 16 | + * @param {GraphEdge} edge | ||
| 17 | 17 | * @returns {GraphVertex} | |
| 18 | 18 | */ | |
| 19 | 19 | addEdge(edge) { | |
@@ -22,6 +22,9 @@ export default class GraphVertex { | |||
| 22 | 22 | return this; | |
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | + /** | ||
| 26 | + * @returns {GraphVertex[]} | ||
| 27 | + */ | ||
| 25 | 28 | getNeighbors() { | |
| 26 | 29 | const edges = this.edges.toArray(); | |
| 27 | 30 | ||
@@ -35,7 +38,7 @@ export default class GraphVertex { | |||
| 35 | 38 | } | |
| 36 | 39 | ||
| 37 | 40 | /** | |
| 38 | - * @param requiredEdge {GraphEdge} | ||
| 41 | + * @param {GraphEdge} requiredEdge | ||
| 39 | 42 | * @returns {boolean} | |
| 40 | 43 | */ | |
| 41 | 44 | hasEdge(requiredEdge) { | |
@@ -47,7 +50,7 @@ export default class GraphVertex { | |||
| 47 | 50 | } | |
| 48 | 51 | ||
| 49 | 52 | /** | |
| 50 | - * @param vertex {GraphVertex} | ||
| 53 | + * @param {GraphVertex} vertex | ||
| 51 | 54 | * @returns {boolean} | |
| 52 | 55 | */ | |
| 53 | 56 | hasNeighbor(vertex) { | |
@@ -58,6 +61,10 @@ export default class GraphVertex { | |||
| 58 | 61 | return !!vertexNode; | |
| 59 | 62 | } | |
| 60 | 63 | ||
| 64 | + /** | ||
| 65 | + * @param {GraphVertex} vertex | ||
| 66 | + * @returns {(GraphEdge|null)} | ||
| 67 | + */ | ||
| 61 | 68 | findEdge(vertex) { | |
| 62 | 69 | const edgeFinder = (edge) => { | |
| 63 | 70 | return edge.startVertex === vertex || edge.endVertex === vertex; | |
@@ -76,7 +83,7 @@ export default class GraphVertex { | |||
| 76 | 83 | } | |
| 77 | 84 | ||
| 78 | 85 | /** | |
| 79 | - * @param callback {function} | ||
| 86 | + * @param {function} [callback] | ||
| 80 | 87 | * @returns {string} | |
| 81 | 88 | */ | |
| 82 | 89 | toString(callback) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments