def remove_node(self, p_id, remove_unconnected_nodes=True):
        """ Removes a node from the graph. """
        if self.has_node(p_id):
            for neighbor in self.incoming_neighbors(p_id):
                self._edges[neighbor].remove(p_id)

            neighbors = set()
            if remove_unconnected_nodes:
                neighbors = self.outgoing_neighbors(p_id)

            del self._edges[p_id]

            for neighbor in neighbors:
                if self.is_isolated(neighbor):
                    self.remove_node(neighbor)
Removes a node from the graph.