定制 noweh/laravel-dijkstra 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

noweh/laravel-dijkstra

最新稳定版本:0.1.0

Composer 安装命令:

composer require noweh/laravel-dijkstra

包简介

Shortest path-algorithm for Laravel.

README 文档

README

Laravel PHP MIT Licensed

A laravel implementation of Dijkstra algorithm.

Dijkstra's algorithm, conceived by computer scientist Edsger Dijkstra, is a graph search algorithm that solves in single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree.

Installation

First you need to add the component to your composer.json

composer require noweh/laravel-dijkstra

Update your packages with composer update or install with composer install.

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Laravel without auto-discovery

After updating composer, add the ServiceProvider to the providers array in config/app.php

Noweh\Dijkstra\DijkstraServiceProvider::class,

Migration

The migrations of this package are publishable under the "migrations" tag via:

php artisan vendor:publish --provider="Noweh\Dijkstra\DijkstraServiceProvider" --tag="migrations"

Usage

Operations with Points and draw graph / find shortest path

    <?php

    /** @var IPointsService $pointsService */
    $pointsService = \Dijkstra::pointsService();

    // Create all points
    $pointsService->createStructure([
            ['name' => 'A', 'x' => 250, 'y' => 120],
            ['name' => 'B', 'x' => 120, 'y' => 228],
            // ...
            ['name' => 'H', 'x' => 400, 'y' => 460]
        ], [
            ['A' => 'B'],
            // ...
            ['H' => 'D']
        ]);

    // add One point
    $pointsService->addPoint(['name' => 'I', 'x' => 60, 'y' => 30]);

    // Remove one point
    $pointsService->removePoint('B');

    // Add relation
    $pointsService->addRelation(['E' => 'I']);

    // Remove relation
    $pointsService->removeRelation(['A' => 'B']);

    // Retrieve all points
    dump($pointsService->getPoints());

    /** @var IGraphService $graphService */
    $graphService = \Dijkstra::graphService();
    $pointFrom = $pointsService->getPoint('B');
    $pointTo = $pointsService->getPoint('C');
    
    dump($graphService->findShortestPath($pointFrom, $pointTo));
    
    // Draw a Graph
    $graphService->drawGraph($pointFrom, $pointTo);

Display example with the use of the drawGraph() method

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固