/** * Inserts the given edge into this graph. * * @param object Edge $edge The edge to insert. */ protected function insertEdge(Edge $edge) { $v = $edge->getV0()->getNumber(); $w = $edge->getV1()->getNumber(); if ($this->matrix[array($v, $w)] !== NULL) { throw new ArgumentError(); } if ($v == $w) { throw new ArgumentError(); } $this->matrix[array($v, $w)] = $edge; $this->matrix[array($w, $v)] = $edge; ++$this->numberOfEdges; }