我对编程知之甚少,因此这是一个不知道从哪里寻找答案的情况。我想要创建如下所示的数据结构:
vertexTopology = {vertexIndex: {clusterIndexes: intersection point}}
然而,实际上集群索引是一个由集群索引组成的集合。因此,现在我真正拥有的是:
vertexTopology = {5: [[(1, 2, 3), intx_1],
[(2, 3, 4), intx_2]]
6: [[(1, 2, 3), intx_3]]
...}
我该如何创建一个与每个集群集合和其顶点索引相关联的唯一索引?类似于:
vertexTopology = {5: {index associated with (1, 2, 3) AND vertex 5, intx_1},
{index associated with (2, 3, 4) AND vertex 5, intx_2},
6: {index associated with (1, 2, 3) AND vertex 6, intx_3}]
...}
我不确定使用字典是否最好实现我想做的事情,因此非常欢迎任何建议!
下面是一个四路口的图片,这样你就能想象一下我正在处理什么。
((1,2,3), 5)
本身就是一个可行的索引;它简单、可哈希、可排序等等。或者你确实需要一个整数? - DSMfrozenset
也是如此,甚至更好,因为然后您就不必担心顺序问题。] - DSM