def __call__(self, index, graph):
def all_permutations(l):<EOL><INDENT>"""<STR_LIT>"""<EOL>if len(l) == <NUM_LIT:1>:<EOL><INDENT>yield l<EOL>return<EOL><DEDENT>for i in range(len(l)):<EOL><INDENT>for sub in all_permutations(l[:i]+l[i+<NUM_LIT:1>:]):<EOL><INDENT>yield [l[i]] + sub<EOL><DEDENT><DEDENT><DEDENT>neighbors = graph.neighbors[index]<EOL>if not len(neighbors) == len(self.neighbor_criteria):<EOL><INDENT>return<EOL><DEDENT>for perm_neighbors in all_permutations(list(neighbors)):<EOL><INDENT>ok = True<EOL>for neighbor, crit in zip(perm_neighbors, self.neighbor_criteria):<EOL><INDENT>if not crit(neighbor, graph):<EOL><INDENT>ok = False<EOL>break<EOL><DEDENT><DEDENT>if ok:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>
Return True only if each neighbor can be linked with a positive criterion

           Arguments:
            | ``index``  --  the index of the vertex/edge on which the criterion is
                             applied
            | ``graph``  --  the graph on which the criterion is tested