| Total Complexity | 8 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class GraphClient |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Maximum degree |
||
| 13 | * |
||
| 14 | * @param Graph $graph |
||
| 15 | * @return int |
||
| 16 | */ |
||
| 17 | public static function maxDegree(Graph $graph) |
||
| 18 | { |
||
| 19 | // init |
||
| 20 | $max = 0; |
||
| 21 | // get vertices |
||
| 22 | $vertices = $graph->getVertices(); |
||
| 23 | // iterate over the set of vertices |
||
| 24 | for ($vertex = 0; $vertex < $vertices; $vertex++) { |
||
| 25 | // local var |
||
| 26 | $degree = $graph->degree($vertex); |
||
| 27 | // check if this vertex degrees are greater than the current max |
||
| 28 | if ($degree > $max) { |
||
| 29 | // update the max |
||
| 30 | $max = $degree; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | // return the max found |
||
| 34 | return $max; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Average degree |
||
| 39 | * |
||
| 40 | * @param Graph $graph |
||
| 41 | * @return int |
||
| 42 | */ |
||
| 43 | public static function avgDegree(Graph $graph) |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * number of self-loops |
||
| 51 | * |
||
| 52 | * @param Graph $graph |
||
| 53 | * @return int |
||
| 54 | */ |
||
| 55 | public static function numberOfSelfLoops(Graph $graph) |
||
| 76 |