0

I am roughly new to Networkx in python and I have a question regrading extracting a subgraphs from a huge graph using Networkx. Suppose that we need a subgraph of nodes 6,8,4 from following graph and we have no idea how many intermediate nodes would be there between these 2 nodes but all of the intermediate nodes should be included in the subgraph as well. Thus, we need to extract the subgraph that is showed with green color (In this particular case, the subgraph could be achieved through the path between nodes 8,4, let's think more general and ignore using path between 8 and 4 as a solution). I tried to create a list of nodes and used G.subgraph(list of nodes), but the created subgraph is empty(second figure)! The graph that I work with is a huge directed graph and unfortunately I can't attach its data here. I appreciate if anyone could help me with finding a way to extract green part of the graph. [![enter image description here][1]][1]

[![enter image description here][2]][2]

user3665906
  • 185
  • 13
  • It is not clear to me how you define the subgraph you want. The standard definition that would be used to define a subgraph from a few nodes would be to take those nodes and any edges between them and call that the subgraph. You clearly want something else. Can you give a clear definition? – Joel Dec 23 '18 at 19:46
  • suppose that you have 100 nodes that are connected to each other. Based on an analysis you found that nodes 1,2,10,99 are important. Now you want to extract the minimal subgraph from 100 that contains 4 mentioned nodes. You have to include all of intermediate nodes and edges that are required to connect these 4 nodes together as well. – user3665906 Dec 24 '18 at 05:17

0 Answers0