Skip to main content
1 de 3

BUENAS NOCHES, CON RESPECTO AL ERROR SIGSEGV

Se trata del inicio del codigo para Djikstra Shortest Paths, pero me da el error SIGSEGV... A que debiera inicializar Graph?? El programa no se ejecuta hasta llegar a esta linea (sin haber dado el error):
for (int j=0; j < Nodes; ++j)

Gracias!

int main() {

int Nodes, Start_Node;
double Density;
vector <int> Output_Distances(Nodes);
// input Number of Nodos, Densidad, to generate random matrix
cout << "Enter number of Nodes: " << endl; 
cin >>  Nodes; 
cout << "Enter Graph Edges Density: " << endl ;
cin >>  Density; 
cout << "Enter Start Node: "  << endl;
cin >> Start_Node;

vector <int>* graph; // Declares graph to fill out with edges

srand(time(0)); // seed rand

    
for (int i=0; i < Nodes; ++i) // loop to fill the matrix with false or true, randomly with probability less than Density
    for (int j=0; j < Nodes; ++j)
        if (i==j) graph[i][j]=false; //diagonal - no loop edge