Esempio n. 1
0
	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)
Esempio n. 2
0
	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)
Esempio n. 3
0
	print "loading matrix from %s"%(path)
	A.load(path)
	A.Apply(pcb.set(1))
	#print "converting to boolean" # already boolean
	#A = pcb.pySpParMatBool(A)
	n = A.getnrow()
	
	colreducer = pcb.pyDenseParVec(n, 1).sparse();
	degrees = A.SpMV_PlusTimes(colreducer).dense();

else:
	if (pcb.root()):
		print "Generating RMAT with 2**%d nodes" %(scale)
	k1time = A.GenGraph500Edges(scale)
	A.Apply(pcb.set(1))
	degrees = A.Reduce(pcb.pySpParMat.Column(), pcb.plus());
	if (pcb.root()):
		print "Generation took %lf s"%(k1time)
	
#A.save("/home/alugowski-ucsb/matrices/rmat%d.mtx"%(scale))
n = A.getnrow()
m = A.getncol()
nee = A.getnee()
nnz = A.getnnz()
edgefactor = nnz/n;
if (pcb.root()):
	print "A is %d by %d with %d elements (%d nonzeros)." % (n, m, nee, nnz)


###############################################
###########    CANDIDATE SELECTION