node1 = $node1; $this->node2 = $node2; $this->weight = $weight; $this->isDirected = $isDirected; } /** * Get nodes of the edge. * * @return Node[] * * @since 1.0.0 */ public function getNodes() : array { return [$this->node1, $this->node2]; } /** * Get node of the edge. * * @return Node * * @since 1.0.0 */ public function getNode1() : Node { return $this->node1; } /** * Get node of the edge. * * @return Node * * @since 1.0.0 */ public function getNode2() : Node { return $this->node2; } /** * Get weight * * @return float * * @since 1.0.0 */ public function getWeight() : float { return $this->weight; } /** * Is directed edge * * @return bool * * @since 1.0.0 */ public function isDirected() : bool { return $this->isDirected; } /** * Compare edge weights * * @param Edge $e1 Edge 1 * @param Edge $e2 Edge 2 * * @return int * * @since 1.0.0 */ public static function compare(Edge $e1, Edge $e2) : int { return $e1->getWeight() <=> $e2->getWeight(); } }