admin管理员组文章数量:1355570
Suppose a number of trees among which we have the following tree. Tree configuration's is represented by 2 lists arranged as tuples representing tree edge's:
ss-pair=[(1, 2), (2, 3), (3, 4), (4, 5), (8, 9), (9, 10), (11, 12), (12, 13), (13, 14), (14, 15)]
ts-pair=[(4, 9), (6, 11),(8, 13)]
What is required is to find the direct and indirect links between the two lists.
By examining the two lists, it can be seen that ts-pair edge (6,11) is a direct link since node 6 DOES NOT APPEAR in the ss-pair list although node 11 is present, while (4, 9) and (8, 13) edges are indirect links, nodes 4, 8, 9 and 13 are in ss-pair.
Expected result should be:
direct-link=[(6, 11)]
indirect-link=[(4, 9), (8, 13)]
The question is: how to get the expected result and generalize the code for any tree configuration ?
本文标签: pythonDirect and indirect connexion in a treeStack Overflow
版权声明:本文标题:python - Direct and indirect connexion in a tree - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743981883a2571115.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论