Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
8 / 8
ReversedDigraph
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
8 / 8
 getReversed()
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
8 / 8
<?php
/*
 * Mondrian
 */
namespace Trismegiste\Mondrian\Graph;
/**
 * ReversedDigraph is a decorator which provides a reversed
 * graph of this directed graph
 */
class ReversedDigraph extends Algorithm
{
    /**
     * Build the reversed digraph of this digraph
     *
     * @return Digraph
     */
    public function getReversed()
    {
        $newGraph = new Digraph();
        foreach ($this->graph->getVertexSet() as $vx) {
            // for isolated vertex :
            $newGraph->addVertex($vx);
            // we reverse each edge :
            foreach ($this->graph->getSuccessor($vx) as $vy) {
                $newGraph->addEdge($vy, $vx);
            }
        }
        return $newGraph;
    }
}