Skip to content

Commit

Permalink
category-cycles: find_cycles.cpp: optimize away intermediate data str…
Browse files Browse the repository at this point in the history
…ucture
  • Loading branch information
siddharthvp committed Oct 20, 2024
1 parent c841fc6 commit 6dc324d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions category-cycles/find_cycles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,18 @@ int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);

unordered_multimap<int,int> cl;
int parent, sub;
while (1) {
cin >> sub;
if (sub == -1) { // end of input
break;
}
cin >> parent;
cl.insert({ parent, sub });
}
// cout << "Finished reading inputs...\n";

// Convert list of edges representation to adjacency list representation
for (auto p: cl) {
graph[p.first].insert(p.second);
// Build adjacency list representation
graph[parent].insert(sub);
}
// cout << "Finished converting list of edges to adjacency list...\n";
// cout << "Finished generating subcategory graph...\n";

cout << "[";

Expand Down

0 comments on commit 6dc324d

Please sign in to comment.