Ejemplo n.º 1
0
        public void ToDot_Uses_Edge_Indicator()
        {
            var a = new GraphNode("a");
            var b = new GraphNode("b");

            var edge = new TestEdge(a, b);
            Assert.AreEqual(edge.ToDot(), "\"a\" ** \"b\"");
        }
Ejemplo n.º 2
0
        public void ToDot_Ouputs_Attributes()
        {
            var a = new GraphNode("a");
            var b = new GraphNode("b");

            var attribute = MockRepository.GenerateMock<IDotAttribute>();
            attribute.Expect(x => x.ToDot()).Return("att=custom");
            
            var edge = new TestEdge(a, b);
            edge.Attributes.AddAttribute(attribute);
            Assert.AreEqual(edge.ToDot(), "\"a\" ** \"b\" [att=custom]");
        }
Ejemplo n.º 3
0
        public void WriteEdge()
        {
            {
                TestAdjacencyGraph g  = new TestAdjacencyGraph();
                TestVertex         v1 = new TestVertex(
                    "v1",
                    "string",
                    1,
                    2,
                    3.0,
                    4.0F,
                    true,
                    new Dummy()
                    );
                TestVertex v2 = new TestVertex(
                    "v2",
                    "string2",
                    5,
                    6,
                    7.0,
                    8.0F,
                    true,
                    new Dummy()
                    );

                g.AddVertex(v1);
                g.AddVertex(v2);

                TestEdge edge = new TestEdge(
                    v1, v2,
                    "e1",
                    "string",
                    9,
                    10,
                    11.0,
                    12.0F,
                    true,
                    new Dummy()
                    );
                g.AddEdge(edge);
                VerifySerialization(g);
            }
        }
        public void WriteEdge()
        {
            {
                var g = new TestGraph()
                {
                    Bool   = true,
                    Double = 1.0,
                    Float  = 2.0F,
                    Int    = 10,
                    Long   = 100,
                    String = "foo"
                };

                TestVertex v1 = new TestVertex("v1")
                {
                    StringDefault = "bla",
                    String        = "string",
                    Int           = 10,
                    Long          = 20,
                    Float         = 25.0F,
                    Double        = 30.0,
                    Bool          = true
                };

                TestVertex v2 = new TestVertex("v2")
                {
                    StringDefault = "bla",
                    String        = "string2",
                    Int           = 110,
                    Long          = 120,
                    Float         = 125.0F,
                    Double        = 130.0,
                    Bool          = true
                };


                g.AddVertex(v1);
                g.AddVertex(v2);

                var e = new TestEdge(
                    v1, v2,
                    "e1",
                    "edge",
                    90,
                    100,
                    25.0F,
                    110.0,
                    true
                    );
                g.AddEdge(e);
                var sg = VerifySerialization(g);

                var se = Enumerable.First(sg.Edges);
                Assert.AreEqual(e.ID, se.ID);
                Assert.AreEqual(e.String, se.String);
                Assert.AreEqual(e.Int, se.Int);
                Assert.AreEqual(e.Long, se.Long);
                Assert.AreEqual(e.Float, se.Float);
                Assert.AreEqual(e.Double, se.Double);
                Assert.AreEqual(e.Bool, se.Bool);
            }
        }
Ejemplo n.º 5
0
 public void Add(params TestNode[] targets)
 {
     foreach (TestNode target in targets)
     {
         TestEdge edge = new TestEdge(this, target);
         this.outgoing.Add(edge);
         target.incoming.Add(edge);
     }
 }
Ejemplo n.º 6
0
 public IEdge Clone()
 {
     TestEdge newEdge = new TestEdge(this.Source, this.Target);
     newEdge.Saturated = this.Saturated;
     return newEdge;
 }
Ejemplo n.º 7
0
        public void AddEdgeTo(TestNode node)
        {
            IEdge <TestNode> edge = new TestEdge(MoveCost + node.MoveCost, node);

            edges.Add(edge);
        }