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); }
//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); }
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); }
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); }
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); }
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); }
public bool DoesCutOrphanVertex(int vertexPosition1, int vertexPosition2, IAdjacencyDirector director) { return(director.DoesCutOrphanVertex(vertexPosition1, vertexPosition2)); }
public IDictionary <int, IAdjacencyDirectableVisitable> RequestDirectables(IAdjacencyDirector director) { return(director.DirectableList); }
public void Register(IAdjacencyDirector director) { director.Register(this); }