Smoren /
graph-tools-php
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Smoren\GraphTools\Models; |
||
| 4 | |||
| 5 | use Smoren\GraphTools\Models\Interfaces\EdgeInterface; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Graph edge's class |
||
| 9 | * @author Smoren <[email protected]> |
||
| 10 | */ |
||
| 11 | class Edge implements EdgeInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var non-empty-string edge's id |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 15 | */ |
||
| 16 | protected string $id; |
||
| 17 | /** |
||
| 18 | * @var non-empty-string edge's type |
||
|
0 ignored issues
–
show
|
|||
| 19 | */ |
||
| 20 | protected string $type; |
||
| 21 | /** |
||
| 22 | * @var non-empty-string start vertex's id of edge |
||
|
0 ignored issues
–
show
|
|||
| 23 | */ |
||
| 24 | protected string $fromId; |
||
| 25 | /** |
||
| 26 | * @var non-empty-string end vertex's id of edge |
||
|
0 ignored issues
–
show
|
|||
| 27 | */ |
||
| 28 | protected string $toId; |
||
| 29 | /** |
||
| 30 | * @var float edge's weight |
||
| 31 | */ |
||
| 32 | protected float $weight; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Edge constructor |
||
| 36 | * @param non-empty-string $id edge's id |
||
|
0 ignored issues
–
show
|
|||
| 37 | * @param non-empty-string $type edge's type |
||
| 38 | * @param non-empty-string $fromId start vertex's id of edge |
||
| 39 | * @param non-empty-string $toId end vertex's id of edge |
||
| 40 | * @param float $weight edge's weight |
||
| 41 | */ |
||
| 42 | public function __construct(string $id, string $type, string $fromId, string $toId, float $weight = 1) |
||
| 43 | { |
||
| 44 | $this->id = $id; |
||
| 45 | $this->type = $type; |
||
| 46 | $this->fromId = $fromId; |
||
| 47 | $this->toId = $toId; |
||
| 48 | $this->weight = $weight; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @inheritDoc |
||
| 53 | */ |
||
| 54 | public function getId(): string |
||
| 55 | { |
||
| 56 | return $this->id; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @inheritDoc |
||
| 61 | */ |
||
| 62 | public function getType(): string |
||
| 63 | { |
||
| 64 | return $this->type; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @inheritDoc |
||
| 69 | */ |
||
| 70 | public function getFromId(): string |
||
| 71 | { |
||
| 72 | return $this->fromId; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @inheritDoc |
||
| 77 | */ |
||
| 78 | public function getToId(): string |
||
| 79 | { |
||
| 80 | return $this->toId; |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @inheritDoc |
||
| 85 | */ |
||
| 86 | public function getWeight(): float |
||
| 87 | { |
||
| 88 | return $this->weight; |
||
| 89 | } |
||
| 90 | } |
||
| 91 |