Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <vector>
- #include <iostream>
- #include <stdio.h>
- #include <fstream>
- #include <sstream>
- using namespace std;
- void displayGraph(map<int, vector<int>> map) {
- // Hér þarf að útfæra útskriftarfallið, sjá verkefnislýsingu
- auto element = map.begin();
- cout << element ->first;
- }
- int main() {
- vector<string> vigur;
- string line;
- ifstream myfile ("t.txt");
- if (myfile.is_open())
- {
- while ( getline (myfile,line) )
- {
- vigur.push_back(line);
- }
- myfile.close();
- }
- else cout << "Unable to open file";
- int V, E; // The number of vertices V, the number of edges E
- stringstream(vigur[0]) >> V;
- stringstream(vigur[1]) >> E;
- // Hér þarf að upphafsstilla tilvik af map klasanum
- map<int, vector<int>> mittMap;
- //búum til V marga hnúta í map
- cout << "hallo";
- //
- int v, w;
- // while (scanf("%d %d", &v, &w) != -1) {
- for(int i=0; i<22; i++){
- // Inni í þessari lykkju eru v og w heiltölur sem nota má til að fylla inn í netið
- mittMap[v].push_back(w);
- }
- cout << mittMap.size() << endl;
- // Hér þarf að kalla á útskriftarfallið
- displayGraph(mittMap);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement