首页 > 解决方案 > 有没有办法计算图中特定节点周围的集群?

问题描述

我有一个图表,已经计算了它的向量的 PageRank,现在想计算具有最高 PageRank 的 20 个节点的集群。到目前为止,我正在使用图形工具和 networkx。

有没有一种已知且实​​用的方法来做到这一点?

标签: pythoncluster-analysisnetworkxpartitioninggraph-tool

解决方案


由于您的问题有点模糊,假设您正在寻找一种方法来获取文档集合的中央集群,我将尝试回答。在这张图片上,中心的 5 个项目集群将是[B,C,E,F,D]

网页排名

在伪代码中稍微有点pytonic,会是这样的吗?

n = 0
center = node.with_highest_rank()
cluster = {center: {}}
current_connexion = center
while n<20:
    main_connexion = node.citing_node_with_higher_rank(current_connexion).filter(not in cluster.keys())
    cluster["center"] = {main_connexion: {}}
    n += 1
    # if ranks are higher on connexion level 2 than the next node on level 1, look down
    if node.citing_node_with_higher_rank(main_connexion).rank > node.citing_node_with_higher_rank(current_connexion).rank:
        current_connexion = main_connexion    

建议:在堆栈溢出时,公众通常是开发人员。开发人员需要具体的用例、具体的代码和精确的定义。如果您有更一般的理论/科学问题(通常,这里是图论),请查看其他社区,例如计算机科学


推荐阅读