vector<int> adj[5]; // I have 5 nodes 
// some code for pushing nodes in adjacency list
for( int i = 0; i < 5; i++ )  // printing graph  
{
    for( int p = 0 ; p < adj[i].size(); p++ )
    {
        cout<< i << " , "<< adj[i][p] << endl;
    }
}
srand (time(NULL));
for( int k = 0 ; k < 3; k++ )  // just want to see random output multiple times, so using for loop 3 times.
{
    int i = rand() % 5; // picking node ( 1-5) randomly 
    int p = adj[i].size(); // calculating number of adjacent nodes 
    int j = rand() % p;   // here I am wrong, 
    cout<< " Random edge " << i+1 <<", " << j;
}
Actually I want to implement Kargar's Min cut program. For that I want to pick an edge randomly. But I am facing this problem:
I am getting a floating point exception. core dumped if I add above code to my program. I checked that the lines with int i and int p are calculating perfectly ( I printed them to see ) but if you add int j = rand() % p in  the code it gives the floating point exception ( core dumped).
Can anyone help me?
 
     
    