Skip to content

Commit 6c8f3b3

Browse files
committed
Remove unneeded code
Direction is already checked by residual graph
1 parent aad0ad2 commit 6c8f3b3

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

src/MinimumCostFlow/SuccessiveShortestPath.php

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ public function createGraph()
4343
if ($edge->getWeight() < 0) {
4444
$flow = $edge->getCapacity();
4545

46-
if ($edge instanceof EdgeDirected) {
47-
$startVertex = $edge->getVertexStart();
48-
$endVertex = $edge->getVertexEnd();
49-
50-
// add balance to start- and end-vertex
51-
$this->addBalance($startVertex, $flow);
52-
$this->addBalance($endVertex, - $flow);
53-
} else {
54-
throw new UnexpectedValueException('Undirected Edges not suported');
55-
}
46+
$startVertex = $edge->getVertexStart();
47+
$endVertex = $edge->getVertexEnd();
48+
49+
// add balance to start- and end-vertex
50+
$this->addBalance($startVertex, $flow);
51+
$this->addBalance($endVertex, - $flow);
5652
}
5753

5854
$edge->setFlow($flow);
@@ -114,30 +110,6 @@ public function createGraph()
114110
return $resultGraph;
115111
}
116112

117-
/**
118-
* check if balance on each vertex of the given graph matches the original graph's
119-
*
120-
* @param Graph $graph
121-
* @return boolean
122-
* @throws Exception if given graph is not a clone of the original graph (each vertex has to be present in both graphs)
123-
* @uses Graph::getNumberOfVertices()
124-
* @uses Graph::getBalanace()
125-
* @uses Graph::getVertex()
126-
*/
127-
private function isBalanceReached(Graph $graph)
128-
{
129-
if ($graph->getNumberOfVertices() !== $this->graph->getNumberOfVertices()) {
130-
throw new DomainException('Given graph does not appear to be a clone of input graph');
131-
}
132-
foreach ($this->graph->getVertices()->getMap() as $vid => $vertex) {
133-
if ($vertex->getBalance() !== $graph->getVertex($vid)->getBalance()) {
134-
return false;
135-
}
136-
}
137-
138-
return true;
139-
}
140-
141113
/**
142114
*
143115
*

0 commit comments

Comments
 (0)