Returns a independent deep copy subgraph induced on nbunch. The induced subgraph of a graph on a set of nodes N is the graph with nodes N and edges from G which have both ends in N. Parameters ---------- G : NetworkX Graph nbunch : node, container of nodes or None (for all
(G, nbunch)
| 97 | |
| 98 | |
| 99 | def induced_subgraph(G, nbunch): |
| 100 | """Returns a independent deep copy subgraph induced on nbunch. |
| 101 | |
| 102 | The induced subgraph of a graph on a set of nodes N is the |
| 103 | graph with nodes N and edges from G which have both ends in N. |
| 104 | |
| 105 | Parameters |
| 106 | ---------- |
| 107 | G : NetworkX Graph |
| 108 | nbunch : node, container of nodes or None (for all nodes) |
| 109 | |
| 110 | Returns |
| 111 | ------- |
| 112 | subgraph : SubGraph |
| 113 | A independent deep copy of the subgraph in `G` induced by the nodes. |
| 114 | |
| 115 | Examples |
| 116 | -------- |
| 117 | >>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc |
| 118 | >>> H = G.subgraph([0, 1, 2]) |
| 119 | >>> list(H.edges) |
| 120 | [(0, 1), (1, 2)] |
| 121 | """ |
| 122 | induced_nodes = G.nbunch_iter(nbunch) |
| 123 | return G.subgraph(induced_nodes) |
| 124 | |
| 125 | |
| 126 | def edge_subgraph(G, edges): |
nothing calls this directly
no test coverage detected