Skip to content

Commit e6b6121

Browse files
committed
Improve documentation
1 parent d0390c2 commit e6b6121

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/MinimumSpanningTree/Base.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,51 @@
44

55
use Fhaculty\Graph\Algorithm\Base as AlgorithmBase;
66
use Fhaculty\Graph\Set\Edges;
7+
use Fhaculty\Graph\Exception\UnexpectedValueException;
8+
use Fhaculty\Graph\Edge\Directed as EdgeDirected;
79

10+
/**
11+
* Abstract base class for minimum spanning tree (MST) algorithms
12+
*
13+
* A minimum spanning tree of a graph is a subgraph that is a tree and connects
14+
* all the vertices together while minimizing the total sum of all edges'
15+
* weights.
16+
*
17+
* A spanning tree thus requires a connected graph (single connected component),
18+
* otherwise we can span multiple trees (spanning forest) within each component.
19+
* Because a null graph (a Graph with no vertices) is not considered connected,
20+
* it also can not contain a spanning tree.
21+
*
22+
* @link http://en.wikipedia.org/wiki/Minimum_Spanning_Tree
23+
* @link http://en.wikipedia.org/wiki/Spanning_Tree
24+
* @link http://mathoverflow.net/questions/120536/is-the-empty-graph-a-tree
25+
*/
826
abstract class Base extends AlgorithmBase
927
{
1028
/**
1129
* create new resulting graph with only edges on minimum spanning tree
1230
*
1331
* @return Graph
14-
* @uses AlgorithmMst::getEdges()
32+
* @uses self::getGraph()
33+
* @uses self::getEdges()
1534
* @uses Graph::createGraphCloneEdges()
1635
*/
1736
public function createGraph()
1837
{
19-
// Copy Graph
2038
return $this->getGraph()->createGraphCloneEdges($this->getEdges());
2139
}
2240

23-
abstract protected function getGraph();
24-
2541
/**
2642
* get all edges on minimum spanning tree
2743
*
2844
* @return Edges
2945
*/
3046
abstract public function getEdges();
47+
48+
/**
49+
* return reference to current Graph
50+
*
51+
* @return Graph
52+
*/
53+
abstract protected function getGraph();
3154
}

0 commit comments

Comments
 (0)