python - 有没有办法计算图中特定节点周围的集群?
问题描述
我有一个图表,已经计算了它的向量的 PageRank,现在想计算具有最高 PageRank 的 20 个节点的集群。到目前为止,我正在使用图形工具和 networkx。
有没有一种已知且实用的方法来做到这一点?
解决方案
由于您的问题有点模糊,假设您正在寻找一种方法来获取文档集合的中央集群,我将尝试回答。在这张图片上,中心的 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
建议:在堆栈溢出时,公众通常是开发人员。开发人员需要具体的用例、具体的代码和精确的定义。如果您有更一般的理论/科学问题(通常,这里是图论),请查看其他社区,例如计算机科学
推荐阅读
- file-upload - 在 Flutter 中通过多部分 post 获取数据上传到服务器的进度
- java - 如何避免selenium webdriver java中的空指针异常
- angular - 您如何允许 Angular Material Table 处理不同的数据源?
- ios - 当应用程序进入后台时如何显示警告警报?
- java - JPQL 中等效的 UTL_RAW.BIT_OR
- php - 网站读取 diff raspberry pi 上的文件并根据变量显示值
- javascript - 跟踪 Pdf.js 中 EventBus 何时不为空
- onnx - 输入张量无法重塑为请求的形状
- .net-core - 从 .net core web api 使用 WSDL soap。从肥皂客户端调用方法时出错
- vba - 如何在 VBA 上抓取 post div 表格内容?