Ask Your Question

Revision history [back]

Happy to give my specific code, since I think the answer will help me understand generators/parallel structure better anyway...

Here's my testing function:

def is_kdense(g,k):
k_dense=True
if min(g.degree())< k-2:
    k_dense=False
if g.size()<floor(g.order()*(k-1)/2):
    k_dense=False
for i in list(g.edge_iterator(labels=False)):
    common= len(set(g.neighbors(i[0])).intersection(g.neighbors(i[1])))
    if common < k-2:
        k_dense=False
        break
return k_dense

This is being called from a main file by:

#generator for n=9
n9graphs=set()
for g in graphs.nauty_geng("9 -c 27:32 -d6"):
    gtmp=g.copy(immutable=True)
    if is_kdense(gtmp,7):
        n9graphs.add(gtmp) 
print "finished first-9"
for g in n9graphs:
    print g.adjacency_matrix()
    print "next graph"

So basically, the main file creates a generator with:

graphs.nauty_geng("9 -c 27:32 -d6")

Then, I could test each graph from the generator in parallel (without any conflict from my test function). However, I do still need a way of saving things that test true, which probably requires a lock around the

n9graphs.add(gtmp)