/** * {@inheritdoc} */ public function transpose() { $graph = new self(); $this->eachEdge(function ($edge) use(&$graph) { $graph->addDirectedEdge($edge[1], $edge[0]); }); return $graph; }