Ejemplo n.º 1
0
        public void EdgeData()
        {
            var a = new NumEdgeData {
                testNum = 3
            };
            var b = new NumEdgeData {
                testNum = 4
            };
            var c = new NumEdgeData {
                testNum = 5
            };

            var myGraph = new DirectedWeightedMultiGraph <int, NumEdgeData>();

            myGraph.AddNodes(1, 2, 3);
            myGraph.AddEdges(
                (1, 2, 4, a),
                (1, 2, 3, b),
                (2, 3, 5, c)
                );

            myGraph.EdgeIDs(1, 2).Select(id => myGraph.EdgeData(id)).Should().Contain(a);
            myGraph.EdgeIDs(1, 2).Select(id => myGraph.EdgeData(id)).Should().Contain(b);
            myGraph.EdgeIDs(2, 3).Select(id => myGraph.EdgeData(id)).Should().Contain(c);
            myGraph.Invoking(x => x.EdgeData(new System.Guid())).Should().Throw <System.ArgumentException>();
        }
Ejemplo n.º 2
0
        public void AddEdges()
        {
            var a = new NumEdgeData {
                testNum = 1
            };
            var b = new NumEdgeData {
                testNum = 2
            };
            var c = new NumEdgeData {
                testNum = 3
            };
            var d = new NumEdgeData {
                testNum = 4
            };

            var myGraph = new DirectedWeightedGraph <int, NumEdgeData>();

            myGraph.AddNodes(1, 2, 3, 4);
            myGraph.AddEdges(
                (1, 2, 5, a),
                (2, 3, 6, b),
                (2, 4, 7, c),
                (3, 4, 8, d)
                );

            myGraph.Neighbors(1).Should().Contain(2);
            myGraph.Neighbors(2).Should().Contain(3);
            myGraph.Neighbors(2).Should().Contain(4);
            myGraph.Neighbors(3).Should().Contain(4);
            myGraph.Neighbors(1).Should().NotContain(4);

            myGraph.Weight(1, 2).Should().Be(5);
            myGraph.Weight(2, 3).Should().Be(6);
            myGraph.Weight(2, 4).Should().Be(7);
            myGraph.Weight(3, 4).Should().Be(8);

            myGraph.EdgeData(1, 2).Should().Be(a);
            myGraph.EdgeData(2, 3).Should().Be(b);
            myGraph.EdgeData(2, 4).Should().Be(c);
            myGraph.EdgeData(3, 4).Should().Be(d);

            myGraph.Invoking(x => x.AddEdge(2, 4, 9, d)).Should().Throw <ArgumentException>();
        }
Ejemplo n.º 3
0
        public void EdgeData()
        {
            var a = new NumEdgeData {
                testNum = 3
            };
            var b = new NumEdgeData {
                testNum = 5
            };

            var myGraph = new DirectedWeightedGraph <int, NumEdgeData>();

            myGraph.AddNodes(1, 2, 3);
            myGraph.AddEdges(
                (1, 2, 4, a),
                (2, 3, 5, b)
                );

            myGraph.EdgeData(1, 2).Should().Be(a);
            myGraph.EdgeData(2, 3).Should().Be(b);
            myGraph.Invoking(x => x.EdgeData(2, 4)).Should().Throw <ArgumentException>();
        }