class for weighted graph
More...
#include <graph.h>
template<typename T>
class weighted_graph< T >
class for weighted graph
◆ weighted_graph() [1/2]
Constructor for weighted graph.
- Parameters
-
__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. |
◆ weighted_graph() [2/2]
Copy constructor for weighted graph class.
- Parameters
-
g | the graph we want to copy |
◆ add_edge()
add_edge function.
- Parameters
-
u | first node. |
v | second node. |
w | weight between u and v. |
◆ bellman_ford()
template<typename T >
std::unordered_map< T, double > weighted_graph< T >::bellman_ford |
( |
T |
start | ) |
|
find SSSP and identify negative cycles.
- Returns
- unordered_map of SSSP.
◆ bfs()
bfs function.
- Parameters
-
start | starting node of the bfs. |
- Returns
- vector<T>, the path of the bfs.
◆ bipartite()
bipartite function.
- Returns
- true if the graph is bipartite.
◆ bridge()
template<typename T >
std::vector< std::vector< T > > weighted_graph< T >::bridge |
( |
T |
start | ) |
|
bridge function.
- Parameters
-
start | starting point of search for the bridges. |
- Returns
- vector<vector<T>> the bridges of the graph.
◆ connected()
connected function.
- Returns
- true if a graph is connected.
◆ connected_components()
connected_components function.
- Returns
- the connected componenets(islands) of the graph.
◆ cycle()
cycle function.
- Returns
- true if a cycle exists in the graph.
◆ dfs()
dfs function.
- Parameters
-
start | starting node of the bfs. |
- Returns
- vector<T>, the path of the dfs.
◆ empty()
empty function.
- Returns
- true if the graph is empty.
◆ eulerian()
eulerian function.
- Returns
- 0 if a graph is not eulerian. 1 if a graph is semi-eulerian. 2 if a graph is eulerian.
◆ has_edge()
has_edge function.
- Parameters
-
start | starting node. |
end | ending node. |
- Returns
- true if a direct edge from start to end exists.
◆ operator=()
operator = for weighted graph class
- Parameters
-
g | the graph we want to copy |
- Returns
- weighted_graph&
◆ prim()
prim function.
- Parameters
-
- Returns
- int64_t, the total cost of the minimum spanning tree of the graph.
◆ scc()
scc(strongly connected components) function.
- Returns
- int64_t the total scc's of the graph.
◆ shortest_path()
shortest_path function.
- Parameters
-
start | starting node. |
end | ending node. |
- Returns
- int64_t, the total cost of the path.
◆ size()
size function.
- Returns
- the size of the graph.
◆ topological_sort()
topological sort function.
- Returns
- vector<T>, the topological order of the elements of the graph.
◆ visualize()
visualize function.
- Returns
- .dot file that can be previewed in vscode with graphviz.
◆ operator<<
template<typename T >
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
weighted_graph< T > & |
g |
|
) |
| |
|
friend |
<< operator for the weighted graph class.
- Returns
- ostream &out for std::cout.
The documentation for this class was generated from the following file:
- /home/spiros/Documents/AlgoPlus/src/classes/graph/graph.h