aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
spanningForestPrim.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47#ifndef GUM_SPANNING_FOREST_PRIM_H
48#define GUM_SPANNING_FOREST_PRIM_H
49
52
53namespace gum {
54
55 /* ===========================================================================
56 */
61 /* ===========================================================================
62 */
64 public:
65 // ############################################################################
67 // ############################################################################
69
71
81 SpanningForestPrim(const UndiGraph* graph, const EdgeProperty< float >* costTable);
82
85
87 virtual ~SpanningForestPrim();
88
90
91 // ############################################################################
93 // ############################################################################
95
97
99
101
102 const UndiGraph& spanningForest();
103
105
106 float costOfSpanningForest();
107
109
110 private:
113
116
119
122
125
128
130 void _compute_();
131
133 void _computeInAComponent_(const NodeId id);
134
136 void _exploreNode_(const NodeId id);
137
140 };
141
142} /* namespace gum */
143
144#endif /* GUM_SPANNING_FOREST_PRIM_H */
A priorityQueue is a heap in which each element has a mutable priority.
UndiGraph _spanning_tree_
the computed spanning tree
SpanningForestPrim(const UndiGraph *graph, const EdgeProperty< float > *costTable)
Default constructor.
float costOfSpanningForest()
Returns the cost of the spanning forest.
void _compute_()
Computes the spanning forest.
const EdgeProperty< float > & _costTable_
the costs of the edges
const EdgeSet & edgesInSpanningForest()
Returns the edges in a min cost spanning forest.
bool _require_computation_
a Boolean indicating whether we need recompute the spanning tree
SpanningForestPrim & operator=(const SpanningForestPrim &toCopy)
Copy operator: private to prevent using it.
const UndiGraph & spanningForest()
Construct the spanning forest.
void _computeInAComponent_(const NodeId id)
compute a spanning tree in a given connected component of graph
float _spanning_tree_cost_
the cost of the spanning tree
void _exploreNode_(const NodeId id)
explore the neighborhood of a node belonging to the spanning tree
virtual ~SpanningForestPrim()
Destructor.
PriorityQueue< Edge, float > _edgesToExplore_
the next edges that may be added to the spanning tree
const UndiGraph & _graph_
the graph the spanning tree of which we wish to compute
SpanningForest()
default constructor
Base class for undirected graphs.
Definition undiGraph.h:128
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
HashTable< Edge, VAL > EdgeProperty
Property on graph elements.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
priority queues (in which an element cannot appear more than once)
Interface for computing min cost spanning trees or forests.