void TCXParser::tcx() { while (_reader.readNextStartElement()) { if (_reader.name() == "Courses") courses(); else if (_reader.name() == "Activities") activities(); else _reader.skipCurrentElement(); } }
vector<int> findOrder(int numCourses, vector<pair<int, int>>& prerequisites) { vector<int> courses(numCourses, -1); if (numCourses <= 0) { return courses; } vector<DirectedGraphNode*> nodes = constructGraph(numCourses, prerequisites); vector<int> visited(numCourses, 0); current_pos = numCourses - 1; for (int i = 0; i < nodes.size(); i++) { DirectedGraphNode* node = nodes[i]; if (visited[node->label] == 0) { if (DFS(nodes, visited, node, courses) == false) { return vector<int>(); } } } return courses; }