def cycle_detect(G):
# G = nx.DiGraph object
cycle_list = list(nx.simple_cycles(G))
print '\n\tCycles detected for individuals: '
for i in cycle_list:
print '\t', i[0]
rmCyNode = raw_input('\n\t> Remove nodes? (y/n): ')
print rmCyNode
if rmCyNode == 'y':
for i in cycle_list:
G.remove_node(i[0])
print '\n\tNodes removed with success.'
print '\n\tProceeding with the algorithm.'
elif rmCyNode == 'n':
print '\n\tCorrect pedigree errors before proceeding..'
print '\n\tClosing PedWork.py session...'
print '\n\tExit > OK!'
sys.exit()
else:
print '\n\tPlease enter y/n.'
sys.exit()
return G
评论列表
文章目录