(array2d = [])
| 25 | } |
| 26 | |
| 27 | set(array2d = []) { |
| 28 | this.nodes = []; |
| 29 | this.edges = []; |
| 30 | for (let i = 0; i < array2d.length; i++) { |
| 31 | this.addNode(i); |
| 32 | for (let j = 0; j < array2d.length; j++) { |
| 33 | const value = array2d[i][j]; |
| 34 | if (value) { |
| 35 | this.addEdge(i, j, this.isWeighted ? value : null); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | this.layout(); |
| 40 | super.set(); |
| 41 | } |
| 42 | |
| 43 | directed(isDirected = true) { |
| 44 | this.isDirected = isDirected; |