![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The Prim algorithm for computing min cost spanning trees or forests. More...
#include <spanningForestPrim.h>
Public Member Functions | |
Constructors / Destructors | |
SpanningForestPrim (const UndiGraph *graph, const EdgeProperty< float > *costTable) | |
Default constructor. More... | |
SpanningForestPrim (const SpanningForestPrim &toCopy) | |
Copy constructor. More... | |
virtual | ~SpanningForestPrim () |
Destructor. More... | |
Accessors / Modifiers | |
const EdgeSet & | edgesInSpanningForest () |
Returns the edges in a min cost spanning forest. More... | |
const UndiGraph & | spanningForest () |
Construct the spanning forest. More... | |
float | costOfSpanningForest () |
Returns the cost of the spanning forest. More... | |
The Prim algorithm for computing min cost spanning trees or forests.
Binary heap implementation : O(E log(V))
Definition at line 43 of file spanningForestPrim.h.
gum::SpanningForestPrim::SpanningForestPrim | ( | const UndiGraph * | graph, |
const EdgeProperty< float > * | costTable | ||
) |
Default constructor.
Note that this algorithm takes into account the fact that the graph given in input is not connected (that, is, it may contain several connected components)
graph | the graph the spanning forest of which we look for |
costTable | the cost for each edge of graph |
GraphError | if the grand and/or the cost table are null pointers |
Definition at line 35 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::SpanningForestPrim::SpanningForestPrim | ( | const SpanningForestPrim & | toCopy | ) |
Copy constructor.
Definition at line 46 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Destructor.
Definition at line 56 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
Computes the spanning forest.
compute the spanning forest
Definition at line 83 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
compute a spanning tree in a given connected component of graph
compute a spanning tree
Definition at line 94 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
explore the neighborhood of a node belonging to the spanning tree
Definition at line 132 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Returns the cost of the spanning forest.
Implements gum::SpanningForest.
Definition at line 62 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Returns the edges in a min cost spanning forest.
Implements gum::SpanningForest.
Definition at line 69 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
Copy operator: private to prevent using it.
|
virtual |
Construct the spanning forest.
Implements gum::SpanningForest.
Definition at line 76 of file spanningForestPrim.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
the costs of the edges
Definition at line 95 of file spanningForestPrim.h.
|
private |
the next edges that may be added to the spanning tree
Definition at line 98 of file spanningForestPrim.h.
|
private |
the graph the spanning tree of which we wish to compute
Definition at line 92 of file spanningForestPrim.h.
|
private |
a Boolean indicating whether we need recompute the spanning tree
Definition at line 107 of file spanningForestPrim.h.
|
private |
the computed spanning tree
Definition at line 101 of file spanningForestPrim.h.
|
private |
the cost of the spanning tree
Definition at line 104 of file spanningForestPrim.h.