Analysis Software
Documentation for sPHENIX simulation software
|
Kruskal's algorithm for finding minimal spanning tree of a graph. More...
#include <JETSCAPE/blob/main/external_packages/gtl/include/GTL/min_tree.h>
Classes | |
class | input_comp |
Public Member Functions | |
min_tree () | |
Constructor. | |
virtual | ~min_tree () |
Destructor. | |
int | check (graph &g) |
Checks whether algorithm can be applied. | |
int | run (graph &g) |
Applies algorithm to graph g. | |
virtual void | reset () |
Resets algorithm. | |
void | set_distances (const edge_map< int > &dist) |
Sets edge weights. | |
set< edge > | get_min_tree () |
Edges of minimal spanning tree calculated in the last call of min_tree::run. | |
int | get_min_tree_length () |
Weight of minimal spanning tree. | |
Public Member Functions inherited from algorithm | |
algorithm () | |
Creates an algorithm object. | |
virtual | ~algorithm () |
Destroys the algorithm object. | |
Private Types | |
typedef pair< int, node::adj_edges_iterator > | TSP_A_VALUE |
Private Attributes | |
edge_map< int > | dist |
int | weight |
set< edge > | tree |
bool | is_set_distances |
Additional Inherited Members | |
Public Types inherited from algorithm | |
enum | { GTL_OK = 1, GTL_ERROR = 0 } |
Return values for algorithm::check and algorithm::run. More... | |
Kruskal's algorithm for finding minimal spanning tree of a graph.
Definition at line 25 of file min_tree.h.
View newest version in sPHENIX GitHub at line 25 of file min_tree.h
|
private |
Definition at line 87 of file min_tree.h.
View newest version in sPHENIX GitHub at line 87 of file min_tree.h
__GTL_BEGIN_NAMESPACE min_tree::min_tree | ( | ) |
Constructor.
Definition at line 27 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 27 of file min_tree.cpp
References is_set_distances, and weight.
|
inlinevirtual |
Destructor.
Definition at line 37 of file min_tree.h.
View newest version in sPHENIX GitHub at line 37 of file min_tree.h
|
virtual |
Checks whether algorithm can be applied.
The graph must
Additionally the weights of the edges must have been set in advance using min_tree::set_distances.
g | graph |
Implements algorithm.
Definition at line 32 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 32 of file min_tree.cpp
References algorithm::GTL_ERROR, algorithm::GTL_OK, graph::is_connected(), graph::is_directed(), is_set_distances, and graph::number_of_nodes().
Edges of minimal spanning tree calculated in the last call of min_tree::run.
Definition at line 45 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 45 of file min_tree.cpp
References tree.
int min_tree::get_min_tree_length | ( | ) |
Weight of minimal spanning tree.
Definition at line 49 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 49 of file min_tree.cpp
References dist, sum(), and tree.
|
virtual |
Resets algorithm.
Prepares the algorithm to be applied to another graph. Please note: The options an algorithm may support do not get reset by this. It is just to reset internally used datastructures.
Implements algorithm.
Definition at line 138 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 138 of file min_tree.cpp
|
virtual |
Applies algorithm to graph g.
g | graph |
algorithm::GTL_OK | on success |
algorithm::GTL_ERROR | otherwise |
Implements algorithm.
Definition at line 61 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 61 of file min_tree.cpp
References node::adj_edges_begin(), node::adj_edges_end(), node::adj_edges_iterator(), dist, graph::edges_begin(), graph::edges_end(), algorithm::GTL_OK, graph::number_of_nodes(), edge::source(), edge::target(), tree, and weight.
void min_tree::set_distances | ( | const edge_map< int > & | dist | ) |
Sets edge weights.
Setting of edge weights must be done before calling min_tree::check and min_tree::run.
dist | edge weigths. |
Definition at line 40 of file min_tree.cpp.
View newest version in sPHENIX GitHub at line 40 of file min_tree.cpp
References dist, and is_set_distances.
|
private |
Definition at line 95 of file min_tree.h.
View newest version in sPHENIX GitHub at line 95 of file min_tree.h
Referenced by get_min_tree_length(), run(), and set_distances().
|
private |
Definition at line 98 of file min_tree.h.
View newest version in sPHENIX GitHub at line 98 of file min_tree.h
Referenced by check(), min_tree(), and set_distances().
Definition at line 97 of file min_tree.h.
View newest version in sPHENIX GitHub at line 97 of file min_tree.h
Referenced by get_min_tree(), get_min_tree_length(), reset(), and run().
|
private |
Definition at line 96 of file min_tree.h.
View newest version in sPHENIX GitHub at line 96 of file min_tree.h
Referenced by min_tree(), reset(), and run().