def __init__(self, all_nodes, kind): if len(all_nodes) > 0: identifier_class = all_nodes[0].identifier.__class__ for node in all_nodes: check.check_instance(node.identifier, identifier_class) check.check_equal(node.finalized, True) self.all_nodes = all_nodes self.kind = check.check_one_of(kind, [Graph.DIRECTED, Graph.UNDIRECTED]) self.log_len = math.log10(len(self.all_nodes) + 1) self.indexes = {} for node in self.all_nodes: self.indexes[node.identifier] = node self.clustering_coefficients = self._calculate_clustering_coefficients( ) self._distances = {} self._max_distances = {} self._global_max_distance = None self._background_calculations = threading.Thread( target=self._submit_calculations) self._background_calculations.daemon = True self._background_calculations.start()
def __init__(self, name, default, plural=False, canonicalize=lambda v: v): self.name = check.check_not_empty(name) self.default = default self.plural = check.check_one_of(plural, [True, False]) self.canonicalize = canonicalize self.key = self.name if not self.plural else "%s[]" % self.name
def __init__(self, threshold, exclude_numbers): self.threshold = check.check_gte(threshold, 1) self.exclude_numbers = check.check_one_of(exclude_numbers, [True, False]) self.word_counts = {}
def __init__(self, improved, update_best): self.improved = check.check_one_of(improved, [True, False]) self.update_best = check.check_one_of(update_best, [True, False])
def score(self, value=None): if value is None: return self._score self._score = check.check_one_of(value, [True, False]) return self
def debug(self, value=None): if value is None: return self._debug self._debug = check.check_one_of(value, [True, False]) return self
def convergence(self, value=None): if value is None: return self._convergence self._convergence = check.check_one_of(value, [True, False]) return self