def __init__(self, connexion, graph, logger, 
                      separator = '@@@', has_root = False
                ):
        self.connexion = connexion  #the redis connexion
        self.graph = graph          #the name of the graph
        self.logger = logger        #the logger
        self.separator = separator  #the key separator
        self.has_root = has_root    #flag for handling of node 
                                    #   with no predecessor
        self.root = 'RO_' + self.separator + '_OT' #name of the root 
                                                    #   (ultimate predecessor)
        self.transactions = {} #dictionnary of transactions

        self.re_check_separator = re.compile(separator, 0) 
                #compiled regular expression used to check 
                #that separator is not in the key
                #(warn about possible key collision)

        self.legacy_mode = False #small flag for a legacy mode 
        #(support of lua scripting in both python-redis and redis-server


        #a small lua script to handle the has_root option
        # first arg is the node name, second arg is the node predecessors key
        self.lua_handle_no_predecessor = ("""
        local rootismember = redis.call('SISMEMBER', ARGV[2], '%(ROOT)s')
        local card = redis.call('SCARD', ARGV[2])
        if card == 0 
            then redis.call('SADD', ARGV[2], '%(ROOT)s')
                 redis.call('SADD', '%(ROOTSUCC)s', ARGV[1])
        end
        if card > 1 and rootismember == 1
        then redis.call('SREM', ARGV[2], '%(ROOT)s')
             redis.call('SREM', '%(ROOTSUCC)s', ARGV[1])
        end
        """ % {
            'ROOTSUCC' : self._gen_key(self.root, ['successors', ]),
            'ROOT' : self.root
            }
        )

        #we try to register the script
        try:
            self._handle_no_predecessor_script = self.connexion.register_script(
                self.lua_handle_no_predecessor)

        except redis.exceptions.ResponseError:
            #server is to old for lua scripting
            self.legacy_mode = True
            self.logger.info('redis server < 2.6.0, using legacy mode, no atomicity')

        except AttributeError:
            #redis-pyton is to old for lua scripting
            self.legacy_mode = True
            self.logger.info('redis-python < 2.7.0, using legacy mode, no atomicity')


        #if we are not in legacy mode, we try to register other lua scripts
        if not self.legacy_mode:

            #a small lua script to remove all the attributes of a given node
            # first arg is the node name, second arg is the node attributs key
            self.lua_remove_all_attributs = ("""
            local attributs = redis.call('SMEMBERS', ARGV[1]..'%(sep)sattributs_list')
            for i, attribut in ipairs(attributs) do
                redis.call('DEL', ARGV[1]..'%(sep)sattribut%(sep)s'..attribut)
            end
            redis.call('DEL', ARGV[1]..'%(sep)sattribut_list')
            """ % {
                'sep' : self.separator
                }
            )

            #we register the script
            #<graph name><sep><node_name><sep><variable_name>[<sep><other>]*
            self.remove_all_attributes_script = self.connexion.register_script(
                    self.lua_remove_all_attributs)

            #a small lua script to remove a node from its predecessors and successors
            # first arg is the node name
            self.lua_remove_node_successors_predecessors = ("""
            local predecessors = redis.call('SMEMBERS', '%(graph)s%(sep)s'..ARGV[1]..'%(sep)spredecessors')
            local successors = redis.call('SMEMBERS', '%(graph)s%(sep)s'..ARGV[1]..'%(sep)ssuccessors')
            for i, predecessor in ipairs(predecessors) do
                redis.call('SREM', '%(graph)s%(sep)s'..predecessor..'%(sep)ssuccessors', ARGV[1])
                        end
            for i, successor in ipairs(successors) do
                local predecessors_key = '%(graph)s%(sep)s'..successor..'%(sep)spredecessors'
                redis.call('SREM', predecessors_key, ARGV[1])
            end 
            """ % {
                'sep' : self.separator, 
                'graph' : self.graph
                }
            )
            self.lua_handle_root_remove = ("""
            for i, successor in ipairs(successors) do
                local predecessors_key = '%(graph)s%(sep)s'..successor..'%(sep)spredecessors'
                local card = redis.call('SCARD', predecessors_key)
                if card == 0 
                then redis.call('SADD', predecessors_key, '%(ROOT)s')
                    redis.call('SADD', '%(ROOTSUCC)s', successor)
                end
            end
            """ % {
                'sep' : self.separator, 
                'graph' : self.graph,
                'ROOTSUCC' : self._gen_key(self.root, ['successors', ]),
                'ROOT' : self.root
                }
            )

            if has_root:
                #we register the script
                self.remove_node_successors_predecessors_script = self.connexion.register_script(
                    self.lua_remove_node_successors_predecessors +
                    self.lua_handle_root_remove
                    )
            else:
                #we register the script
                self.remove_node_successors_predecessors_script = self.connexion.register_script(
                    self.lua_remove_node_successors_predecessors)
initialize a Redisgraph instance
dataset/ETHPy150Open kakwa/pygraph_redis/pygraph_redis/directed_graph.py/Directed_graph.__init__