예제 #1
0
    def setUp(self):
        self.a = StringNode("A")
        self.b = StringNode("B")
        self.c = StringNode("C")
        self.d = StringNode("D")
        self.e = StringNode("E")
        self.f = StringNode("F")
        self.g = StringNode("G")

        self.nodes = dict([("A", self.a), ("B", self.b), ("C", self.c),
                           ("D", self.d), ("E", self.e), ("F", self.f),
                           ("G", self.g)])

        self.a.linkTo(self.b)
        self.a.linkTo(self.c, 15)

        self.b.linkTo(self.c)

        self.c.linkTo(self.d)
        self.c.linkTo(self.e)
        self.c.linkTo(self.f)

        self.d.linkTo(self.c, 100)

        self.e.linkTo(self.e, 10)

        self.f.linkTo(self.g, 10)
        self.f.linkTo(self.b, 200)

        graph.calculatePaths(self.nodes.values())
예제 #2
0
    def setUp(self):
        self.a=StringNode("A")
        self.b=StringNode("B")
        self.c=StringNode("C")
        self.d=StringNode("D")
        self.e=StringNode("E")
        self.f=StringNode("F")
        self.g=StringNode("G")

        self.nodes=dict([("A", self.a), ("B", self.b), ("C", self.c),
            ("D", self.d), ("E", self.e), ("F", self.f), ("G", self.g)])

        self.a.linkTo(self.b)
        self.a.linkTo(self.c, 15)

        self.b.linkTo(self.c)

        self.c.linkTo(self.d)
        self.c.linkTo(self.e)
        self.c.linkTo(self.f)

        self.d.linkTo(self.c, 100)

        self.e.linkTo(self.e, 10)

        self.f.linkTo(self.g, 10)
        self.f.linkTo(self.b, 200)

        graph.calculatePaths(self.nodes.values())
예제 #3
0
    def testBigGraph(self):
        nodes = []
        # Generate one hundred nodes
        for i in range(100):
            nodes.append(StringNode(str(i)))

        # Randomly select 50 nodes to link each to 50 other nodes
        r = random.Random()
        for i in r.sample(range(100), 50):
            node = nodes[i]
            for j in r.sample(range(100), 50):
                node.linkTo(nodes[j])

        graph.calculatePaths(nodes)
예제 #4
0
    def testBigGraph(self):
        nodes=[]
        # Generate one hundred nodes
        for i in range(100):
            nodes.append(StringNode(str(i)))

        # Randomly select 50 nodes to link each to 50 other nodes
        r=random.Random()
        for i in r.sample(range(100), 50):
            node=nodes[i]
            for j in r.sample(range(100), 50):
                node.linkTo(nodes[j])

        graph.calculatePaths(nodes)