• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# GraphLEMain

a guest Jun 17th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include<string>
4. using namespace std;
5.
6. int main()
7. {
8.     int ch, vertices, edges, source, v, e;
9.     float cost;
10.
11.     cout << "Please enter the number of vertices: ";
12.     cin >> vertices;
13.     Graph g(vertices);
14.     cout << "\Please enter the number of edges: ";
15.     cin >> edges;
16.     for (int i = 1; i <= edges; i++)
17.     {
18.         cout << "Edge " << i << ": ";
19.         cin >> v >> e >> cost;
22.     }
23.     cout << endl;
24.     do
25.     {
26.         system("cls");
27.         cout << "Graph Operations:\n[1] Adjacency List\n[2] Adjacency Matrix\n[3] DFS\n[4] BFS\n[5] Find Path\n[6] Path Cost\n[7] Exit Program\nChoice: ";
28.         cin >> ch;
29.         if (ch == 1)
30.         {
31.             cout << "Adjacency List: ";
32.             g.printGraph();
33.
34.         }
35.         else if (ch == 2)
36.         {
37.             cout << "Adjacency Matrix: ";
38.             //g.printGraph(2);
39.         }
40.         else if (ch == 3)
41.         {
42.             cout << "Please enter vertex of source for DFS: ";
43.             cin >> source;
44.             cout << "\nDFS Traversal..." << endl;
45.             g.DFS(source);
46.
47.         }
48.         else if (ch == 4)
49.         {
50.             cout << "Please enter vertex of source for BFS: ";
51.             cin >> source;
52.             cout << "\nBFS Traversal..." << endl;
53.             g.BFS(source);
54.         }
55.         cout << endl;
56.         system("pause");
57.     } while (ch != 7);
58.
59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?