You could even use with edge list – you'd have to iterate over all edges, though, to find the edges of interest – or if edges are sorted, you could use binary search to find starting edge and then iterate only over a sub-range...
Algorithms usually are designed for a problem, not for how input data is represented. Although some problems require specific data structures for internal data (Aho Corasick a modified trie, for example; but if input is std::string, array of characters or read one character by another from file is pretty irrelevant again...).
But you could, sorted edge list provided, create another array, iterate once over the list and store the starting indices in the array. Then you get O(1) vertex access again...
you could just add the values to a single vector as soon as you encounter. Then you don't have to count size separately either. Each time you start a new search, you clear that vector again...
Then vector of vectors? Each time you start with a new component you add an empty inner vector to outer one and add the nodes you encounter. Outer vector.size(), then for each inner vector size + contents...
Well, you then need range lookup for each component. And you would have to count number of components explicitly. With vector of vectors, you get all that for free...
I'm designing a multilevel queue process simulator in C++ but I've got a problem when trying to implement several queues (my queues are vectors).So,
"multilevel" is a 4 elements array (not vector). Inside each of those elements there is a vector (type t_PCB).
vector<vector<t_PCB>> multilevel[4]...
Actually, you can re-use the path problem from before.
Instead of reading an adjacency matrix, you now could create one, adding for each field an edge to its up to eight reachable other fields. Rest then is as you had before...
Calculating next fields from current one appears more efficient to me, though (that would correspond to creating only a partial matrix).
Don't do if(condition) return true; else return false; just have return condition;
You can iterate over each of the fields of your bord (double loop), for each field iterate over the eight neighbour offsets and if these added to current field coordinates are inside the board set a 1.
I personally wouldn't materialise that matrix, but instead iterate over the eight neighbours inside BFS and calculate them on need only. That is like calculating in the matrix only the fields that actually are needed, skipping the others.