本文整理汇总了C++中Graph::FindEdgeCost方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::FindEdgeCost方法的具体用法?C++ Graph::FindEdgeCost怎么用?C++ Graph::FindEdgeCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::FindEdgeCost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
Graph G;
string input;
cin >> input;
while(input != "END") {
G.vertices.push_back(input);
cin >> input;
}
string first, second;
cin >> first;
int weight;
while(first != "END") {
cin >> second;
cin >> weight;
G.AddEdge(first,second,weight);
cin >> first;
}
//G.PrintOut();
int opcode;
cin >> opcode;
string A, B;
while(opcode != 0) {
switch(opcode)
{
case 1:
cin >> A;
if(G.FindVertex(A))
cout << 1 << endl;
else
cout << 0 << endl;
break;
case 2:
cin >> A;
cin >> B;
cout << G.FindEdgeCost(A, B) << endl;
break;
case 3:
cin >> A;
cin >> B;
cout << G.IsReachable(A, B) << endl;
break;
}
cin >> opcode;
}
}
示例2: main
int main ()
{
Graph G;
string temp;
cin >> temp;
while (temp != "END")
{
if (!G.FindVertex(temp))
{
G.vertices.push_back(temp);
}
cin >> temp;
}
string key1, key2;
int val;
cin >> key1;
while (key1 != "END")
{
cin >> key2; cin >> val;
if (G.FindVertex(key1) && G.FindVertex(key2))
{
G.AddEdge(key1, key2, val);
}
cin >> key1;
}
int n;
cin >> n;
while (n != 0)
{
switch (n)
{
case 1:
{
string param;
cin >> param;
if (G.FindVertex(param)) cout << "1" << endl;
else cout << "0" << endl;
break;
}
case 2:
{
string param1, param2;
cin >> param1; cin >> param2;
cout << G.FindEdgeCost(param1, param2) << endl;
break;
}
case 3:
{
string param1, param2;
cin >> param1; cin >> param2;
cout << G.IsReachable(param1, param2) << endl;
break;
}
}
cin >> n;
}
return 1;
}