Пример #1
0
        public void Load()
        {
            var georgia = new TestNode();
            var florida = new TestNode();
            var sc = new TestNode();
            var tennesse = new TestNode();
            var nc = new TestNode();
            var alabama = new TestNode();

            Nodes.Add(georgia);
            Nodes.Add(florida);
            Nodes.Add(sc);
            Nodes.Add(tennesse);
            Nodes.Add(nc);
            Nodes.Add(alabama);

            Edges.Add(georgia.Connect(florida));
            Edges.Add(georgia.Connect(sc));
            Edges.Add(georgia.Connect(nc));
            Edges.Add(georgia.Connect(tennesse));
            Edges.Add(georgia.Connect(alabama));

            Edges.Add(alabama.Connect(tennesse));
            Edges.Add(alabama.Connect(florida));

            Edges.Add(nc.Connect(sc));

            Edges.Add(nc.Connect(tennesse));
        }
Пример #2
0
        private void AddNode_Execute()
        {
            var newNode = new TestNode();
            Nodes.Add(newNode);

            var newEdges = new List<TestEdge>();
            var randomCount = _Randomizer.Next(1, 4);
            for (int i = 0; i < randomCount; i++)
            {
                var existingNode = Nodes[_Randomizer.Next(0, 3)];
                if (newEdges.Any(te => te.Source.UniqueID == existingNode.UniqueID || te.Sink.UniqueID == existingNode.UniqueID))
                {
                    i--;
                    continue;
                }
                if (_Randomizer.Next(0, 2) == 1)
                    newEdges.Add(newNode.Connect(existingNode));
                else
                    newEdges.Add(existingNode.Connect(newNode));
            }

            foreach (var edge in newEdges)
                Edges.Add(edge);
        }
Пример #3
0
 public TestEdge Connect(TestNode otherNode)
 {
     return new TestEdge(this, otherNode);
 }