So i understand that a graph is N x N matrix so the code i produce below produces a graph, but how do i generate the edges and assign the edges with random weights of 1 - 10. and i need to return (M,L) M = adj matrix, L = adj list
#include <iostream>
#include <stdlib.h>
usingnamespace std;
void gen_random_graph(int n)
{
int adj_matrix[n][n];
for(int u = 0; u < n; u++)
{
for (int v = 0; v < n; v++) //generating a N x N matrix based on the # of vertex
{
if(adj_matrix[u][v]==adj_matrix[v][u])
{
adj_matrix[u][v] = rand() % 10 + 1;
cout << adj_matrix[u][v] << endl;
}
}
}
}
int main()
{
int N;
cout << "Enter number of vertices" << endl;
cin >> N;
gen_random_graph(N);
return 0;
}