Implement the graph data structure with matrix