繁体   English   中英

在公共节点列表中找到边缘是否有更好的功能?

[英]Is there a better function for finding edges on a list of common nodes?

我有一个节点列表,每个节点都测量了其他点的wifi场强。 列表将采用以下形式:

 RSSI_list = [[node4, node3, RSSI], [node7, node5, RSSI]] #etc (it will be more populated)

可以认为RSSI等于估计的距离,因为它将被我记录的一些经验数据内插/外推的值替换。

我想找到并“映射”所有点相互之间的位置,这样我就可以计算出它们之间的角度。

为此,我研究了使用networkx ,它提供了以下功能:

aGraph.add_nodes_from(aListOfNodes)   # Add all the nodes from the list, aListOfNodes
aGraph.add_edge(aNode1, aNode2) # creates an edge from aNode1 to aNode2

edgeData = {"weight": 42}      # a dictionary with only one entry
g.add_edge(nodeA, nodeB, edgeData)   #create the edge with the given data dictionary

这将允许我使用我的列表中的内容。 我想要一些允许我添加节点对的东西,并且会自动链接末端很常见的对。

在我进一步向下看之前,networkx的查询行是否有更好的功能在另一个python模块中可以做得更好?

networkx将完全符合您的要求:

g = nx.Graph()

for a, b , w in RSSI_list:
    g.add_edge(a, b, {'weight': w})

然后,您可以通过遍历图表获得所需的一切。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM