Class for Unweighted Graph.
More...
#include <graph.h>
template<typename T>
class graph< T >
Class for Unweighted Graph.
◆ graph() [1/2]
template<typename T >
graph< T >::graph |
( |
std::string |
_type, |
|
|
std::vector< std::pair< T, std::vector< T >>> |
_adj = {} |
|
) |
| |
|
inline |
Constructor for the unweighted graph.
- Parameters
-
__type | type of the graph, either "directed" or "undirected" |
__adj | vector<pair<T,vector<T>>, you can pass a vector of pairs to construct the graph without doing multiple add_edge. |
◆ graph() [2/2]
Construct a new graph object.
- Parameters
-
g | the graph we want to copy |
◆ add_edge()
template<typename T >
void graph< T >::add_edge |
( |
T |
u, |
|
|
T |
v |
|
) |
| |
|
inline |
add_edge function
- Parameters
-
◆ bfs()
template<typename T >
std::vector< T > graph< T >::bfs |
( |
T |
start | ) |
|
bfs function
- Parameters
-
start | starting node of the bfs. |
- Returns
- vector<T>, the path of the bfs.
◆ bipartite()
template<typename T >
bool graph< T >::bipartite |
bipartite function.
- Returns
- true if the graph is bipartite.
◆ bridge()
template<typename T >
std::vector< std::vector< T > > 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()
template<typename T >
bool graph< T >::connected |
connected function.
- Returns
- true if a graph is connected.
◆ connected_components()
template<typename T >
int64_t graph< T >::connected_components |
connected_components function.
- Returns
- the connected components(islands) of the graph.
◆ cycle()
cycle function.
- Returns
- true if a cycle exist in the graph.
◆ dfs()
template<typename T >
std::vector< T > graph< T >::dfs |
( |
T |
start | ) |
|
dfs function
- Parameters
-
start | starting node of the dfs. |
- Returns
- vector<T>, the path of the dfs.
◆ 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()
template<typename T >
bool graph< T >::has_edge |
( |
T |
start, |
|
|
T |
end |
|
) |
| |
|
inline |
has_edge function.
- Parameters
-
start | starting node. |
end | ending node. |
- Returns
- true if a direct edge from start to end exists. false if a direct edge from start to end does not exist.
◆ operator=()
operator = for the graph class
- Parameters
-
g | the graph we want to copy |
- Returns
- graph&
◆ scc()
template<typename T >
int64_t graph< T >::scc |
( |
| ) |
|
scc(strongly connected components) function.
- Returns
- int64_t the number of scc's in the graph.
◆ size()
size function
- Returns
- size_t the size of the graph.
◆ topological_sort()
template<typename T >
std::vector< T > graph< T >::topological_sort |
topological_sort function.
- Returns
- vector<T> the topological order of the elements of the graph.
◆ visualize()
template<typename T >
void graph< T >::visualize |
( |
| ) |
|
visualize function.
- Returns
- .dot file that can be previewed in vscode with graphviz.
◆ operator<<
template<typename T >
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
graph< T > & |
g |
|
) |
| |
|
friend |
operator << for the 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