Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }