001/*
002MIT License
003
004Copyright (c) 2020 earlygrey
005
006Permission is hereby granted, free of charge, to any person obtaining a copy
007of this software and associated documentation files (the "Software"), to deal
008in the Software without restriction, including without limitation the rights
009to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
010copies of the Software, and to permit persons to whom the Software is
011furnished to do so, subject to the following conditions:
012
013The above copyright notice and this permission notice shall be included in all
014copies or substantial portions of the Software.
015
016THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
017IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
018FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
019AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
020LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
021OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
022SOFTWARE.
023 */
024package squidpony.squidai.graph;
025
026/**
027 * Algorithms specific to undirected graphs, like {@link DefaultGraph}, as well as general {@link Algorithms}.
028 * Currently, this only adds a {@link #findMinimumWeightSpanningTree()} method.
029 * @param <V> the vertex type; often {@link squidpony.squidmath.Coord}
030 * @author earlygrey
031 */
032public class UndirectedGraphAlgorithms<V> extends Algorithms<V> {
033
034    UndirectedGraphAlgorithms(UndirectedGraph<V> graph) {
035        super(graph);
036    }
037
038    /**
039     * Find a minimum weight spanning tree using Kruskal's algorithm.
040     * @return a Graph object containing a minimum weight spanning tree (if this graph is connected -
041     * in general a minimum weight spanning forest)
042     */
043    public Graph<V> findMinimumWeightSpanningTree() {
044        return implementations.kruskalsMinimumWeightSpanningTree(true);
045    }
046
047
048}