hexlet/graphs

v1.1.0 2022-01-16 12:30 UTC

This package is not auto-updated.

Last update: 2024-09-23 01:16:51 UTC


README

github action status

用于处理图的函数。

示例

<?php

use function Php\Graphs\graphs\makeJoints;
use function Php\Graphs\graphs\buildTreeFromLeaf;
use function Php\Graphs\graphs\sortJoints;

$tree = ['B', [
    ['D'],
    ['A', [
        ['C', [
            ['F'],
            ['E'],
        ]],
    ]],
]];

$joints = makeJoints($tree);
$transformed = buildTreeFromLeaf($joints, 'C');
// ['C', [
//     ['F'],
//     ['E'],
//     ['A', [
//         ['B', [
//             ['D'],
//         ]],
//     ]],
// ]];

sortTree($transformed);
// ['C', [
//     ['A', [
//         ['B', [
//             ['D'],
//         ]],
//     ]],
//     ['E'],
//     ['F'],
// ]];

Hexlet Ltd. logo

此存储库由Hexlet团队和社区创建和维护,Hexlet是一个教育项目。了解更多关于Hexlet

hexlet-friends 上查看最活跃的贡献者。