Example #1
0
 def is_regular(self, k = None, *largs, **kargs):
     store = lookup(kargs, "store", default = discretezoo.WRITE_TO_DB,
                    destroy = True)
     cur = lookup(kargs, "cur", default = None, destroy = True)
     default = len(largs) + len(kargs) == 0
     try:
         if not default:
             raise NotImplementedError
         r = lookup(self._graphprops, "is_regular")
         return r and (True if k is None
                       else k == self.average_degree(store = store,
                                                     cur = cur))
     except (KeyError, NotImplementedError):
         r = Graph.is_regular(self, k, *largs, **kargs)
         if default:
             if store:
                 row = {"is_regular": r}
                 if r and k is not None:
                     row["average_degree"] = k
                 self._update_rows(ZooGraph, row,
                                   {self._spec["primary_key"]: self._zooid},
                                   cur = cur)
             update(self._graphprops, "is_regular", r)
             if r and k is not None:
                 update(self._graphprops, "average_degree", k)
         return r
Example #2
0
 def is_regular(self, k=None, store=False, **kargs):
     default = len(kargs) == 0
     try:
         if not default:
             raise NotImplementedError
         r = lookup(self._props, "is_regular")
         return r and (True if k is None else k == self.average_degree(store=store))
     except (KeyError, NotImplementedError):
         r = Graph.is_regular(self, k, **kargs)
         if default and store:
             update(self._props, "is_regular", r)
             if r and k is not None:
                 update(self._props, "average_degree", k)
         return r