File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fhaculty \Graph \Algorithm ;
4
+
5
+ use Fhaculty \Graph \Set ;
6
+ use Fhaculty \Graph \Algorithm \Base ;
7
+ use Fhaculty \Graph \Edge \Directed as EdgeDirected ;
8
+
9
+ class Directed extends Base
10
+ {
11
+ private $ set ;
12
+
13
+ public function __construct (Set $ graphOrWalk )
14
+ {
15
+ $ this ->set = $ graphOrWalk ;
16
+ }
17
+
18
+ /**
19
+ * checks whether the graph has any directed edges (aka digraph)
20
+ *
21
+ * @return boolean
22
+ */
23
+ public function isDirected ()
24
+ {
25
+ foreach ($ this ->set ->getEdges () as $ edge ) {
26
+ if ($ edge instanceof EdgeDirected) {
27
+ return true ;
28
+ }
29
+ }
30
+
31
+ return false ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace Fhaculty \Graph \Algorithm \MaximumMatching ;
4
4
5
+ use Fhaculty \Graph \Algorithm \Directed ;
6
+
5
7
use Fhaculty \Graph \Exception \LogicException ;
6
8
7
9
use Fhaculty \Graph \Exception \UnexpectedValueException ;
@@ -14,7 +16,8 @@ class Flow extends Base
14
16
{
15
17
public function getEdges ()
16
18
{
17
- if ($ this ->graph ->isDirected ()) {
19
+ $ alg = new Directed ($ this ->graph );
20
+ if ($ alg ->isDirected ()) {
18
21
throw new UnexpectedValueException ('Input graph contains directed edges ' );
19
22
}
20
23
You can’t perform that action at this time.
0 commit comments