Exemplo n.º 1
0
 def innerLoop(self, u, v, w, distance, graph, sourceNode, previous):
     data = ExtraData(
         self.uID, "u = {}, v = {}, distanceBetween({},{}) = {}".format(
             u, v, u, v, w))
     data.addToTable(self.uID, self.displayNames[self.uID], u)
     data.addToTable(self.vID, self.displayNames[self.vID], v)
     data.addToTable(self.wID, self.displayNames[self.wID], w)
     nodes = [{
         "id": u.id,
         "color": CURRENT_NODE_COLOR
     }, {
         "id": v.id,
         "color": NEIGHBOUR_NODE_COLOR
     }]
     self.animationEngine.addToFrames(12, data=data, nodes=nodes)
     self.animationEngine.addToFrames(
         13,
         edges=self.edgeHighlighter.getEdges(distance, previous, u, v, w,
                                             sourceNode, graph),
         data=ExtraData.addSingleTableDataAndGet(
             self.innerIfD,
             "{} + {} < {} = {}".format(distance[u], w, distance[v],
                                        distance[u] + w < distance[v])))
     self.animationEngine.addToFrames(
         14,
         data=ExtraData.addSingleTableDataAndGet(
             self.innerIfDBool, str(distance[u] + w < distance[v])))
Exemplo n.º 2
0
 def kLoop(self, i, j, k, distance, htmlTable):
     nodes = [{
         "id": k.id,
         "color": CURRENT_NODE_COLOR
     }, {
         "id": j.id,
         "color": SELECTED_NODE_COLOR
     }, {
         "id": i.id,
         "color": NEIGHBOUR_NODE_COLOR
     }]
     data = ExtraData(self.forLoopK,
                      k,
                      inlineExp="k =",
                      isShownOnScreen=True)
     data.addToTable(self.tableMatrixID, self.tableMatrixLabel, htmlTable)
     exp = self.__createExp(i, j, k, distance)
     self.animationEngine.addToFrames(15,
                                      data=data,
                                      nodes=nodes,
                                      overrideExplanation=exp)
     self.animationEngine.addToFrames(16, overrideExplanation=exp)