public function ensureEdge($from, $to) { $this->ensureVertex($from)->ensureVertex($to); if (!$this->vertices[$from]->contains($to)) { $this->size++; } $this->vertices[$from]->attach($to); $this->vertices[$to]->attach($from); }