def divConn (self, preCellsTags, postCellsTags, connParam):
    from .. import sim

    ''' Generates connections between all pre and post-syn cells based on probability values'''
    if sim.cfg.verbose: print('Generating set of divergent connections (rule: %s) ...' % (connParam['label']))
     
    # get list of params that have a lambda function
    paramsStrFunc = [param for param in [p+'Func' for p in self.connStringFuncParams] if param in connParam] 

    # copy the vars into args immediately and work out which keys are associated with lambda functions only once per method
    funcKeys = {}
    for paramStrFunc in paramsStrFunc:
        connParam[paramStrFunc + 'Args'] = connParam[paramStrFunc + 'Vars'].copy()
        funcKeys[paramStrFunc] = [key for key in connParam[paramStrFunc + 'Vars'] if callable(connParam[paramStrFunc + 'Vars'][key])]

    # converted to list only once 
    postCellsTagsKeys = sorted(postCellsTags)    

    # calculate hash for post cell gids
    hashPostCells = sim.hashList(postCellsTagsKeys)

    for preCellGid, preCellTags in preCellsTags.items():  # for each presyn cell
        divergence = connParam['divergenceFunc'][preCellGid] if 'divergenceFunc' in connParam else connParam['divergence']  # num of presyn conns / postsyn cell
        divergence = max(min(int(round(divergence)), len(postCellsTags)-1), 0)
        self.rand.Random123(hashPostCells, preCellGid, sim.cfg.seeds['conn'])  # init randomizer
        randSample = self.randUniqueInt(self.rand, divergence+1, 0, len(postCellsTags)-1)
        
        # note: randSample[divergence] is an extra value used only if one of the random postGids coincided with the preGid 
        postCellsSample = {postCellsTagsKeys[randSample[divergence]] if postCellsTagsKeys[i]==preCellGid else postCellsTagsKeys[i]: 0
                               for i in randSample[0:divergence]}  # dict of selected gids of postsyn cells with removed pre gid

        for postCellGid in [c for c in postCellsSample if c in self.gid2lid]:            
            postCellTags = postCellsTags[postCellGid]
            for paramStrFunc in paramsStrFunc: # call lambda functions to get weight func args
                # update the relevant FuncArgs dict where lambda functions are known to exist in the corresponding FuncVars dict
                for funcKey in funcKeys[paramStrFunc]:
                    connParam[paramStrFunc + 'Args'][funcKey] = connParam[paramStrFunc+'Vars'][funcKey](preCellTags,postCellTags)

            if preCellGid != postCellGid: # if not self-connection
                self._addCellConn(connParam, preCellGid, postCellGid)
Generates connections between all pre and post-syn cells based on probability values