def degree(self): """ calculates the degree of each vertex of the passed HyGraph instance. Input Arguments: self: a HyGraph instance Output Argument: ret: a ParVec instance with each element containing the degree of the corresponding vertex. SEE ALSO: sum """ if self.nedge() == 0: return ParVec.zeros(self.nvert()) ret = self._spm.Reduce(pcb.pySpParMat.Column(),pcb.plus(), pcb.ifthenelse(pcb.bind2nd(pcb.not_equal_to(), 0), pcb.set(1), pcb.set(0))) return ParVec.toParVec(ret)
def npin(self): """ calculates the cardinality of each edge of the passed HyGraph instance. Input Arguments: self: a HyGraph instance Output Argument: ret: a ParVec instance with each element containing the cardinality of the corresponding edge. SEE ALSO: rank, antirank """ if self.nedge() == 0: return ParVec.zeros(self.nedge()) ret = self._spm.Reduce(pcb.pySpParMat.Row(),pcb.plus(), pcb.ifthenelse(pcb.bind2nd(pcb.not_equal_to(), 0), pcb.set(1), pcb.set(0))) return ParVec.toParVec(ret)