public ReindexedDataResult <GraphConnectivityDefinition <TEdgeData> > CreateCompacted <TEdgeData>(
            GraphConnectivityDefinition <TEdgeData> source,
            IVertexAdjacencyFactory <TEdgeData> verticesFactory,
            bool sharedVerticesInstances,
            IEqualityComparer <VertexAdjacency <TEdgeData> > vertexEqualityComparer = null)
        {
            var oldVertices = source.ToArray();

            var map = oldVertices.SortWithReindexingResult(VertexAdjacencyComparer <TEdgeData> .DefaultWithHighestNumberOfEdgesFirst);

            var cloned = Create(oldVertices,
                                new ReindexedVertexAdjacencyFactoryWrapper <TEdgeData>(map, verticesFactory ?? new VertexAdjacencyFactory <TEdgeData>()), d => d,
                                sharedVerticesInstances, vertexEqualityComparer);

            return(map.ToReindexedDataResult(cloned));
        }
예제 #2
0
 public void Deconstruct(out GraphConnectivityDefinition <TEdgeData> connectivity, out ISymbolToIndexReadOnlyConverter <TSymbol> symbolToIndexConverter)
 {
     connectivity           = Connectivity;
     symbolToIndexConverter = SymbolToIndexConverter;
 }
예제 #3
0
 /// <summary>Initializes a new instance of the <see cref="ReadOnlySymbolGraph{TEdgeData, TSymbol}" /> class.</summary>
 /// <param name="connectivity">The read-only connectivity.</param>
 /// <param name="symbolProvider">The read-only symbol provider.</param>
 internal ReadOnlySymbolGraph(GraphConnectivityDefinition <TEdgeData> connectivity,
                              ISymbolToIndexReadOnlyConverter <TSymbol> symbolProvider)
 {
     Connectivity           = connectivity;
     SymbolToIndexConverter = symbolProvider;
 }
 public GraphConnectivityDefinitionEdgeFilter(GraphConnectivityDefinition <TEdgeData> wrapped, Func <Edge <int, TEdgeData>, bool> selectEdgePredicate)
 {
     Wrapped             = wrapped ?? throw new ArgumentNullException(nameof(wrapped));
     SelectEdgePredicate = selectEdgePredicate ?? throw new ArgumentNullException(nameof(selectEdgePredicate));
     _adjWrappers        = new Dictionary <int, VertexAdjacency <TEdgeData> >(wrapped.Count);
 }