4
4
5
5
use Fhaculty \Graph \Algorithm \Base as AlgorithmBase ;
6
6
use Fhaculty \Graph \Set \Edges ;
7
- use Fhaculty \Graph \Exception \UnexpectedValueException ;
8
7
use Fhaculty \Graph \Edge \Directed as EdgeDirected ;
9
8
use Fhaculty \Graph \Edge \Base as Edge ;
10
9
use SplPriorityQueue ;
21
20
* Because a null graph (a Graph with no vertices) is not considered connected,
22
21
* it also can not contain a spanning tree.
23
22
*
23
+ * Most authors demand that the input graph has to be undirected, whereas this
24
+ * library supports also directed and mixed graphs. The actual direction of the
25
+ * edge will be ignored, only its incident vertices will be checked. This is
26
+ * done in order to be consistent to how ConnectedComponents are checked.
27
+ *
24
28
* @link http://en.wikipedia.org/wiki/Minimum_Spanning_Tree
25
29
* @link http://en.wikipedia.org/wiki/Spanning_Tree
26
30
* @link http://mathoverflow.net/questions/120536/is-the-empty-graph-a-tree
@@ -71,7 +75,6 @@ public function getWeight()
71
75
*
72
76
* @param Edges $edges
73
77
* @param SplPriorityQueue $sortedEdges
74
- * @throws UnexpectedValueException when encountering directed edges
75
78
*/
76
79
protected function addEdgesSorted (Edges $ edges , SplPriorityQueue $ sortedEdges )
77
80
{
@@ -80,10 +83,6 @@ protected function addEdgesSorted(Edges $edges, SplPriorityQueue $sortedEdges)
80
83
/* @var $edge Edge */
81
84
// ignore loops (a->a)
82
85
if (!$ edge ->isLoop ()) {
83
- if ($ edge instanceof EdgeDirected) {
84
- throw new UnexpectedValueException ('Minimum spanning tree for directed edges not supported ' );
85
- }
86
-
87
86
// Add edges with negative weight because of order in stl
88
87
$ sortedEdges ->insert ($ edge , -$ edge ->getWeight ());
89
88
}
0 commit comments