@staticmethod<EOL><INDENT>def filterGraph(graph, node_fnc):<DEDENT>
nodes = filter(lambda l: node_fnc(l), graph.nodes())<EOL>edges = {}<EOL>gedges = graph.edges()<EOL>for u in gedges:<EOL><INDENT>if u not in nodes:<EOL><INDENT>continue<EOL><DEDENT>for v in gedges[u]:<EOL><INDENT>if v not in nodes:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>edges[u].append(v)<EOL><DEDENT>except KeyError:<EOL><INDENT>edges[u] = [v]<EOL><DEDENT><DEDENT><DEDENT>return Graph(nodes, edges)<EOL>
Remove all nodes for with node_fnc does not hold