Files
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

64 lines
1.8 KiB
PHP

<?php
use Fhaculty\Graph\Graph;
use Graphp\Algorithms\MaximumMatching\Flow;
use PHPUnit\Framework\TestCase;
class FlowTest extends TestCase
{
// /**
// * run algorithm with small graph and check result against known result
// */
// public function testKnownResult()
// {
// $loader = new EdgeListBipartit(PATH_DATA . 'Matching_100_100.txt');
// $loader->setEnableDirectedEdges(false);
// $graph = $loader->createGraph();
// $alg = new Flow($graph);
// $this->assertEquals(100, $alg->getNumberOfMatches());
// }
public function testSingleEdge()
{
$graph = new Graph();
$edge = $graph->createVertex(0)->setGroup(0)->createEdge($graph->createVertex(1)->setGroup(1));
$alg = new Flow($graph);
// correct number of edges
$this->assertEquals(1, $alg->getNumberOfMatches());
// actual edge instance returned
$this->assertEquals(array($edge), $alg->getEdges()->getVector());
// check
$flowgraph = $alg->createGraph();
$this->assertInstanceOf('Fhaculty\Graph\Graph', $flowgraph);
}
/**
* expect exception for directed edges
* @expectedException UnexpectedValueException
*/
public function testInvalidDirected()
{
$graph = new Graph();
$graph->createVertex(0)->setGroup(0)->createEdgeTo($graph->createVertex(1)->setGroup(1));
$alg = new Flow($graph);
$alg->getNumberOfMatches();
}
/**
* expect exception for non-bipartit graphs
* @expectedException UnexpectedValueException
*/
public function testInvalidBipartit()
{
$graph = new Graph();
$graph->createVertex(0)->setGroup(1)->createEdge($graph->createVertex(1)->setGroup(1));
$alg = new Flow($graph);
$alg->getNumberOfMatches();
}
}