简体   繁体   English

在pyhton(networkx)中有一个有向图,是否可以根据节点属性的特定条件创建子图?

[英]Having a directed graph in pyhton (networkx), is it possible to create a subgraph according to a specific condition on the node attributes?

I have a twitter data set that i want to analyze,after creating a directed graph(the nodes are twitter users, and edge from a to b means a follows b) how i created the graph:我有一个 twitter 数据集,我想在创建有向图后进行分析(节点是 twitter 用户,从 a 到 b 的边表示 a 跟随 b)我是如何创建图形的:

在此处输入图像描述

I want to make a sub graph that contains only male users and edges between them, and another one containing only female users and edges between them.我想制作一个只包含男性用户和他们之间的边的子图,以及另一个只包含女性用户和他们之间的边的子图。 thank you.谢谢你。

I am working on a similar problem, and I think there are two fitting stack answers:我正在研究类似的问题,我认为有两个合适的堆栈答案:

Select nodes and edges form networkx graph with attributes Select 节点和边形成带有属性的networkx图

partition graph into sungraphs based on node's attribute NetworkX 根据节点的属性 NetworkX 将图划分为太阳图

The preliminary requirement is that you add attributes to your nodes and edges according to what you need to use later初步要求是您根据以后需要使用的内容为节点和边添加属性

Not sure if this is satisfactory, but maybe it'll help a little.不确定这是否令人满意,但也许它会有所帮助。

PS. PS。 If you've already solved it, paste your solution here so others can see:)如果您已经解决了,请将您的解决方案粘贴到此处,以便其他人可以看到:)

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

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