Reputation: 10151
I have the following function
bool Graph::termination_condition() {
for(int i = 0; i < nodes; i++) {
// check if any pair of neighbors is using the same color
//vector<int> neigh_colors;
//for(int idx = 0; idx < degree(node); idx++) {
// adjList[node][idx] is the neighbor
//if( find(neigh_colors.begin(), neigh_colors.end(), node_obj[adjList[node][idx]].l_color) == neigh_colors.end() )
// // not found, add
//neigh_colors.push_back(node_obj[adjList[node][idx]].l_color);
//else
// return false;
//}
// check if the color of the node is used
//if( find(neigh_colors.begin(), neigh_colors.end(), node_obj[node].l_color) != neigh_colors.end() )
// return false;
// check if color of node is in conflict list
//if( node_obj[node].tmp_conf_list.size() )
// if( find( node_obj[node].tmp_conf_list.begin(), node_obj[node].tmp_conf_list.end(), node_obj[node].l_color) != node_obj[node].tmp_conf_list.end() )
// return false;
}
return true;
// return false;
}
that makes a segmentation fault whenever I call it
void Graph::otherfunction() {
if( termination_condition() == true )
return 1;
}
what could be the problem?
Thanks
UPDATE:
int Graph::otherfunction() {
if( termination_condition() == true )
return 1;
}
Upvotes: 0
Views: 145
Reputation: 5425
With the little amount of information we've been given, all we can do is guess.
Your best bet is to hop into it with a debugger and find out where the problem is. Setting a breakpoint at the start of otherFunction
should be a good place to start.
Upvotes: 0
Reputation: 283793
My crystal ball says, the this
pointer is NULL or otherwise invalid, and nodes
is a member variable.
Upvotes: 3