GitHub Viewer
#ifndef CPP_ALGORITHM_GRAPH_H
#define CPP_ALGORITHM_GRAPH_H
namespace Graph
{
std::vector InitializeAdjacencyMatrix(int row, int col, std::vector& edges)
{
auto adjacency_matrix = std::vector(row, std::vector(col, 0));
for (const auto& [x, y] : edges)
{
if (x < row && y < col)
{
adjacency_matrix[x][y] = 1;
}
}
return adjacency_matrix;
}
std::vector InitializeAdjacencyMatrixWithZero(int row, int col)
{
auto adjacency_matrix = std::vector(row, std::vector(col, 0));
return adjacency_matrix;
}
std::vector InitializeAdjacencyMatrixWithOne(int row, int col)
{
auto adjacency_matrix = std::vector(row, std::vector(col, 1));
return adjacency_matrix;
}
}