二维数据结构
作者:互联网
// var arr = []; // 一维数组
// var arr = [[], [], []] // 二维数组: 数组中的每一个元素都是一个数组
var arr = new Array(4);
for (var i = 0; i < arr.length; i++) {
arr[i] = new Array(8);
}
function Node(value) {
this.value = value;
this.neighbor = [];
}
var a = new Node("a");
var b = new Node("b");
var c = new Node("c");
var d = new Node("d");
var e = new Node("e");
var f = new Node("f");
a.neighbor.push(b);
a.neighbor.push(c);
a.neighbor.push(f);
b.neighbor.push(a);
b.neighbor.push(d);
b.neighbor.push(e);
c.neighbor.push(a);
d.neighbor.push(b);
e.neighbor.push(b);
总感觉缺点啥,等到顿悟了在优化一下吧
标签:Node,arr,push,二维,neighbor,var,new,数据结构 来源: https://blog.csdn.net/weixin_50221415/article/details/123218538