Extract subgraph that defined by nodes

From the graph object consists of N nodes and E edges, I want to select n nodes and extract only the nodes(m) and edges directly connected to those nodes(selected n nodes).
Finally I want to get sub-graph with (n+m) nodes and their edge information.
How can I do this efficiently?

Thanks in advance.

Do you want to get a subgraph with (n + m) nodes and all edges among them?

Yes! And I’m hope to get nodes which are connected to specific selected nodes. Is there any function that select node that connected to specific nodes?

You can first use in_edges and/or out_edges to get the m nodes from n nodes. Then you can use node_subgraph to extract a subgraph of n + m nodes and all edges among them.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.