int main() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); Graph<string, string> g; g.InsertVertex("Anchorage"); g.InsertVertex("Eagle River"); g.InsertVertex("Old Glenn - AK HWY 1 - AK HWY 3 JCT"); g.InsertVertex("Wasilla"); g.InsertVertex("Palmer"); g.InsertVertex("Talkeetna"); g.InsertVertex("Fairbanks"); g.InsertEdge("Anchorage", "Eagle River", "Old Glenn Hwy", 16); g.InsertEdge("Eagle River", "Old Glenn - AK HWY 1 - AK HWY 3 JCT", "Old Glenn", 19); g.InsertEdge("Old Glenn - AK HWY 1 - AK HWY 3 JCT", "Palmer", "HWY 1", 6); g.InsertEdge("Old Glenn - AK HWY 1 - AK HWY 3 JCT", "Wasilla", "HWY 3", 8); g.InsertEdge("Wasilla", "Talkeetna", "HWY 3", 70); g.InsertEdge("Talkeetna", "Fairbanks", "HWY 3", 300); /*try { g.InsertEdge("Anchorage", "Eagle River", "Old Glenn Hwy", 16); } catch (Exception e) { cout << e << endl; }*/ /*Graph<string, string> copy(g); Graph<string, string> equal; equal = g;*/ cout << "Depth:" << endl; g.DepthFirst(&Print); cout << "\nBreadth:" << endl; g.BreadthFirst(&Print); g.DeleteVertex("Fairbanks"); try { cout << "Invalid Delete" << endl; g.DeleteVertex("Fairbanks"); } catch (Exception e) { cout << e << endl; } cout << "\nBreadth after Delete Vertex Fairbanks:" << endl; g.BreadthFirst(&Print); g.DeleteEdge("Old Glenn - AK HWY 1 - AK HWY 3 JCT", "Wasilla", "HWY 3", 8); cout << "\nDepth after Delete Edge:" << endl; g.DepthFirst(&Print); return 0; }
int main() { Graph head; std::cout << &head << std::endl; std::cout << head.InsertVertex('a')->GetName() << std::endl; std::cout << head.InsertVertex('b')->GetName() << std::endl; std::cout << head.InsertVertex('c')->GetName() << std::endl; std::cout << head.InsertVertex('d')->GetName() << std::endl; std::cout << head.GetFirstVertex()->GetName() << std::endl; std::cout << head.InsertEdge('a', 'b')->GetName() << std::endl; std::cout << head.InsertEdge('a', 'c')->GetName() << std::endl; std::cout << head.InsertEdge('a', 'd')->GetName() << std::endl; std::cout << head.InsertEdge('b', 'a')->GetName() << std::endl; std::cout << head.DeleteEdge('b', 'a') << std::endl; std::cout << head.DeleteEdge('a', 'b') << std::endl; std::cout << head.DeleteEdge('a', 'c') << std::endl; std::cout << head.DeleteEdge('a', 'd') << std::endl; std::cout << head.DeleteVertex('b') << std::endl; std::cout << head.DeleteVertex('c') << std::endl; std::cout << head.DeleteVertex('d') << std::endl; return 0; }