![]() |
aGrUM 2.3.2
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. | |
| SpanningForestPrim (const SpanningForestPrim &toCopy) | |
| Copy constructor. | |
| virtual | ~SpanningForestPrim () |
| Destructor. | |
Accessors / Modifiers | |
| const EdgeSet & | edgesInSpanningForest () |
| Returns the edges in a min cost spanning forest. | |
| const UndiGraph & | spanningForest () |
| Construct the spanning forest. | |
| float | costOfSpanningForest () |
| Returns the cost of the spanning forest. | |
Private Member Functions | |
| void | _compute_ () |
| Computes the spanning forest. | |
| void | _computeInAComponent_ (const NodeId id) |
| compute a spanning tree in a given connected component of graph | |
| void | _exploreNode_ (const NodeId id) |
| explore the neighborhood of a node belonging to the spanning tree | |
| SpanningForestPrim & | operator= (const SpanningForestPrim &toCopy) |
| Copy operator: private to prevent using it. | |
Private Attributes | |
| const UndiGraph & | _graph_ |
| the graph the spanning tree of which we wish to compute | |
| const EdgeProperty< float > & | _costTable_ |
| the costs of the edges | |
| PriorityQueue< Edge, float > | _edgesToExplore_ |
| the next edges that may be added to the spanning tree | |
| UndiGraph | _spanning_tree_ |
| the computed spanning tree | |
| float | _spanning_tree_cost_ |
| the cost of the spanning tree | |
| bool | _require_computation_ |
| a Boolean indicating whether we need recompute the spanning tree | |
The Prim algorithm for computing min cost spanning trees or forests.
Binary heap implementation : O(E log(V))
Definition at line 63 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 55 of file spanningForestPrim.cpp.
References gum::SpanningForest::SpanningForest(), SpanningForestPrim(), _costTable_, _graph_, _require_computation_, _spanning_tree_cost_, and GUM_ERROR.
Referenced by SpanningForestPrim(), SpanningForestPrim(), ~SpanningForestPrim(), and operator=().
| gum::SpanningForestPrim::SpanningForestPrim | ( | const SpanningForestPrim & | toCopy | ) |
Copy constructor.
Definition at line 66 of file spanningForestPrim.cpp.
References gum::SpanningForest::SpanningForest(), SpanningForestPrim(), _costTable_, _edgesToExplore_, _graph_, _require_computation_, _spanning_tree_, and _spanning_tree_cost_.
|
virtual |
Destructor.
Definition at line 76 of file spanningForestPrim.cpp.
References SpanningForestPrim().
|
private |
Computes the spanning forest.
compute the spanning forest
Definition at line 103 of file spanningForestPrim.cpp.
References _computeInAComponent_(), _graph_, _require_computation_, and _spanning_tree_.
Referenced by costOfSpanningForest(), edgesInSpanningForest(), and spanningForest().
|
private |
compute a spanning tree in a given connected component of graph
compute a spanning tree
Definition at line 114 of file spanningForestPrim.cpp.
References _costTable_, _edgesToExplore_, _exploreNode_(), _spanning_tree_, _spanning_tree_cost_, gum::Edge::first(), and gum::Edge::second().
Referenced by _compute_().
|
private |
explore the neighborhood of a node belonging to the spanning tree
Definition at line 152 of file spanningForestPrim.cpp.
References _costTable_, _edgesToExplore_, _graph_, and _spanning_tree_.
Referenced by _computeInAComponent_().
|
virtual |
Returns the cost of the spanning forest.
Implements gum::SpanningForest.
Definition at line 82 of file spanningForestPrim.cpp.
References _compute_(), _require_computation_, and _spanning_tree_cost_.
|
virtual |
Returns the edges in a min cost spanning forest.
Implements gum::SpanningForest.
Definition at line 89 of file spanningForestPrim.cpp.
References _compute_(), _require_computation_, and _spanning_tree_.
|
private |
Copy operator: private to prevent using it.
References SpanningForestPrim().
|
virtual |
Construct the spanning forest.
Implements gum::SpanningForest.
Definition at line 96 of file spanningForestPrim.cpp.
References _compute_(), _require_computation_, and _spanning_tree_.
|
private |
the costs of the edges
Definition at line 115 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), SpanningForestPrim(), _computeInAComponent_(), and _exploreNode_().
|
private |
the next edges that may be added to the spanning tree
Definition at line 118 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), _computeInAComponent_(), and _exploreNode_().
|
private |
the graph the spanning tree of which we wish to compute
Definition at line 112 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), SpanningForestPrim(), _compute_(), and _exploreNode_().
|
private |
a Boolean indicating whether we need recompute the spanning tree
Definition at line 127 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), SpanningForestPrim(), _compute_(), costOfSpanningForest(), edgesInSpanningForest(), and spanningForest().
|
private |
the computed spanning tree
Definition at line 121 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), _compute_(), _computeInAComponent_(), _exploreNode_(), edgesInSpanningForest(), and spanningForest().
|
private |
the cost of the spanning tree
Definition at line 124 of file spanningForestPrim.h.
Referenced by SpanningForestPrim(), SpanningForestPrim(), _computeInAComponent_(), and costOfSpanningForest().