'Remove node n.
Removes the node n and all adjacent edges.
Attempting to remove a non-existent node will raise an exception.
Parameters
n : node
A node in the graph
Raises
NetworkXError
If n is not in the graph.
See Also
remove_nodes_from
Examples
>>> G = nx.path_graph(3)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> list(G.edges())
[(0, 1), (1, 2)]
>>> G.remove_node(1)
>>> list(G.edges())'

def remove_node(self, n):

    adj = self._adj
    try:
        nbrs = list(adj[n])
        del self._node[n]
    except KeyError:
        raise NetworkXError(('The    node    %s    is    not    in    the    graph.' % (n,)))
    for u in nbrs:
        del adj[u][n]
    del adj[n]
