Example #1
0
        public IDictionary <int, IAdjacencyDirectableVisitable> AdjacentVertices(IAdjacencyDirector director)
        {
            var elements          = director.RequestAdjacentElements(this.Position);
            var convertedElements = elements.Select(t => ((VertexNode <T>)t.Value).ToVisitable).ToDictionary(t => t.Position, t => t);

            return(convertedElements);
        }
Example #2
0
        //public VertexNodeFactory(AdjacencyMatrixDictionaryDirector<VertexNode<string>> director)
        //{
        //    if (director == null)
        //    {
        //        throw new NullReferenceException("Director is null when constructing VertexNodeFactory!");
        //    }
        //    this.Director = director;
        //}

        public static VertexNode <T> CreateNode(T vertex, int position, IAdjacencyDirector director)
        {
            var edgeNode = new VertexNode <T>(vertex, position);

            edgeNode.Register(director);
            return(edgeNode);
        }
Example #3
0
        public static VertexNode <T> CreateNode(T vertex, int position, IAdjacencyDirector director, SynchronizedCollection <VertexNode <T> > adjacentVertices)
        // Ensures thread safety.
        {
            var vertexNode = CreateNode(vertex, position, director);

            // Convert to synchronizedCollection to make thread-safe.
            //vertexNode.AdjacentVertices = adjacentVertices;
            return(vertexNode);
        }
Example #4
0
 public VertexNode(T value, int position, IAdjacencyDirector director)
 {
     this.Chosen   = false;
     this.Value    = value;
     this.Position = position;
     if (director == null)
     {
         throw new NullReferenceException("Director cannot be null when constructing VertexNode!");
     }
     this.AdjacencyDirector = director;
     this.AdjacencyDirector.Register(this);
 }
Example #5
0
        public static VertexNode <T> CreateNode(T vertex, int position, IAdjacencyDirector director, IEnumerable <T> adjacentVertices)
        // Ensures thread safety.
        {
            var vertexNode = CreateNode(vertex, position, director);
            // Convert to synchronizedCollection to make thread-safe.
            var collection = new SynchronizedCollection <VertexNode <T> >()
            {
            };

            foreach (var adjacentVertex in adjacentVertices)
            {
                var node = CreateNode(adjacentVertex, position, director);
                collection.Add(node);
            }
            //vertexNode.AdjacentVertices = collection;
            return(vertexNode);
        }
Example #6
0
        public List <Queue <Tuple <int, int> > > GetElementsWithWeights(IAdjacencyDirector director)
        {
            var queueList = new List <Queue <Tuple <int, int> > >()
            {
            };

            foreach (var positionQueue in this._positionQueueList)
            {
                var queue = new Queue <Tuple <int, int> >();
                foreach (var i in positionQueue)
                {
                    var weight = director.VertexDataProvider.Elements[i].Weight;
                    var tuple  = new Tuple <int, int>(i, weight);
                    queue.Enqueue(tuple);
                }
                queueList.Add(queue);
            }
            return(queueList);
        }
Example #7
0
 public bool DoesCutOrphanVertex(int vertexPosition1, int vertexPosition2, IAdjacencyDirector director)
 {
     return(director.DoesCutOrphanVertex(vertexPosition1, vertexPosition2));
 }
Example #8
0
 public IDictionary <int, IAdjacencyDirectableVisitable> RequestDirectables(IAdjacencyDirector director)
 {
     return(director.DirectableList);
 }
Example #9
0
 public void Register(IAdjacencyDirector director)
 {
     director.Register(this);
 }