Skip to content

Commit 7f4015b

Browse files
committed
Remove unneeded methods getVerticesIds() and getVerticesId()
1 parent 7afe56d commit 7f4015b

File tree

5 files changed

+12
-28
lines changed

5 files changed

+12
-28
lines changed

src/ConnectedComponents.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ConnectedComponents extends BaseGraph
1818
* @param Vertex $vertex
1919
* @return Graph
2020
* @throws InvalidArgumentException if given vertex is not from same graph
21-
* @uses AlgorithmSearchBreadthFirst::getVerticesIds()
21+
* @uses AlgorithmSearchBreadthFirst::getVertices()
2222
* @uses Graph::createGraphCloneVertices()
2323
*/
2424
public function createGraphComponentVertex(Vertex $vertex)
@@ -30,6 +30,11 @@ public function createGraphComponentVertex(Vertex $vertex)
3030
return $this->graph->createGraphCloneVertices($this->createSearch($vertex)->getVertices());
3131
}
3232

33+
/**
34+
*
35+
* @param Vertex $vertex
36+
* @return SearchBreadthFirst
37+
*/
3338
private function createSearch(Vertex $vertex)
3439
{
3540
$alg = new SearchBreadthFirst($vertex);
@@ -58,7 +63,7 @@ public function isSingle()
5863
/**
5964
* @return int number of components
6065
* @uses Graph::getVertices()
61-
* @uses AlgorithmSearchBreadthFirst::getVerticesIds()
66+
* @uses AlgorithmSearchBreadthFirst::getVertices()
6267
*/
6368
public function getNumberOfComponents()
6469
{
@@ -71,7 +76,7 @@ public function getNumberOfComponents()
7176
if (!isset($visitedVertices[$vid])) {
7277

7378
// get all vertices of this component
74-
$newVertices = $this->createSearch($vertex)->getVerticesIds();
79+
$newVertices = $this->createSearch($vertex)->getVertices()->getIds();
7580

7681
++$components;
7782

src/DetectNegativeCycle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function hasCycleNegative()
3636
*
3737
* @return Cycle
3838
* @throws UnderflowException if there's no negative cycle
39-
* @uses AlgorithmSpMooreBellmanFord::getVerticesId()
39+
* @uses AlgorithmSpMooreBellmanFord::getVertices()
4040
*/
4141
public function getCycleNegative()
4242
{
@@ -51,7 +51,7 @@ public function getCycleNegative()
5151

5252
try {
5353
// try to get all connected vertices (or throw new cycle)
54-
foreach ($alg->getVerticesId() as $vid) {
54+
foreach ($alg->getVertices()->getIds() as $vid) {
5555
// getting connected vertices succeeded, so skip over all of them
5656
$verticesVisited[$vid] = true;
5757
// no cycle found, check next vertex...

src/MinimumSpanningTree/Kruskal.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ public function getEdges()
7878
// Füge billigste Kanten zu neuen Graphen hinzu und verschmelze teilgragen wenn es nötig ist (keine Kreise)
7979
// solange ich mehr als einen Graphen habe mit weniger als n-1 kanten (bei n knoten im original)
8080
foreach ($sortedEdges as $edge) {
81+
/* @var $edge EdgeDirected */
8182
// Gucke Kante an:
8283

83-
$vertices = $edge->getVerticesId();
84+
$vertices = $edge->getVertices()->getIds();
8485

8586
$aId = $vertices[0];
8687
$bId = $vertices[1];

src/Search/Base.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,4 @@ public function getNumberOfVertices()
6464
* @return Vertices
6565
*/
6666
abstract public function getVertices();
67-
68-
/**
69-
* get array of all vertices' IDs that can be reached from start vertex
70-
*
71-
* @return int[]
72-
* @uses AlgorithmSearch::getVertices()
73-
*/
74-
public function getVerticesIds()
75-
{
76-
return $this->getVertices()->getIds();
77-
}
7867
}

src/ShortestPath/Base.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,6 @@ public function getVertices()
110110
return new Vertices($vertices);
111111
}
112112

113-
/**
114-
* get array of all vertices' IDs the given start vertex has a path to
115-
*
116-
* @return int[]
117-
* @uses AlgorithmSp::getDistanceMap()
118-
*/
119-
public function getVerticesId()
120-
{
121-
return array_keys($this->getDistanceMap());
122-
}
123-
124113
/**
125114
* get map of vertex IDs to distance
126115
*

0 commit comments

Comments
 (0)