Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include "GraphADT.h"
- using namespace std;
- int main()
- {
- int ch, vertices, edges, source, v, e;
- float cost;
- cout << "Please enter the number of vertices: ";
- cin >> vertices;
- Graph g(vertices);
- cout << "\Please enter the number of edges: ";
- cin >> edges;
- for (int i = 1; i <= edges; i++)
- {
- cout << "Edge " << i << ": ";
- cin >> v >> e >> cost;
- g.addEdge(v, e);
- g.addEdge2(v, e, cost);
- }
- cout << endl;
- do
- {
- system("cls");
- 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: ";
- cin >> ch;
- if (ch == 1)
- {
- cout << "Adjacency List: ";
- g.printGraph();
- }
- else if (ch == 2)
- {
- cout << "Adjacency Matrix: ";
- //g.printGraph(2);
- }
- else if (ch == 3)
- {
- cout << "Please enter vertex of source for DFS: ";
- cin >> source;
- cout << "\nDFS Traversal..." << endl;
- g.DFS(source);
- }
- else if (ch == 4)
- {
- cout << "Please enter vertex of source for BFS: ";
- cin >> source;
- cout << "\nBFS Traversal..." << endl;
- g.BFS(source);
- }
- cout << endl;
- system("pause");
- } while (ch != 7);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement