

def subgraph(self, nbunch):
    'Return the subgraph induced on nodes in nbunch.\n\n        The induced subgraph of the graph contains the nodes in nbunch\n        and the edges between those nodes.\n\n        Parameters\n        ----------\n        nbunch : list, iterable\n            A container of nodes which will be iterated through once.\n\n        Returns\n        -------\n        G : Graph\n            A subgraph of the graph with the same edge attributes.\n\n        Notes\n        -----\n        The graph, edge or node attributes just point to the original graph.\n        So changes to the node or edge structure will not be reflected in\n        the original graph while changes to the attributes will.\n\n        To create a subgraph with its own copy of the edge/node attributes use:\n        nx.Graph(G.subgraph(nbunch))\n\n        If edge attributes are containers, a deep copy can be obtained using:\n        G.subgraph(nbunch).copy()\n\n        For an inplace reduction of a graph to a subgraph you can remove nodes:\n        G.remove_nodes_from([ n in G if n not in set(nbunch)])\n\n        Examples\n        --------\n        >>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc\n        >>> G.add_path([0,1,2,3])\n        >>> H = G.subgraph([0,1,2])\n        >>> H.edges()\n        [(0, 1), (1, 2)]\n        '
    bunch = self.nbunch_iter(nbunch)
    H = self.__class__()
    for n in bunch:
        H.node[n] = self.node[n]
    H_adj = H.adj
    self_adj = self.adj
    for n in H.node:
        Hnbrs = {
            
        }
        H_adj[self] = Hnbrs
        for (nbr, d) in self_adj[n].items():
            if (nbr in H_adj):
                Hnbrs[nbr] = d
                H_adj[nbr][n] = d
    H.graph = self.graph
    return H

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingGraph.subgraph/VarMisuse@83/598 `n`->`self`