示例#1
0
def compute(self, vs, agg, superstep):
    newValue = min(self.value, vs[0]) if vs else self.value
    if newValue != self.value:
        outbox = [(edge.target_id, newValue + edge.value)
                  for edge in self.outEdges]
    else:
        outbox = []
    return Vertex(self.id, newValue, self.outEdges, False), outbox
示例#2
0
 def compute(self, messageSum, agg, superstep):
     if messageSum and messageSum[0]:
         newValue = 0.15 / num + 0.85 * messageSum[0]
     else:
         newValue = self.value
     terminate = (superstep >= 10 and
                  abs(newValue - self.value) < epsilon) or superstep > 30
     outbox = [(edge.target_id, newValue / len(self.outEdges))
               for edge in self.outEdges] if not terminate else []
     return Vertex(self.id, newValue, self.outEdges, not terminate), outbox
示例#3
0
def to_vertex(id_lines):
    (id, lines) = id_lines
    outEdges = [Edge(tid, int(v))
                for _, tid, v in lines]
    return (id, Vertex(id, sys.maxint, outEdges, True))
示例#4
0
def parse_vertex(line, numV):
    fields = line.split(' ')
    title, refs = fields[0], fields[1:]
    outEdges = [Edge(ref) for ref in refs]
    return (title, Vertex(title, 1.0 / numV, outEdges, True))