How to Implement the Adjacency Matrix Algorithm in C++