How to generate random directed connected graph?
I need to create graph which will pass:
ConnectedGraphQ[^]
|
How to generate random directed connected graph? I need to create graph which will pass:
|
||||
| show 5 more comments |
|
A random geometric graph is generated by choosing some points in the plane and then connecting two vertices if they are within a certain distance. If the distance is chosen appropriately, the graph will be connected. Here's an implementation that uses a bisection method to determine the smallest appropriate distance.
Not terribly efficient, of course. 1000 vertices took about 30 sec.
Here's a geometric random graph with a highlighted spanning tree which is minimal with respect to total edge length, yielding an interesting dendritic structure.
|
|||||||
|
|
Here is my solution:
|
|||
|
|
|
With even small (reasonably) edge probabilities this function will generate in a reasonably short time random directed connected graph:
Use:
Check:
|
|||
|
|
|
Here's a rejection method:
|
||||
|
|
RandomGraph[]? It has aDirectedEdgesoption... – J. M.♦ Oct 12 '12 at 13:23RandomGraphuntil you obtain a connected one. – whuber Oct 12 '12 at 14:04RandomGraphto get a sense of its emphasis on allowing the user to specify how many vertices, how many edges, and the distribution of the edge frequencies. When you don't pay any attention to the distribution, you open yourself up to silly output. – whuber Oct 12 '12 at 15:18