Esempio n. 1
0
def main():
    nodeGenerator = NodeGenerator()
    coors = nodeGenerator.gen(10, 200) 
    tree = DHTree(coors)
    tree.get_tree(math.pi / 3, math.pi / 4, 2, 7)
    tree.print_tree()
    tree.store_vertices('vertices')
    tree.store_edges('edges')
Esempio n. 2
0
def main():
    nodeGenerator = NodeGenerator()
    coors = nodeGenerator.gen(10, 100) 
    tree = DHTree(2, 7, math.pi / 3, coors)
    index = range(len(coors))
    tree.build_tree(index, begin = 0, end = len(index), r = tree.V[0])
    tree.print_tree()
    tree.store_vertices('vertices')
    tree.store_edges('edges')
Esempio n. 3
0
    def __init__(self, char, start=None, finish=None):
        # constructor makes a simple start node and accept state connected by an edge
        node_generator = NodeGenerator.getInstance()
        if (start == None):
            self.start_node = node_generator.make_node(isStart=True)
            self.accept_state = node_generator.make_node(isFinish=True)
            self.start_node.add_destination_node(char, self.accept_state)
            self.all_accept_states = []

        else:  # make custom non-simple graphs (like ones after operations)
            self.start_node = start
            self.accept_state = finish
            self.start_node.add_destination_node(char, self.accept_state)
            self.all_accept_states = []
Esempio n. 4
0
 def keenClosure(graph):
     """
     uses the kleen closure operator on a graph to produce a new graph using thompson algorithm
     :param graph: a graph
     :return:
     """
     n = NodeGenerator.getInstance()
     g = Graph("@")
     # g.start_node.clearEdges()
     # repeat more than once
     graph.accept_state.add_destination_node("@", graph.start_node)
     # add new finish with edge epsilon
     graph.accept_state.add_destination_node("@", g.accept_state)
     graph.accept_state.isFinish = 0
     # add new start
     g.start_node.add_destination_node("@", graph.start_node)
     graph.start_node.isStart = 0
     # repeat zero times
     return g
Esempio n. 5
0
    def __init__(self, nodes):
        # sort nodes according to ids
        nodes = sorted(nodes, key=state.sortHelper)
        state.state_Nodes.append(nodes)
        state.state_instances.append(self)
        self.destinations = {}  # we add in it a pair (char,state number)
        self.id = state.id
        state.id += 1

    @staticmethod
    def getNodeFromID(self, id):
        return state.state_instances[id]

    def getStateNodes(self):
        return state.state_Nodes[self.id]

    def addDestination(self, char, state_to):
        # only 1 state_to for each char, so we dont need a list
        self.destinations[char] = state_to


if __name__ == '__main__':
    x = NodeGenerator.getInstance()
    a = x.make_node()
    b = x.make_node()
    c = x.make_node()

    y = state.getState([a, b])
    z = state.getState([a, c])
    print(z.getStateNodes())
Esempio n. 6
0
from Operation import Operation
import random

row = []
for x in range(0, Main.x_resolution):
    column = []
    for y in range(0, Main.y_resolution):
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        column.append(Pixel(r, g, b, 255))
    row.append(column)

frame = Frame(row)

i0 = NodeGenerator(frame)
i1 = Operation()
c2 = 0
c3 = 0
i4 = -14
i4 = i1.actALessThanB(c3, c3)
i6 = -5
i7 = i0.constructNodeRectangle(793, 448, 246, 568)
i8 = 36
i8 = i1.actAdd(i6, i7.determineAverageBlue())
i10 = -5
c3 = i1.actRemainder(i7.determineAverageBlue(), i10)
i12 = i0.constructNodeRectangle(611, 250, 416, 0)
i13 = 1
i13 = i1.actDivide(i6, i12.determineAverageGreen())
i15 = -54
Esempio n. 7
0
def main():
    nodeGen = NodeGenerator()
    coors = nodeGen.gen(100, 500) 
    tree = RandTree(coors)
    tree.get_tree(2, 5)             
    tree.print_nodes()