-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListGraph.cpp
More file actions
39 lines (29 loc) · 1.24 KB
/
ListGraph.cpp
File metadata and controls
39 lines (29 loc) · 1.24 KB
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
30
31
32
33
34
35
36
37
38
39
#include "ListGraph.h"
/* Welcome to the Adjacency-List based graph
-The class takes in Custer's unordered_map<string, set<string>> and uses a const reference
to that unordered map AS the adjacency list.
-Therefore, there are not insert
Notes for main:
Make sure to check artist BEFORE using getAdjacents
*/
ListGraph::ListGraph(std::unordered_map<std::string, std::set<std::string>>& _adjList) : adjList(_adjList)
{}
//Run CheckArtist BEFORE running GetAdjacents!!
bool ListGraph::CheckArtist(std::string artist) //checks if an artist exists in the map (As a key)
{
if (adjList.count(artist)) //if the key is found, return true
return true;
else
return false;
}
//Only run this if you know the artist exists in the map!!
std::set<std::string>& ListGraph::GetAdjacents(std::string artist) //returns a string set of adjacent artists
{
//When we got our data from Spotify, the artist we're looking at also appears
//as their own featured artist in the list. This next line of code removes themselves before
//the set is returned
//THIS IS BROKEN; ERASE WON"T WORK IN THIS CONTEXT DO YOUR RESEARCH BUB
//LOL jk just salty im not the one that got google :(
adjList[artist].erase(artist);
return adjList[artist];
}