创建随机树(或满足树属性的邻接矩阵)的好方法是什么?我目前有以下要返回的数据结构,但我想随机生成它。有什么建议么?
return [{
Source: "A1",
Target: "A2",
}, {
Source: "A2",
Target: "A3",
}, {
Source: "A1",
Target: "A4",
}, {
Source: "A4",
Target: "A6",
}, {
Source: "A4",
Target: "A7",
}, {
Source: "A3",
Target: "A8",
}, {
Source: "A3",
Target: "A5",
}];