Skip to content

Commit da6d8f0

Browse files
committed
Move Set::hasFlow() to new Algorithm\Flow
1 parent 937ca8e commit da6d8f0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Flow.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Fhaculty\Graph\Algorithm;
4+
5+
use Fhaculty\Graph\Algorithm\BaseGraph;
6+
use Fhaculty\Graph\Edge\Base as Edge;
7+
use Fhaculty\Graph\Graph;
8+
9+
/**
10+
* Basic algorithms for working with flow graphs
11+
*
12+
* A flow network (also known as a transportation network) is a directed graph
13+
* where each edge has a capacity and each edge receives a flow.
14+
*
15+
* @link http://en.wikipedia.org/wiki/Flow_network
16+
* @see Algorithm\Balance
17+
*/
18+
class Flow extends BaseSet
19+
{
20+
/**
21+
* check if this graph has any flow set (any edge has a non-NULL flow)
22+
*
23+
* @return boolean
24+
* @uses Edge::getFlow()
25+
*/
26+
public function hasFlow()
27+
{
28+
foreach ($this->set->getEdges() as $edge) {
29+
if ($edge->getFlow() !== NULL) {
30+
return true;
31+
}
32+
}
33+
34+
return false;
35+
}
36+
}

0 commit comments

Comments
 (0)