Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool GList::isStronglyConnected()
- {
- //obidje za svaki cvor DFS
- //ako ne obidje sve nije
- //Strongly Connected.
- LNode* t = this->start;
- int r;
- while (t != nullptr)
- {
- cout << "\n";
- r = this->depthFirstSearch();
- cout << "\n";
- if (r != this->countNodes)
- {
- return false;
- }
- this->setUnvisited();
- t = t->next;
- }
- return true;
- }
- void GList::setUnvisited()
- {
- LNode* t = this->start;
- while (t != nullptr)
- {
- t->visited = false;
- t = t->next;
- }
- return;
- }
- int GList::depthFirstSearch()
- {
- int r = 0;
- Stek* a = new Stek(this->countNodes);
- LNode* ptr = this->start;
- string b;
- a->push(ptr);
- while (!a->isEmpty())
- {
- ptr = a->pop();
- if (!ptr->visited)
- {
- ptr->visited = true;
- b += ptr->symbol;
- b += " ";
- r++;
- Edge* ptrNext = ptr->izlGrana;
- //nabacamo susede
- while (ptrNext != nullptr)
- {
- a->push(ptrNext->dstNode);
- ptrNext = ptrNext->nextBranch;
- }
- }
- }
- cout << b;
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement