AlgoPlus v0.1.0
|
class for weighted graph More...
#include <graph.h>
Public Member Functions | |
weighted_graph (std::string _type, std::vector< std::pair< std::pair< T, T >, int64_t > > _adj={}) | |
Constructor for weighted graph. | |
weighted_graph (const weighted_graph &g) | |
Copy constructor for weighted graph class. | |
weighted_graph & | operator= (const weighted_graph &g) |
operator = for weighted graph class | |
~weighted_graph () | |
Destroy the weighted graph object. | |
void | add_edge (T u, T v, int64_t w) |
add_edge function. | |
bool | has_edge (T start, T end) |
has_edge function. | |
void | clear () |
clear function. Clearing the entire graph. | |
bool | empty () |
empty function. | |
size_t | size () |
size function. | |
std::vector< T > | dfs (T start) |
dfs function. | |
std::vector< T > | bfs (T start) |
bfs function. | |
double | shortest_path (T start, T end) |
shortest_path function. | |
int64_t | connected_components () |
connected_components function. | |
bool | cycle () |
cycle function. | |
std::vector< T > | topological_sort () |
topological sort function. | |
int64_t | prim (T start) |
prim function. | |
bool | bipartite () |
bipartite function. | |
std::vector< std::vector< T > > | bridge (T start) |
bridge function. | |
int64_t | scc () |
scc(strongly connected components) function. | |
bool | connected () |
connected function. | |
int | eulerian () |
eulerian function. | |
std::unordered_map< T, double > | bellman_ford (T start) |
find SSSP and identify negative cycles. | |
int | max_flow (T start, T end) |
maximum flow function | |
void | visualize () |
visualize function. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, weighted_graph< T > &g) |
<< operator for the weighted graph class. | |
class for weighted graph
|
inline |
Constructor for weighted graph.
__type | type of the graph, either "directed" or "undirected". |
__adj | vector<pair<pair<T,T>, int64_t>>, you can pass a vector of pairs to construct the graph without doing multiple add_edge. |
|
inlineexplicit |
Copy constructor for weighted graph class.
g | the graph we want to copy |
|
inline |
add_edge function.
u | first node. |
v | second node. |
w | weight between u and v. |
std::unordered_map< T, double > weighted_graph< T >::bellman_ford | ( | T | start | ) |
find SSSP and identify negative cycles.
std::vector< T > weighted_graph< T >::bfs | ( | T | start | ) |
bfs function.
start | starting node of the bfs. |
bool weighted_graph< T >::bipartite | ( | ) |
bipartite function.
std::vector< std::vector< T > > weighted_graph< T >::bridge | ( | T | start | ) |
bridge function.
start | starting point of search for the bridges. |
bool weighted_graph< T >::connected | ( | ) |
connected function.
int64_t weighted_graph< T >::connected_components | ( | ) |
connected_components function.
bool weighted_graph< T >::cycle | ( | ) |
cycle function.
std::vector< T > weighted_graph< T >::dfs | ( | T | start | ) |
dfs function.
start | starting node of the bfs. |
|
inline |
empty function.
int weighted_graph< T >::eulerian | ( | ) |
eulerian function.
|
inline |
has_edge function.
start | starting node. |
end | ending node. |
int weighted_graph< T >::max_flow | ( | T | start, |
T | end ) |
maximum flow function
Returns the maximum flow from a starting node 's' to an ending node(sink) 't'
|
inline |
int64_t weighted_graph< T >::prim | ( | T | start | ) |
prim function.
start | starting node. |
int64_t weighted_graph< T >::scc | ( | ) |
scc(strongly connected components) function.
double weighted_graph< T >::shortest_path | ( | T | start, |
T | end ) |
shortest_path function.
start | starting node. |
end | ending node. |
size_t weighted_graph< T >::size | ( | ) |
size function.
std::vector< T > weighted_graph< T >::topological_sort | ( | ) |
topological sort function.
void weighted_graph< T >::visualize | ( | ) |
visualize function.
|
friend |
<< operator for the weighted graph class.