Skip to content

Commit 9635dcd

Browse files
committed
Replace all occurances of $graph->getNumberOfEdges()
replaced with count($graph->getEdges())
1 parent cb82e1f commit 9635dcd

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Property/WalkProperty.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function hasCycle()
162162
*/
163163
public function isLoop()
164164
{
165-
return ($this->walk->getNumberOfEdges() === 1 && $this->isCycle());
165+
return (count($this->walk->getEdges()) === 1 && $this->isCycle());
166166
}
167167

168168
/**
@@ -214,7 +214,7 @@ public function hasLoop()
214214
public function isDigon()
215215
{
216216
// exactly 2 edges
217-
return ($this->walk->getNumberOfEdges() === 2 &&
217+
return (count($this->walk->getEdges()) === 2 &&
218218
// no duplicate edges
219219
!$this->hasArrayDuplicates($this->walk->getEdges()->getVector()) &&
220220
// exactly two distinct vertices
@@ -238,7 +238,7 @@ public function isDigon()
238238
public function isTriangle()
239239
{
240240
// exactly 3 (implicitly distinct) edges
241-
return ($this->walk->getNumberOfEdges() === 3 &&
241+
return (count($this->walk->getEdges()) === 3 &&
242242
// exactly three distinct vertices
243243
count($this->walk->getVertices()->getVerticesDistinct()) === 3 &&
244244
// this is actually a cycle

tests/Property/WalkPropertyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testTrivialGraph()
1515
$walk = Walk::factoryFromEdges(array(), $v1);
1616

1717
$this->assertEquals(1, count($walk->getVertices()));
18-
$this->assertEquals(0, $walk->getNumberOfEdges());
18+
$this->assertEquals(0, count($walk->getEdges()));
1919

2020
$alg = new WalkProperty($walk);
2121

@@ -68,7 +68,7 @@ public function testCycle()
6868
$walk = Walk::factoryFromEdges(array($e1, $e2), $v1);
6969

7070
$this->assertEquals(3, count($walk->getVertices()));
71-
$this->assertEquals(2, $walk->getNumberOfEdges());
71+
$this->assertEquals(2, count($walk->getEdges()));
7272

7373
$alg = new WalkProperty($walk);
7474

@@ -171,7 +171,7 @@ public function testSimplePathWithinGraph()
171171
$walk = Walk::factoryFromEdges(array($e2), $v2);
172172

173173
$this->assertEquals(2, count($walk->getVertices()));
174-
$this->assertEquals(1, $walk->getNumberOfEdges());
174+
$this->assertEquals(1, count($walk->getEdges()));
175175

176176
$alg = new WalkProperty($walk);
177177

tests/ShortestPath/BaseShortestPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testGraphCycle()
7979
$this->assertEquals($expectedWeight, $alg->getDistance($v1));
8080

8181
$walk = $alg->getWalkTo($v1);
82-
$this->assertEquals(2, $walk->getNumberOfEdges());
82+
$this->assertEquals(2, count($walk->getEdges()));
8383
}
8484

8585
/**

0 commit comments

Comments
 (0)