Example #1
0
 protected BaseAlgorithm(IGraph graph, IEndPoints endPoints)
 {
     visitedVertices = new VisitedVertices();
     parentVertices  = new ParentVertices();
     this.graph      = graph;
     this.endPoints  = new EndPoints(endPoints);
 }
Example #2
0
 public AStarModified(IGraph graph, IEndPoints endPoints, IStepRule stepRule, IHeuristic function)
     : base(graph, endPoints, stepRule, function)
 {
     PercentOfFarthestVerticesToDelete
                     = CalculatePercentOfFarthestVerticesToDelete;
     deletedVertices = new Queue <IVertex>();
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BolRetailerApi"/> class.
 /// Setup the necessary objects. This object can be used to inject via DI.
 /// </summary>
 /// <param name="clientId">The client identifier.</param>
 /// <param name="clientSecret">The client secret.</param>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="testMode">if set to <c>true</c> [test mode].</param>
 public BolRetailerApi(string clientId, string clientSecret, HttpClient httpClient, bool testMode = false)
 {
     RateLimits          = new RateLimits();
     EndPoints           = testMode ? new TestEndPoints() : new EndPoints();
     _httpClient         = httpClient;
     _authorizationToken = new AuthorizationToken(clientId, clientSecret, TokenService);
 }
 public static void Highlight(this IGraphPath self, IEndPoints endpoints)
 {
     self.Path
     .Except(endpoints.Source, endpoints.Target)
     .OfType <IMarkable>()
     .ForEach(vertex => vertex.MarkAsPath());
 }
Example #5
0
 public static void Highlight(this IGraphPath self, IEndPoints endpoints)
 {
     self.Path
     .Where(vertex => !endpoints.IsEndPoint(vertex))
     .OfType <IMarkable>()
     .ForEach(vertex => vertex.MarkAsPath());
 }
Example #6
0
 public HttpPooledClient(HttpReactor reactor, IEndPoints endPoints,
                         TimeSpan connectTimeout, TimeSpan sendTimeout,
                         TimeSpan connectionExpire)
 {
     _reactor = reactor;
     _client  = new HttpClient(endPoints,
                               connectTimeout, sendTimeout, connectionExpire);
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrdersService" /> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="endPoints">The end points.</param>
 /// <param name="authorizationToken">The authorization token.</param>
 /// <param name="rateLimits">The rate limits.</param>
 public OrdersService(
     HttpClient httpClient,
     IEndPoints endPoints,
     IAuthorizationToken authorizationToken,
     RateLimits rateLimits = null)
     : base(httpClient, endPoints, authorizationToken, rateLimits)
 {
 }
Example #8
0
 public GraphPath(ParentVertices parentVertices,
                  IEndPoints endPoints, IGraph graph, IStepRule stepRule)
 {
     this.parentVertices = parentVertices;
     this.graph          = graph;
     this.endPoints      = endPoints;
     this.stepRule       = stepRule;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticatedClientBase"/> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="endPoints">The end points.</param>
 /// <param name="authorizationToken">The authorization token.</param>
 /// <param name="rateLimits">The rate limits.</param>
 protected AuthenticatedClientBase(
     HttpClient httpClient,
     IEndPoints endPoints,
     IAuthorizationToken authorizationToken,
     RateLimits rateLimits = null)
     : base(httpClient, endPoints)
 {
     _authorizationToken = authorizationToken;
     RateLimits          = rateLimits ?? new RateLimits();
 }
Example #10
0
 public GraphPath(ParentVertices parentVertices,
                  IEndPoints endPoints, IGraph graph, IStepRule stepRule)
 {
     path                = new Lazy <IVertex[]>(GetPath);
     pathCost            = new Lazy <double>(ExtractPathCost);
     pathLength          = new Lazy <int>(GetPathLength);
     this.parentVertices = parentVertices;
     this.graph          = graph;
     this.endPoints      = endPoints;
     this.stepRule       = stepRule;
 }
Example #11
0
        public AlgorithmEventArgs(int visitedVertices,
                                  IEndPoints endPoints = null, IVertex vertex = null)
        {
            if (vertex != null)
            {
                IsEndPoint = endPoints?.IsEndPoint(vertex) ?? false;
            }

            Vertex          = vertex ?? new NullVertex();
            VisitedVertices = visitedVertices;
        }
Example #12
0
        public HttpReactor(IEndPoints endPoints, int maxClients,
                           TimeSpan connectTimeout, TimeSpan sendTimeout,
                           TimeSpan connectionExpire)
        {
            _clientQueue = new ConcurrentQueue <HttpPooledClient>();

            for (var i = 0; i < maxClients; i++)
            {
                var client = new HttpPooledClient(this, endPoints,
                                                  connectTimeout, sendTimeout, connectionExpire);

                _clientQueue.Enqueue(client);
            }
        }
Example #13
0
        public HttpClient(IEndPoints endPoints,
                          TimeSpan connectTimeout, TimeSpan sendTimeout,
                          TimeSpan connectionExpire)
        {
            var buffer = new ArraySegment <byte>(new byte[DefaultBufferSize]);

            _message              = new HttpMessage(buffer, DefaultMaxHeadersSize);
            _endPoints            = endPoints;
            _connectTimeoutMicros = connectTimeout.TotalMicroseconds();
            _sendTimeoutMicros    = sendTimeout.TotalMicroseconds();

            _connectionExpireMicros = (connectionExpire == DefaultConnectionExpire)
                ? Int64.MaxValue : connectionExpire.TotalMicroseconds();

            SocketInit();
        }
        public GraphPathTests()
        {
            graphAssemble = new TestGraph2DAssemble();
            expectedPraphPathCoordinates = new ICoordinate[]
            {
                new TestCoordinate(0, 0), //1
                new TestCoordinate(0, 1), //5
                new TestCoordinate(1, 2), //8
                new TestCoordinate(1, 3), //1
                new TestCoordinate(2, 4), //3
                new TestCoordinate(3, 5), //2
                new TestCoordinate(3, 6), //1
                new TestCoordinate(4, 7)  //5
            };
            graph = graphAssemble.AssembleGraph(0);
            var source = graph[expectedPraphPathCoordinates.First()];
            var target = graph[expectedPraphPathCoordinates.Last()];

            endPoints      = new EndPoints(source, target);
            parentVertices = new ParentVertices();
            FormParentVertices(parentVertices);
        }
 protected BaseGreedyAlgorithm(IGraph graph, IEndPoints endPoints)
     : base(graph, endPoints)
 {
     visitedVerticesStack = new Stack <IVertex>();
 }
Example #16
0
 public GraphPath(ParentVertices parentVertices, IEndPoints endPoints, IGraph graph)
     : this(parentVertices, endPoints, graph, new DefaultStepRule())
 {
 }
Example #17
0
 public DepthFirstAlgorithm(IGraph graph, IEndPoints endPoints)
     : this(graph, endPoints, new ManhattanDistance())
 {
 }
Example #18
0
 public DepthFirstAlgorithm(IGraph graph, IEndPoints endPoints, IHeuristic heuristic)
     : base(graph, endPoints)
 {
     this.heuristic = heuristic;
 }
Example #19
0
 public AStarAlgorithm(IGraph graph, IEndPoints endPoints, IStepRule stepRule, IHeuristic function)
     : base(graph, endPoints, stepRule)
 {
     heuristic = function;
 }
Example #20
0
 public EndPoints(IEndPoints endPoints)
 {
     End   = endPoints.End;
     Start = endPoints.Start;
 }
Example #21
0
 public ViaCepService(IHttpClientFactory clientFactory, IEndPoints settings)
 {
     _clientFactory = clientFactory;
     _settings      = settings;
 }
Example #22
0
 public AStarAlgorithm(IGraph graph, IEndPoints endPoints, IHeuristic function)
     : this(graph, endPoints, new DefaultStepRule(), function)
 {
 }
 public DistanceFirstAlgorithm(IGraph graph, IEndPoints endPoints)
     : this(graph, endPoints, new EuclidianDistance())
 {
 }
Example #24
0
 protected abstract IAlgorithm CreateAlgorithm(IGraph graph, IEndPoints endPoints);
Example #25
0
 public CostGreedyAlgorithm(IGraph graph, IEndPoints endPoints, IStepRule stepRule)
     : base(graph, endPoints)
 {
     this.stepRule = stepRule;
 }
Example #26
0
 public AStarAlgorithm(IGraph graph, IEndPoints endPoints, IStepRule stepRule)
     : this(graph, endPoints, stepRule, new ChebyshevDistance())
 {
 }
 public static bool Contains(this IGraph self, IEndPoints endPoints)
 {
     return(self.Contains(endPoints.Source, endPoints.Target));
 }
Example #28
0
 protected BaseWaveAlgorithm(IGraph graph, IEndPoints endPoints)
     : base(graph, endPoints)
 {
     verticesQueue = new Queue <IVertex>();
 }
Example #29
0
 protected override IAlgorithm CreateAlgorithm(IGraph graph, IEndPoints endPoints)
 {
     return(new AStarAlgorithm.AStarAlgorithm(graph, endPoints));
 }
Example #30
0
 public AStarAlgorithm(IGraph graph, IEndPoints endPoints)
     : this(graph, endPoints, new DefaultStepRule(), new ChebyshevDistance())
 {
 }