Exemple #1
0
 /**
  * @expectedException UnexpectedValueException
  */
 public function testVertexWithUndirectedEdgeHasInvalidFlow()
 {
     // 1 -- 2
     $graph = new Graph();
     $graph->createVertex(1)->createEdge($graph->createVertex(2))->setFlow(10);
     $alg = new AlgorithmFlow($graph);
     $alg->getFlowVertex($graph->getVertex(1));
 }
Exemple #2
0
 /**
  * check if balance is okay and throw exception otherwise
  *
  * @throws UnexpectedValueException
  * @return AlgorithmMCF             $this (chainable)
  */
 protected function checkBalance()
 {
     $alg = new AlgorithmFlow($this->graph);
     $balance = $alg->getBalance();
     $tolerance = 1.0E-6;
     if ($balance >= $tolerance || $balance <= -$tolerance) {
         throw new UnexpectedValueException('The given graph is not balanced value is: ' . $balance);
     }
     return $this;
 }