将x,y转换为图
我有一个坐标的元组[0,1],[1,2],[1,3],[2,4],[4,5],[3,4]
和我想将这些坐标转换为用于BFS中使用的图表,以便每个顶点都保留其邻居的列表。
所以这样的事情
0 = [1]
1 = [0, 2, 3]
2 = [1, 4]
I've a tuple of coordinates [0, 1], [1, 2], [1, 3], [2, 4], [4, 5], [3, 4]
and I want to convert these coordinates into a graph to be used in BFS so each vertex holds a list of its neighbor.
So something like this,
0 = [1]
1 = [0, 2, 3]
2 = [1, 4]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
快速而肮脏:
Quick and dirty: