Пример #1
0
 def initDistAndPrev(self, dist, prev):
     self.animationEngine.addToFrames(6)
     self.animationEngine.addToFrames(
         7,
         data=ExtraData.addSingleTableDataAndGet(
             self.distanceId, dist, "Distance",
             self.displayNames[self.distanceId], "Distance"))
     self.animationEngine.addToFrames(
         8,
         data=ExtraData.addSingleTableDataAndGet(
             self.prevId, prev, "Previous", self.displayNames[self.prevId],
             "Previous"))
Пример #2
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])))
Пример #3
0
 def firstForLoop(self, dist):
     self.animationEngine.addToFrames(9)
     self.animationEngine.addToFrames(
         10,
         data=ExtraData.addSingleTableDataAndGet(self.distanceId, dist,
                                                 "Distance",
                                                 self.displayNames))
     self.animationEngine.addToFrames(11)
Пример #4
0
 def jLoop(self, j):
     nodes = [{"id": j.id, "color": SELECTED_NODE_COLOR}]
     self.animationEngine.addToFrames(
         14,
         data=ExtraData.addSingleTableDataAndGet(self.forLoopJ,
                                                 j,
                                                 inlineExp="j ="),
         nodes=nodes)
Пример #5
0
 def iLoop(self, i):
     nodes = [{"id": i.id, "color": NEIGHBOUR_NODE_COLOR}]
     self.animationEngine.addToFrames(
         13,
         data=ExtraData.addSingleTableDataAndGet(self.forLoopI,
                                                 i,
                                                 inlineExp="i ="),
         nodes=nodes)
Пример #6
0
 def setToInf(self, htmlTable):
     self.animationEngine.addToFrames(
         5,
         data=ExtraData.addSingleTableDataAndGet(
             self.tableMatrixID,
             htmlTable,
             tableName=self.tableMatrixLabel,
             isShownOnScreen=False))
Пример #7
0
    def innerIf(self, u, v, w, distance, previous, graph, source):
        data = ExtraData(
            self.errorUID,
            "u = {}, v = {}, distanceBetween({},{}) = {}".format(
                u, v, u, v, w))
        self.animationEngine.addToFrames(20, data=data)
        self.animationEngine.addToFrames(
            21,
            edges=self.edgeHighlighter.getEdges(distance, previous, u, v, w,
                                                source, graph),
            data=ExtraData.addSingleTableDataAndGet(
                self.errCheckID,
                "{} + {} ({}) < {}".format(distance[u], w, distance[u] + w,
                                           distance[v])))

        self.animationEngine.addToFrames(
            22,
            data=ExtraData.addSingleTableDataAndGet(
                self.outIfDBool, (str((distance[u] + w) < distance[v]))))
Пример #8
0
 def assignDistance(self, i, j, k, distance, htmlTable):
     exp = self.__createExp(i, j, k, distance)
     self.animationEngine.addToFrames(
         17,
         data=ExtraData.addSingleTableDataAndGet(
             self.tableMatrixID,
             htmlTable,
             tableName=self.tableMatrixLabel,
             isShownOnScreen=False),
         overrideExplanation=exp)
     self.animationEngine.addToFrames(18, overrideExplanation=exp)
Пример #9
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)
Пример #10
0
    def ifStatement(self, u, v, w, distances, previous):
        data13 = ExtraData(self.equalDistID,
                           "distance[{}] = {} + {}".format(v, distances[u], w))
        data13.addToUpdateDataQueue(self.distanceId,
                                    distances,
                                    isShownOnScreen=False,
                                    inlineExp="Distance")

        data14 = ExtraData(self.equalPrevID, "previous[{}] = {}".format(v, u))
        data14.addToUpdateDataQueue(self.prevId,
                                    previous,
                                    isShownOnScreen=False,
                                    inlineExp="Previous")

        self.animationEngine.addToFrames(15, data=data13)
        self.animationEngine.addToFrames(16, data=data14)
Пример #11
0
 def ret(self, dist, prev):
     self.animationEngine.addToFrames(24)
     self.animationEngine.addToFrames(25)
     data = ExtraData(self.distanceId,
                      dist,
                      isShownOnScreen=False,
                      inlineExp="Distance")
     data.addToUpdateDataQueue(self.prevId,
                               prev,
                               isShownOnScreen=False,
                               inlineExp="Previous")
     data.addToUpdateDataQueue(self.retID,
                               "Dist {}, OI OI OI Prev {}".format(
                                   dist, prev),
                               isShownOnScreen=False)
     self.animationEngine.addToFrames(26, data=data)