/// <inheritdoc /> public override bool AddEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, TEdgeData edgeData, out ReplaceableVertexAdjacency <TEdgeData> final) { final = vertexFactory.GetInstance(EnumerableExtensions.Enumerate(AdjacentEdge.Create(destVertexIndex, edgeData)), 1); return(true); }
/// <inheritdoc /> public override bool AddEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, TEdgeData edgeData, out ReplaceableVertexAdjacency <TEdgeData> final) { if (_adj == null) { _adj = new Dictionary <int, TEdgeData>(1); } var count = _adj.Count; _adj[destVertexIndex] = edgeData; final = this; return(_adj.Count > count); }
/// <inheritdoc /> public override bool RemoveEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, out ReplaceableVertexAdjacency <TEdgeData> final) { if (!ContainsEdgeToIndex(destVertexIndex)) { final = default; return(false); } final = vertexFactory.GetInstance( this.Where(a => a.Destination != destVertexIndex), EdgesCount - 1); return(true); }
/// <inheritdoc /> public override bool AddEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, TEdgeData edgeData, out ReplaceableVertexAdjacency <TEdgeData> final) { if (ContainsEdgeToIndex(destVertexIndex)) { final = this; return(false); } final = vertexFactory.GetInstance( this.Append(AdjacentEdge.Create(destVertexIndex, edgeData)), EdgesCount + 1); return(true); }
/// <inheritdoc /> public override bool RemoveEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, out ReplaceableVertexAdjacency <TEdgeData> final) { if (_adj == null || !_adj.Remove(destVertexIndex)) { final = this; return(false); } if (!vertexFactory.ProvidesFixedCapacity(_adj.Count)) { final = this; return(true); } final = vertexFactory.GetInstance(_adj.Select(AdjacentEdge.Create), _adj.Count); return(true); }
/// <inheritdoc /> public override bool RemoveEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, out ReplaceableVertexAdjacency <TEdgeData> final) { final = this; return(false); }
/// <summary> /// Adds the edge to the vertex given by the <paramref name="final" /> parameter. /// If the maximal capacity of the current vertex is not enough, it will replace the <paramref name="final" /> vertex /// by a new one with sufficient capacity and will copy all edges to the new vertex instance, returning the current /// instance /// to the specified <paramref name="vertexFactory" />. /// </summary> /// <param name="vertexFactory"></param> /// <param name="destVertexIndex">Index of the destination vertex.</param> /// <param name="edgeData">The edge data.</param> /// <param name="final">The reference to the target vertex, can be replaced in case of to small capacity.</param> /// <returns> /// <c>true</c> if new edge was added (the number of edges increased). /// </returns> public abstract bool AddEdge(ReplaceableVertexFactoryInterface <TEdgeData> vertexFactory, int destVertexIndex, TEdgeData edgeData, out ReplaceableVertexAdjacency <TEdgeData> final);