// Initialize pthread barriers initialize barriers bar, bar_bfs, and bar_clean with num_t threads
// Main SCC function called by the main thread function scc(tid): for each node i from 0 to N-1: if comps[i] is unassigned (-1): // Clean up previous outer list nodes clean_prv()
// Initialize a new outer list node
head = new outer_list_node
head.lists[0].push_back(i) // Add node i to the first thread's list
comps[i] = comp // Assign component id to node i
wait at bar_bfs barrier // Synchronize with helper threads
// Perform BFS in parallel
call wf_bfs(tid)
wait at bar_clean barrier // Synchronize before cleanup
// Perform cleanup in parallel
call cleanUp(tid)
wait at bar barrier // Synchronize after cleanup
increment comp // Move to next component ID
// Final cleanup for any remaining outer list nodes
clean_prv()
set head to null
wait at bar_bfs barrier // Final synchronization for helper threads
set comp to -1 // Signal termination to helper threads
wait at bar_clean barrier
wait at bar barrier
// Helper function for other threads function scc_helper(tid): while comp is not -1: // Run until main thread signals termination wait at bar_bfs barrier // Synchronize with main thread
// Perform BFS in parallel
call wf_bfs(tid)
wait at bar_clean barrier // Synchronize before cleanup
// Perform cleanup in parallel
call cleanUp(tid)
wait at bar barrier // Synchronize after cleanup