Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lesson4/dummy_sns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Graph {
while (graphReader.read_row(currentNodeId, adjacentNodeId)) {
// graph_ is a vector of vector, whose element is a adjacent node id.
graph_[currentNodeId].push_back(adjacentNodeId);
// ALEXNOTE: rather than maintaing the nicknames and the graph separately,
// you would get more performance by having Node objects store links
// (in C++, pointers would be ideal) directly to their adjacent notes.
}
}

Expand Down Expand Up @@ -159,11 +162,13 @@ void check(Graph& graphObj, const std::vector<std::string>& nicknames,

void runTest(Graph& graphObj, const std::vector<std::string>& nicknames) {
check(graphObj, nicknames, "adrian", "hugh"); // Adrian and Me
check(graphObj, nicknames, "adrian", "alan"); // can reach directory
check(graphObj, nicknames, "adrian", "alan"); // can reach directory (ALEXNOTE: directly?)
check(graphObj, nicknames, "adrian", "jack"); // can reach via some people
check(graphObj, nicknames, "adrian", "betty"); // unreachable
check(graphObj, nicknames, "hoge", "fuga"); // no such nickname
check(graphObj, nicknames, "", ""); // empty input

// ALEXNOTE: how about testing the same name as the source and dest? does it work okay?
}

int main() {
Expand All @@ -184,4 +189,4 @@ int main() {
check(graphObj, nicknames, startNickname, targetNickname);
}
return 0;
}
}