def partition_by_cut(cut, rag):
 nodes1 = [n for (i, n) in enumerate(rag.nodes()) if cut[i]]
 nodes2 = [n for (i, n) in enumerate(rag.nodes()) if (not cut[i])]
 sub1 = rag.subgraph(nodes1)
 sub2 = rag.subgraph(nodes2)
 return (sub1, sub2)

def partition_by_cut ( cut , rag ) : nodes1 = [ n for ( i , n ) in enumerate ( rag . nodes ( ) ) if cut [ i ] ] nodes2 = [ n for ( i , n ) in enumerate ( rag . nodes ( ) ) if ( not cut [ i ] ) ] sub1 = rag . subgraph ( nodes1 ) sub2 = rag . subgraph ( nodes2 ) return ( sub1 , sub2 )
compute resulting subgraphs from given bi-parition .