In the python library networkx I would like to remove the nodes and edges of a graph which have some property. For example, suppose I wanted to remove all nodes and edges where
Note that in Aric's for networkx==2.2, you need to wrap G.degree() in a dictionary because the networkx view object doesn't have an items method. This line would be:
[node for node,degree in dict(G.degree()).items() if degree > 2]