|
GraphLibrary
0.0.1
A simple library that implements various graph algorithms.
|
Class that computes a Minimum Spanning Tree using Kruskal's algorithm. More...
#include <Kruskal.hpp>
Public Member Functions | |
| Kruskal () | |
| Default constructor. More... | |
| Kruskal (const Graph &) | |
| Computation constructor. More... | |
| Kruskal (const Kruskal &)=default | |
| Copy constructor. More... | |
| Kruskal (Kruskal &&) noexcept=default | |
| Move constructor. More... | |
| Kruskal & | operator= (const Kruskal &)=default |
| Copy assignment. More... | |
| Kruskal & | operator= (Kruskal &&) noexcept=default |
| Move assignment. More... | |
| ~Kruskal ()=default | |
| Default destructor. More... | |
| std::function< std::pair< bool, gl::Color >const idx_t src, const idx_t dest)> | EdgeSelector (const gl::Color &trueColor=gl::Color("red"), const gl::Color &falseColor=gl::Color("black")) const |
| Provides a Selector Object to color the edges in the MST. More... | |
| std::function< std::pair< bool, gl::Color >const idx_t node)> | NodeSelector (const gl::Color &trueColor=gl::Color("red"), const gl::Color &falseColor=gl::Color("white")) const |
| Provides a Selector Object to color the nodes in the MST. More... | |
| void | compute (const Graph &graph) |
| Computation. This is where the MST is computed based on a * greedy heuristic that only adds the cheapest edges. More... | |
| val_t | getCost () const |
| Computes the cost of the MST (sum of all edge weights in the MST). More... | |
| Graph | getMST () const |
| Returns a graph that only contains the edges of the MST. More... | |
Private Types | |
| using | Edge = typename Graph::Edge |
| using | idx_t = typename Graph::idx_t |
| using | val_t = typename Graph::val_t |
| using | visit_list_t = typename Graph::visit_list_t |
Private Attributes | |
| bool | isInitialized_ = false |
| Boolean storing initialization status. More... | |
| Graph | result_ |
| MST graph. More... | |
| val_t | cost_ |
| MST cost (sum of all edge weights) More... | |
Class that computes a Minimum Spanning Tree using Kruskal's algorithm.
A Minimum Spanning Tree (MST) is a subgraph of a given graph that covers all nodes, but with minimal edge weight cost.
|
private |
|
private |
|
private |
|
private |
| gl::algorithm::Kruskal< Graph >::Kruskal | ( | ) |
Default constructor.
|
explicit |
Computation constructor.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
default |
Default destructor.
|
default |
Copy assignment.
|
defaultnoexcept |
Move assignment.
| std::function< std::pair< bool, gl::Color >const typename Graph::idx_t src, const typename Graph::idx_t dest)> gl::algorithm::Kruskal< Graph >::EdgeSelector | ( | const gl::Color & | trueColor = gl::Color("red"), |
| const gl::Color & | falseColor = gl::Color("black") |
||
| ) | const |
Provides a Selector Object to color the edges in the MST.
| [in] | trueColor | New color for the MST edges. |
| [in] | falseColor | New color for all non-MST edges. |
| std::function< std::pair< bool, gl::Color >const typename Graph::idx_t node)> gl::algorithm::Kruskal< Graph >::NodeSelector | ( | const gl::Color & | trueColor = gl::Color("red"), |
| const gl::Color & | falseColor = gl::Color("white") |
||
| ) | const |
Provides a Selector Object to color the nodes in the MST.
| [in] | trueColor | (optional) New color for the MST nodes. |
| [in] | falseColor | (optional) New color for the non-MST nodes. |
| void gl::algorithm::Kruskal< Graph >::compute | ( | const Graph & | graph | ) |
Computation. This is where the MST is computed based on a * greedy heuristic that only adds the cheapest edges.
| graph | Input graph on which the Minimum Spanning Tree will * be computed. |
| Kruskal< Graph >::val_t gl::algorithm::Kruskal< Graph >::getCost | ( | ) | const |
Computes the cost of the MST (sum of all edge weights in the MST).
| Graph gl::algorithm::Kruskal< Graph >::getMST | ( | ) | const |
Returns a graph that only contains the edges of the MST.
|
private |
Boolean storing initialization status.
|
private |
MST graph.
|
private |
MST cost (sum of all edge weights)