本文整理汇总了C++中Graph::DeleteEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::DeleteEdge方法的具体用法?C++ Graph::DeleteEdge怎么用?C++ Graph::DeleteEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::DeleteEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: main
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;
}