/** * @param Directed $edge * @param array $path */ private function walkOn(Directed $edge, array $path = array()) { $vertexStart = $edge->getVertexStart()->getId(); if (in_array($vertexStart, $path)) { $path[] = $vertexStart; $path = array_slice($path, array_search($vertexStart, $path)); $this->addCycle($path); } else { $path[] = $vertexStart; $edgesOut = $edge->getVertexEnd()->getEdgesOut(); foreach ($edgesOut as $edgeOut) { $this->walkOn($edgeOut, $path); } } }
/** * @param Directed $edge * @return array */ private function extractEdge(Directed $edge) { return array('from' => $edge->getVertexStart()->getId(), 'to' => $edge->getVertexEnd()->getId(), 'locations' => $this->extractEntities($edge->getAttribute('locations', array())), 'belongsToCycle' => $edge->getAttribute('belongsToCycle', false), 'referenceValidatorMessages' => $edge->getAttribute('referenceValidatorMessages')); }
/** * Get edge id * * @param \Fhaculty\Graph\Edge\Directed $edge * * @return string */ private function getEdgeId($edge) { return $edge->getVertexStart()->getId() . '_' . $edge->getVertexEnd()->getId(); }