示例#1
0
    def test_addInEdge(self):

        v4 = Vertex("4", 200, 100)
        v5 = Vertex("5", 100, 100)

        v45 = Edge(v4, v5, 2)
        v54 = Edge(v5, v4, 3)

        nose.tools.assert_raises(GraphError, v5.addInEdge, v54)
        v5.addInEdge(v45)
        assert v5.getNumInEdges() == 1
        nose.tools.assert_raises(GraphError, v5.addInEdge, v45)
示例#2
0
    def test_construction(self):

        v1 = Vertex("1", 1.0, 1.0)

        v1.getNumOutEdges() == 0
        v1.getNumInEdges() == 0

        v1.getCardinality() == (0, 0)

        v1.getNumMovements() == 0
示例#3
0
    def test_incidentEdge(self):

        v4 = Vertex("4", 200, 100)
        v5 = Vertex("5", 100, 100)

        e45 = Edge(v4, v5, 2)
        e54 = Edge(v5, v4, 3)

        v5.addInEdge(e45)

        assert e45 == v5.getInEdge("4")
        nose.tools.assert_raises(GraphError, v5.getInEdge, "40")

        assert v5.hasInEdge("4")
        assert not v5.hasInEdge("100")
示例#4
0
    def test_getOutEdge(self):

        v4 = Vertex("4", 200, 100)
        v5 = Vertex("5", 100, 100)

        e45 = Edge(v4, v5, 2)
        e54 = Edge(v5, v4, 3)

        v5.addOutEdge(e54)

        assert e54 == v5.getOutEdge("4")
        nose.tools.assert_raises(GraphError, v5.getOutEdge, "10")

        assert v5.hasOutEdge("4")
        assert not v5.hasOutEdge("11")