/** * Get the <a href="http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29">diameter</a> of a graph. * * This will throw if the list cannot be fetched from the server * This does not support 'batchsize', 'limit' and 'count'.<br><br> * * @throws Exception * * @param mixed $graph - graph name as a string or instance of Graph * * @param bool|array $options - an array of optional parameters: * <ul><br> * <li><b>direction</b> - The direction of the edges as a string. * Possible values are *outbound*, *inbound* and *any* (default).</li> * <li><b>algorithm</b> - The algorithm to calculate the shortest paths. If both start and end vertex examples are empty * <a href="http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm">Floyd-Warshall</a> is used, otherwise the * default is <a "href=http://en.wikipedia.org/wiki/Dijkstra's_algorithm">Dijkstra</a>. * <li><b>weight</b> - The name of the attribute of the edges containing the length as a string. * <li><b>defaultWeight</b> - Only used with the option *weight*. If an edge does not have the attribute named as * defined in option *weight* this default. * </ul> * * * @return double */ public function getDiameter($graph, $options = array()) { if ($graph instanceof Graph) { $graph = $graph->getKey(); } $options['objectType'] = 'figure'; $data = array_merge($options, $this->getCursorOptions($options)); $statement = new Statement($this->getConnection(), array("query" => '')); $statement->setResultType($options['objectType']); $aql = "RETURN GRAPH_DIAMETER(@graphName, @options) "; if (isset($options['direction'])) { if ($options['direction'] === "in") { $options['direction'] = "inbound"; } if ($options['direction'] === "out") { $options['direction'] = "outbound"; } } $statement->bind('graphName', $graph); $statement->bind('options', $options); $statement->setQuery($aql); $a = $statement->execute()->getAll(); return $a[0]; }