(genome, **args)
return int(mutations)
The mutator of GTree, Swap Mutator

   .. versionadded:: 0.6
      The *GTreeMutatorSwap* function
The mutator of GTree, Swap Mutator
The mutator of GTree Swap Mutator
def GTreeMutatorSwap(genome, **args):
   """ The mutator of GTree, Swap Mutator

   .. versionadded:: 0.6
      The *GTreeMutatorSwap* function
   """
   if args["pmut"] <= 0.0:
      return 0
   elements = len(genome)
   mutations = args["pmut"] * elements

   if mutations < 1.0:
      mutations = 0
      for i in xrange(len(genome)):
         if Util.randomFlipCoin(args["pmut"]):
            mutations += 1
            nodeOne = genome.getRandomNode()
            nodeTwo = genome.getRandomNode()
            nodeOne.swapNodeData(nodeTwo)
   else:
      for it in xrange(int(round(mutations))):
         nodeOne = genome.getRandomNode()
         nodeTwo = genome.getRandomNode()
         nodeOne.swapNodeData(nodeTwo)

   return int(mutations)
def GTreeMutatorSwap ( genome , * * args ) : if args [ "pmut" ] <= 0.0 : return 0 elements = len ( genome ) mutations = args [ "pmut" ] * elements if mutations < 1.0 : mutations = 0 for i in xrange ( len ( genome ) ) : if Util . randomFlipCoin ( args [ "pmut" ] ) : mutations += 1 nodeOne = genome . getRandomNode ( ) nodeTwo = genome . getRandomNode ( ) nodeOne . swapNodeData ( nodeTwo ) else : for it in xrange ( int ( round ( mutations ) ) ) : nodeOne = genome . getRandomNode ( ) nodeTwo = genome . getRandomNode ( ) nodeOne . swapNodeData ( nodeTwo ) return int ( mutations )