aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
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-2026 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-2026 *
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
50
#include <
agrum/base/core/priorityQueue.h
>
51
#include <
agrum/base/graphs/algorithms/spanningForest.h
>
52
53
namespace
gum
{
54
55
/* ===========================================================================
56
*/
61
/* ===========================================================================
62
*/
63
class
GUM_SHARED_PUBLIC
SpanningForestPrim
:
public
SpanningForest
{
64
public
:
65
// ############################################################################
67
// ############################################################################
69
71
81
SpanningForestPrim
(
const
UndiGraph
*
graph
,
const
EdgeProperty< float >
* costTable);
82
84
SpanningForestPrim
(
const
SpanningForestPrim
& toCopy);
85
87
SpanningForestPrim
(
SpanningForestPrim
&& from);
88
90
~SpanningForestPrim
()
override
;
91
93
94
// ############################################################################
96
// ############################################################################
98
100
101
const
EdgeSet
&
edgesInSpanningForest
()
override
;
102
104
105
const
UndiGraph
&
spanningForest
()
override
;
106
108
109
float
costOfSpanningForest
()
override
;
110
112
113
private
:
115
const
UndiGraph
&
_graph_
;
116
118
const
EdgeProperty< float >
&
_costTable_
;
119
121
PriorityQueue< Edge, float >
_edgesToExplore_
;
122
124
UndiGraph
_spanning_tree_
;
125
127
float
_spanning_tree_cost_
;
128
130
bool
_require_computation_
;
131
133
void
_compute_
();
134
136
void
_computeInAComponent_
(
const
NodeId
id
);
137
139
void
_exploreNode_
(
const
NodeId
id
);
140
142
SpanningForestPrim
&
operator=
(
const
SpanningForestPrim
& toCopy);
143
};
144
145
}
/* namespace gum */
146
147
#endif
/* GUM_SPANNING_FOREST_PRIM_H */
gum::PriorityQueue
A priorityQueue is a heap in which each element has a mutable priority.
Definition
priorityQueue.h:884
gum::SpanningForestPrim::_spanning_tree_
UndiGraph _spanning_tree_
the computed spanning tree
Definition
spanningForestPrim.h:124
gum::SpanningForestPrim::SpanningForestPrim
SpanningForestPrim(const UndiGraph *graph, const EdgeProperty< float > *costTable)
Default constructor.
Definition
spanningForestPrim.cpp:55
gum::SpanningForestPrim::costOfSpanningForest
float costOfSpanningForest() override
Returns the cost of the spanning forest.
Definition
spanningForestPrim.cpp:91
gum::SpanningForestPrim::spanningForest
const UndiGraph & spanningForest() override
Construct the spanning forest.
Definition
spanningForestPrim.cpp:105
gum::SpanningForestPrim::edgesInSpanningForest
const EdgeSet & edgesInSpanningForest() override
Returns the edges in a min cost spanning forest.
Definition
spanningForestPrim.cpp:98
gum::SpanningForestPrim::_compute_
void _compute_()
Computes the spanning forest.
Definition
spanningForestPrim.cpp:112
gum::SpanningForestPrim::_costTable_
const EdgeProperty< float > & _costTable_
the costs of the edges
Definition
spanningForestPrim.h:118
gum::SpanningForestPrim::_require_computation_
bool _require_computation_
a Boolean indicating whether we need recompute the spanning tree
Definition
spanningForestPrim.h:130
gum::SpanningForestPrim::operator=
SpanningForestPrim & operator=(const SpanningForestPrim &toCopy)
Copy operator: private to prevent using it.
gum::SpanningForestPrim::_computeInAComponent_
void _computeInAComponent_(const NodeId id)
compute a spanning tree in a given connected component of graph
Definition
spanningForestPrim.cpp:127
gum::SpanningForestPrim::_spanning_tree_cost_
float _spanning_tree_cost_
the cost of the spanning tree
Definition
spanningForestPrim.h:127
gum::SpanningForestPrim::_exploreNode_
void _exploreNode_(const NodeId id)
explore the neighborhood of a node belonging to the spanning tree
Definition
spanningForestPrim.cpp:165
gum::SpanningForestPrim::_edgesToExplore_
PriorityQueue< Edge, float > _edgesToExplore_
the next edges that may be added to the spanning tree
Definition
spanningForestPrim.h:121
gum::SpanningForestPrim::_graph_
const UndiGraph & _graph_
the graph the spanning tree of which we wish to compute
Definition
spanningForestPrim.h:115
gum::SpanningForest::SpanningForest
SpanningForest()
default constructor
gum::UndiGraph
Base class for undirected graphs.
Definition
undiGraph.h:130
gum::EdgeSet
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Definition
graphElements.h:391
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
gum::EdgeProperty
HashTable< Edge, VAL > EdgeProperty
Property on graph elements.
Definition
graphElements.h:409
gum::graph
Definition
bayesBall.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
priorityQueue.h
priority queues (in which an element cannot appear more than once)
spanningForest.h
Interface for computing min cost spanning trees or forests.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0