File tree Expand file tree Collapse file tree 12 files changed +14
-16
lines changed Expand file tree Collapse file tree 12 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ private function createSearch(Vertex $vertex)
65
65
* connected here.
66
66
*
67
67
* @return boolean
68
- * @uses AlgorithmSearchBreadthFirst::getNumberOfVertices()
69
68
* @see self::getNumberOfComponents()
70
69
*/
71
70
public function isSingle ()
@@ -79,7 +78,7 @@ public function isSingle()
79
78
}
80
79
$ alg = $ this ->createSearch ($ vertex );
81
80
82
- return ($ this ->graph ->getNumberOfVertices () === $ alg ->getNumberOfVertices ( ));
81
+ return (count ( $ this ->graph ->getVertices ()) === count ( $ alg ->getVertices () ));
83
82
}
84
83
85
84
/**
Original file line number Diff line number Diff line change @@ -124,13 +124,12 @@ public function createGraph()
124
124
* @param Graph $graph
125
125
* @return boolean
126
126
* @throws Exception if given graph is not a clone of the original graph (each vertex has to be present in both graphs)
127
- * @uses Graph::getNumberOfVertices()
128
127
* @uses Graph::getBalanace()
129
128
* @uses Graph::getVertex()
130
129
*/
131
130
private function isBalanceReached (Graph $ graph )
132
131
{
133
- if ($ graph ->getNumberOfVertices () !== $ this ->graph ->getNumberOfVertices ( )) {
132
+ if (count ( $ graph ->getVertices ()) !== count ( $ this ->graph ->getVertices () )) {
134
133
throw new DomainException ('Given graph does not appear to be a clone of input graph ' );
135
134
}
136
135
foreach ($ this ->graph ->getVertices ()->getMap () as $ vid => $ vertex ) {
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ public function getEdges()
125
125
126
126
// definition of spanning tree: number of edges = number of vertices - 1
127
127
// above algorithm does not check isolated edges or may otherwise return multiple connected components => force check
128
- if (count ($ returnEdges ) !== ($ this ->graph ->getNumberOfVertices ( ) - 1 )) {
128
+ if (count ($ returnEdges ) !== (count ( $ this ->graph ->getVertices () ) - 1 )) {
129
129
throw new UnexpectedValueException ('Graph is not connected ' );
130
130
}
131
131
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function getEdges()
35
35
$ returnEdges = array ();
36
36
37
37
// iterate n-1 times (per definition, resulting MST MUST have n-1 edges)
38
- for ($ i = 0 , $ n = $ this ->startVertex ->getGraph ()->getNumberOfVertices ( ) - 1 ; $ i < $ n ; ++$ i ) {
38
+ for ($ i = 0 , $ n = count ( $ this ->startVertex ->getGraph ()->getVertices () ) - 1 ; $ i < $ n ; ++$ i ) {
39
39
$ markInserted [$ vertexCurrent ->getId ()] = true ;
40
40
41
41
// get unvisited vertex of the edge and add edges from new vertex
Original file line number Diff line number Diff line change @@ -46,6 +46,6 @@ public function isNull()
46
46
*/
47
47
public function isTrivial ()
48
48
{
49
- return ($ this ->graph ->getEdges ()->isEmpty () && $ this ->graph ->getNumberOfVertices ( ) === 1 );
49
+ return ($ this ->graph ->getEdges ()->isEmpty () && count ( $ this ->graph ->getVertices () ) === 1 );
50
50
}
51
51
}
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public function getEdges()
46
46
$ isFirst = true ;
47
47
48
48
// Repeat until all vertices have been marked
49
- $ totalCountOfVertices = $ this ->vertex ->getGraph ()->getNumberOfVertices ( );
49
+ $ totalCountOfVertices = count ( $ this ->vertex ->getGraph ()->getVertices () );
50
50
for ($ i = 0 ; $ i < $ totalCountOfVertices ; ++$ i ) {
51
51
$ currentVertex = NULL ;
52
52
$ currentVertexId = NULL ;
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function getEdges()
79
79
// the usal algorithm says we repeat (n-1) times.
80
80
// but because we also want to check for loop edges on the start vertex,
81
81
// we have to add an additional step:
82
- $ numSteps = $ this ->vertex ->getGraph ()->getNumberOfVertices ( );
82
+ $ numSteps = count ( $ this ->vertex ->getGraph ()->getVertices () );
83
83
$ edges = $ this ->vertex ->getGraph ()->getEdges ();
84
84
$ changed = true ;
85
85
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ protected function getGraph()
108
108
*/
109
109
public function getEdges ()
110
110
{
111
- $ this ->numEdges = $ this ->graph ->getNumberOfVertices ( );
111
+ $ this ->numEdges = count ( $ this ->graph ->getVertices () );
112
112
if ($ this ->numEdges < 3 ) {
113
113
throw new UnderflowException ('Needs at least 3 vertices ' );
114
114
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public function getEdges()
40
40
{
41
41
$ returnEdges = array ();
42
42
43
- $ n = $ this ->vertex ->getGraph ()->getNumberOfVertices ( );
43
+ $ n = count ( $ this ->vertex ->getGraph ()->getVertices () );
44
44
45
45
$ vertex = $ this ->vertex ;
46
46
$ visitedVertices = array ($ vertex ->getId () => true );
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ public function isTree()
96
96
}
97
97
98
98
// check number of vertices reachable from root should match total number of vertices
99
- return ($ num === $ this ->graph ->getNumberOfVertices ( ));
99
+ return ($ num === count ( $ this ->graph ->getVertices () ));
100
100
}
101
101
102
102
/**
You can’t perform that action at this time.
0 commit comments