public function __construct(Node $node, float $weight = null) { $this->node = $node; $this->weight = $weight ?: $this->generateRandomWeight(); }