I have to develop a program which checks if some undirected graph is bipartite in C++ as a project exam. I have created all necessary functions but I faced issue I do not clearly understand.
I have some custom struct:
struct slistEl
{
slistEl* next;
int v;
};
Then I have all logic which checks if the graph previously taken from the .txt file is bipartite:
bool isBipartite(int n, slistEl** A)
{
queue Q;
int* C;
int v, u, i;
slistEl* p;
C = new int[n];
for (i = 0; i < n; i++) C[i] = 0;
for (i = 0; i < n; i++)
if (!C[i])
{
C[i] = 1;
Q.push(i);
while (!Q.empty())
{
v = Q.front();
Q.pop();
for (p = A[v]; p; p = p->next)
{
u = p->v;
if (C[u] == C[v])
{
delete[] C;
return false;
}
if (!C[u])
{
C[u] = -C[v];
Q.push(u);
}
}
}
}
delete[] C;
return true;
}
void continueWork(vector<int[2]> verticles) {
slistEl* p, * r, ** A;
A = new slistEl * [getVerticlesCount(verticles)];
for (int i = 0; i < getVerticlesCount(verticles); i++) A[i] = NULL;
for (int i = 0; i < verticles.size(); i++)
{
slistEl v1;
v1.v = verticles[i][0];
slistEl v2;
v2.v = verticles[i][1];
p = new slistEl;
p->v = v2.v;
p->next = A[v1.v];
A[v1.v] = p;
p = new slistEl;
p->v = v1.v;
p->next = A[v2.v];
A[v2.v] = p;
}
}
Function getVerticalCounts has no impact for this issue- it counts verticals from the input file.
Then, I receive following issue which I tried to resolve like here in this issue but It did not help me in any way: Error in converting argument from 'const_Ty' to const custom struct
Errors I receive: '==': no conversion from 'const _Ty' to 'int [2]' an array cannot be initialized with a parenthesized initializer
Could someone explain to me specifically what this problem is and potentially how to fix it? I would be so grateful.