示例#1
0
文件: FlowTest.php 项目: feffi/graph
 /**
  * @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));
 }
示例#2
0
文件: Base.php 项目: feffi/graph
 /**
  * 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;
 }