1
1
<?php
2
+
2
3
namespace Mouf \Database \SchemaAnalyzer ;
3
4
4
- use Doctrine \Common \Cache \ArrayCache ;
5
- use Doctrine \DBAL \Schema \Schema ;
6
5
use Fhaculty \Graph \Graph ;
7
6
use Fhaculty \Graph \Vertex ;
8
7
use Fhaculty \Graph \Edge ;
9
8
10
9
class MultiDijkstraTest extends \PHPUnit_Framework_TestCase
11
10
{
12
- public function testDijkstra () {
11
+ public function testDijkstra ()
12
+ {
13
13
$ graph = new Graph ();
14
14
15
- $ a = $ graph ->createVertex (" a " );
16
- $ b = $ graph ->createVertex (" b " );
17
- $ c = $ graph ->createVertex (" c " );
18
- $ d = $ graph ->createVertex (" d " );
19
- $ e = $ graph ->createVertex (" e " );
20
- $ f = $ graph ->createVertex (" f " );
21
- $ g = $ graph ->createVertex (" g " );
22
- $ h = $ graph ->createVertex (" h " );
23
- $ i = $ graph ->createVertex (" i " );
24
- $ j = $ graph ->createVertex (" j " );
15
+ $ a = $ graph ->createVertex (' a ' );
16
+ $ b = $ graph ->createVertex (' b ' );
17
+ $ c = $ graph ->createVertex (' c ' );
18
+ $ d = $ graph ->createVertex (' d ' );
19
+ $ e = $ graph ->createVertex (' e ' );
20
+ $ f = $ graph ->createVertex (' f ' );
21
+ $ g = $ graph ->createVertex (' g ' );
22
+ $ h = $ graph ->createVertex (' h ' );
23
+ $ i = $ graph ->createVertex (' i ' );
24
+ $ j = $ graph ->createVertex (' j ' );
25
25
26
26
$ a ->createEdge ($ b )->setWeight (85 );
27
27
$ a ->createEdge ($ c )->setWeight (217 );
@@ -50,13 +50,14 @@ public function testDijkstra() {
50
50
/**
51
51
* @expectedException \Mouf\Database\SchemaAnalyzer\MultiDijkstraAmbiguityException
52
52
*/
53
- public function testDijkstraAmbiguity () {
53
+ public function testDijkstraAmbiguity ()
54
+ {
54
55
$ graph = new Graph ();
55
56
56
- $ a = $ graph ->createVertex (" a " );
57
- $ b = $ graph ->createVertex (" b " );
58
- $ c = $ graph ->createVertex (" c " );
59
- $ d = $ graph ->createVertex (" d " );
57
+ $ a = $ graph ->createVertex (' a ' );
58
+ $ b = $ graph ->createVertex (' b ' );
59
+ $ c = $ graph ->createVertex (' c ' );
60
+ $ d = $ graph ->createVertex (' d ' );
60
61
61
62
$ a ->createEdge ($ b )->setWeight (12 );
62
63
$ a ->createEdge ($ c )->setWeight (42 );
@@ -71,13 +72,14 @@ public function testDijkstraAmbiguity() {
71
72
/**
72
73
* @expectedException \Mouf\Database\SchemaAnalyzer\MultiDijkstraNoPathException
73
74
*/
74
- public function testDijkstraNoPath () {
75
+ public function testDijkstraNoPath ()
76
+ {
75
77
$ graph = new Graph ();
76
78
77
- $ a = $ graph ->createVertex (" a " );
78
- $ b = $ graph ->createVertex (" b " );
79
- $ c = $ graph ->createVertex (" c " );
80
- $ d = $ graph ->createVertex (" d " );
79
+ $ a = $ graph ->createVertex (' a ' );
80
+ $ b = $ graph ->createVertex (' b ' );
81
+ $ c = $ graph ->createVertex (' c ' );
82
+ $ d = $ graph ->createVertex (' d ' );
81
83
82
84
$ a ->createEdge ($ b )->setWeight (12 );
83
85
$ a ->createEdge ($ c )->setWeight (42 );
@@ -88,30 +90,32 @@ public function testDijkstraNoPath() {
88
90
/**
89
91
* @expectedException \Fhaculty\Graph\Exception\UnexpectedValueException
90
92
*/
91
- public function testDijkstraNegativeWeight () {
93
+ public function testDijkstraNegativeWeight ()
94
+ {
92
95
$ graph = new Graph ();
93
96
94
- $ a = $ graph ->createVertex (" a " );
95
- $ b = $ graph ->createVertex (" b " );
97
+ $ a = $ graph ->createVertex (' a ' );
98
+ $ b = $ graph ->createVertex (' b ' );
96
99
97
100
$ a ->createEdge ($ b )->setWeight (-12 );
98
101
99
102
MultiDijkstra::findShortestPaths ($ a , $ b );
100
103
}
101
104
102
- public function testOptimizedExit () {
105
+ public function testOptimizedExit ()
106
+ {
103
107
$ graph = new Graph ();
104
108
105
- $ a = $ graph ->createVertex (" a " );
106
- $ b = $ graph ->createVertex (" b " );
107
- $ c = $ graph ->createVertex (" c " );
108
- $ d = $ graph ->createVertex (" d " );
109
- $ e = $ graph ->createVertex (" e " );
110
- $ f = $ graph ->createVertex (" f " );
111
- $ g = $ graph ->createVertex (" g " );
112
- $ h = $ graph ->createVertex (" h " );
113
- $ i = $ graph ->createVertex (" i " );
114
- $ j = $ graph ->createVertex (" j " );
109
+ $ a = $ graph ->createVertex (' a ' );
110
+ $ b = $ graph ->createVertex (' b ' );
111
+ $ c = $ graph ->createVertex (' c ' );
112
+ $ d = $ graph ->createVertex (' d ' );
113
+ $ e = $ graph ->createVertex (' e ' );
114
+ $ f = $ graph ->createVertex (' f ' );
115
+ $ g = $ graph ->createVertex (' g ' );
116
+ $ h = $ graph ->createVertex (' h ' );
117
+ $ i = $ graph ->createVertex (' i ' );
118
+ $ j = $ graph ->createVertex (' j ' );
115
119
116
120
$ a ->createEdge ($ b )->setWeight (1 );
117
121
$ a ->createEdge ($ c )->setWeight (217 );
@@ -134,17 +138,19 @@ public function testOptimizedExit() {
134
138
$ this ->assertTrue ($ this ->hasVertex ($ edges [0 ], $ b ));
135
139
}
136
140
137
- private function hasVertex (Edge \Base $ edge , Vertex $ vertex ) {
141
+ private function hasVertex (Edge \Base $ edge , Vertex $ vertex )
142
+ {
138
143
return $ edge ->getVerticesStart ()->getVertexFirst () === $ vertex || $ edge ->getVerticesTarget ()->getVertexFirst () === $ vertex ;
139
144
}
140
145
141
- public function testDijkstraAmbiguity2 () {
146
+ public function testDijkstraAmbiguity2 ()
147
+ {
142
148
$ graph = new Graph ();
143
149
144
- $ a = $ graph ->createVertex (" a " );
145
- $ b = $ graph ->createVertex (" b " );
146
- $ c = $ graph ->createVertex (" c " );
147
- $ d = $ graph ->createVertex (" d " );
150
+ $ a = $ graph ->createVertex (' a ' );
151
+ $ b = $ graph ->createVertex (' b ' );
152
+ $ c = $ graph ->createVertex (' c ' );
153
+ $ d = $ graph ->createVertex (' d ' );
148
154
149
155
$ a ->createEdge ($ b )->setWeight (12 );
150
156
$ a ->createEdge ($ c )->setWeight (42 );
@@ -170,14 +176,15 @@ public function testDijkstraAmbiguity2() {
170
176
$ this ->assertTrue ($ this ->hasVertex ($ paths [1 ][1 ], $ d ));
171
177
}
172
178
173
- public function testDijkstraAmbiguity3 () {
179
+ public function testDijkstraAmbiguity3 ()
180
+ {
174
181
$ graph = new Graph ();
175
182
176
- $ a = $ graph ->createVertex (" a " );
177
- $ b = $ graph ->createVertex (" b " );
178
- $ c = $ graph ->createVertex (" c " );
179
- $ d = $ graph ->createVertex (" d " );
180
- $ e = $ graph ->createVertex (" e " );
183
+ $ a = $ graph ->createVertex (' a ' );
184
+ $ b = $ graph ->createVertex (' b ' );
185
+ $ c = $ graph ->createVertex (' c ' );
186
+ $ d = $ graph ->createVertex (' d ' );
187
+ $ e = $ graph ->createVertex (' e ' );
181
188
182
189
$ a ->createEdge ($ b )->setWeight (12 );
183
190
$ a ->createEdge ($ c )->setWeight (42 );
@@ -192,5 +199,4 @@ public function testDijkstraAmbiguity3() {
192
199
193
200
$ this ->assertCount (4 , $ paths );
194
201
}
195
-
196
202
}
0 commit comments