How to generate random graph of n vertices with random connections with specified number of Edge in matlab
11 views (last 30 days)
Show older comments
Though i have used the below code for generating the random graph of n vertices with random connections, it is even choosing the number of edges randomly. Could some one please help me to find the solution for this?
G = round(rand(n));
G = triu(G) + triu(G,1)';
G = G - diag(diag(G));
Example: n = 5; number of edges = 10
Response:
0 1 0 1 0
1 0 1 0 0
1 1 0 1 0
0 0 1 0 1
0 1 0 0 0
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!