-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.cpp
More file actions
29 lines (26 loc) · 809 Bytes
/
Graph.cpp
File metadata and controls
29 lines (26 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "Graph.h"
void Graph::insertEdge(node from, node to, int weight) {
nodeStore[from.ID] = from;
nodeStore[to.ID] = to;
pair<int, int> toWeight;
toWeight.first = to.ID;
toWeight.second = weight;
adjList[from.ID].push_back(toWeight);
}
void Graph::printGraph() {
for (auto it: adjList) {
cout << it.first << " Name: " << nodeStore[it.first].name <<" connects to: ";
for (int i = 0; i < it.second.size(); i++) {
cout << it.second.at(i).first << " Name: " << nodeStore[it.second.at(i).first].name << " ";
cout << "with a weight of: " << it.second.at(i).second;
}
cout << endl;
}
}
//vector<int> Graph::BFSsearch(string Uinput) {
// vector<int> searchRes;
// int Vsize = nodeStore.size();
// vector<bool> visited(Vsize, false);
//
// unordered_map<int, vector<pair<int, int>>>;
//}