![]() |
aGrUM
0.16.0
|
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 44 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 36 of file spanningForestPrim.cpp.
References GUM_ERROR.
gum::SpanningForestPrim::SpanningForestPrim | ( | const SpanningForestPrim & | toCopy | ) |
Copy constructor.
Definition at line 50 of file spanningForestPrim.cpp.
|
virtual |
Destructor.
Definition at line 61 of file spanningForestPrim.cpp.
|
private |
Computes the spanning forest.
compute the spanning forest
Definition at line 88 of file spanningForestPrim.cpp.
References __computeInAComponent(), __graph, __require_computation, __spanning_tree, gum::NodeGraphPart::existsNode(), and gum::NodeGraphPart::nodes().
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 99 of file spanningForestPrim.cpp.
References __costTable, __edgesToExplore, __exploreNode(), __spanning_tree, __spanning_tree_cost, gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::NodeGraphPart::existsNode(), 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 137 of file spanningForestPrim.cpp.
References __costTable, __edgesToExplore, __graph, __spanning_tree, gum::NodeGraphPart::existsNode(), and gum::EdgeGraphPart::neighbours().
Referenced by __computeInAComponent().
|
virtual |
Returns the cost of the spanning forest.
Implements gum::SpanningForest.
Definition at line 67 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 74 of file spanningForestPrim.cpp.
References __compute(), __require_computation, __spanning_tree, and gum::EdgeGraphPart::edges().
|
private |
Copy operator: private to prevent using it.
|
virtual |
Construct the spanning forest.
Implements gum::SpanningForest.
Definition at line 81 of file spanningForestPrim.cpp.
References __compute(), __require_computation, and __spanning_tree.
|
private |
the costs of the edges
Definition at line 97 of file spanningForestPrim.h.
Referenced by __computeInAComponent(), and __exploreNode().
|
private |
the next edges that may be added to the spanning tree
Definition at line 100 of file spanningForestPrim.h.
Referenced by __computeInAComponent(), and __exploreNode().
|
private |
the graph the spanning tree of which we wish to compute
Definition at line 94 of file spanningForestPrim.h.
Referenced by __compute(), and __exploreNode().
|
private |
a Boolean indicating whether we need recompute the spanning tree
Definition at line 109 of file spanningForestPrim.h.
Referenced by __compute(), costOfSpanningForest(), edgesInSpanningForest(), and spanningForest().
|
private |
the computed spanning tree
Definition at line 103 of file spanningForestPrim.h.
Referenced by __compute(), __computeInAComponent(), __exploreNode(), edgesInSpanningForest(), and spanningForest().
|
private |
the cost of the spanning tree
Definition at line 106 of file spanningForestPrim.h.
Referenced by __computeInAComponent(), and costOfSpanningForest().