({{, (RefLink[RandomGraph, paclet:ref/RandomGraph])[{n,m}] 
gives a pseudorandom graph with n vertices and m edges.}, {, (RefLink[RandomGraph, paclet:ref/RandomGraph])[{n,m},k]
gives a list of k pseudorandom graphs.}, {, (RefLink[RandomGraph, paclet:ref/RandomGraph])[gdist,…]
samples from the random graph distribution gdist.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[RandomGraph, paclet:ref/RandomGraph])[{n,m}] is equivalent to (RefLink[RandomGraph, paclet:ref/RandomGraph])[(RefLink[UniformGraphDistribution, paclet:ref/UniformGraphDistribution])[n,m]].

(RefLink[RandomGraph, paclet:ref/RandomGraph]) gives a different sequence of pseudorandom graphs whenever you run the Wolfram Language. By using (RefLink[SeedRandom, paclet:ref/SeedRandom]), you can get a repeatable sequence.

Vertices are taken to be integers 1, …, n.

A method option to (RefLink[SeedRandom, paclet:ref/SeedRandom]) can be given to specify the pseudorandom generator used.

(RefLink[RandomGraph, paclet:ref/RandomGraph])[dist,{(Subscript[n, 1]),(Subscript[n, 2]),…}] gives an (Subscript[n, 1])×(Subscript[n, 2])×… array of graphs.

(RefLink[RandomGraph, paclet:ref/RandomGraph]) has the same options as (RefLink[Graph, paclet:ref/Graph]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (99)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Generate a random graph on 5 vertices and 6 edges:

RandomGraph[{5, 6}]

Simulate a graph property distribution:

RandomGraph[BernoulliGraphDistribution[6,0.4]]

data=EdgeCount /@ RandomGraph[BernoulliGraphDistribution[6,0.4],10^3];

Show[Histogram[data,Automatic,"PDF"],
DiscretePlot[PDF[BinomialDistribution[15,0.4],m],{m,0,15},Joined-> True]]

OpenersExampleSection1(Spacer1)Scope  (12)

Generate a pseudorandom graph with a given number of vertices and edges:

RandomGraph[{5,6}]

A directed pseudorandom graph:

RandomGraph[{6,7},DirectedEdges-> True]

Generate arrays of different sizes and dimensions:

RandomGraph[BernoulliGraphDistribution[8,0.3],4]

An array of graphs:

RandomGraph[BernoulliGraphDistribution[8,0.3],{2,3}]

Generate random graphs distributed according to the Barabasi–Albert model:

RandomGraph[BarabasiAlbertGraphDistribution[15,2],4]

Generate random graphs that are Bernoulli distributed:

RandomGraph[BernoulliGraphDistribution[8,0.4],4]

Generate random graphs that are uniformly distributed:

RandomGraph[UniformGraphDistribution[8,12],4]

Generate random graphs with given degree sequence:

RandomGraph[DegreeGraphDistribution[{3,3,3,3,3,3,3,3}],4]

Generate random spatial graphs:

RandomGraph[SpatialGraphDistribution[15,0.35],4]

Generate random graphs distributed according to the Price model:

RandomGraph[PriceGraphDistribution[15,2,1],4]

Generate random graphs distributed according to the Watts–Strogatz model:

RandomGraph[WattsStrogatzGraphDistribution[15,0.2],4]

Generate random graphs of large size:

g=RandomGraph[{(10^4),(10^4)}];

{VertexCount[g],EdgeCount[g]}

OpenersExampleSection2(Spacer1)Options  (70)

OpenersExampleSubsection0(Spacer1)DirectedEdges  (1)

By default, an undirected graph is generated:

RandomGraph[{4,5}]

Use (RefLink[DirectedEdges, paclet:ref/DirectedEdges])->(RefLink[True, paclet:ref/True]) to generate a directed graph:

RandomGraph[{4,5},DirectedEdges-> True]

OpenersExampleSubsection1(Spacer1)EdgeLabels  (6)

Label the edge 1<->2:

RandomGraph[{3,3},EdgeLabels->{1\[UndirectedEdge]2->"Hello"}]

Label all edges:

el=EdgeList[RandomGraph[{3,3}]]

RandomGraph[{3,3},EdgeLabels->Table[el[[i]]->(Subscript["e", i]),{i,Length[el]}]]

Use (RefLink[Placed, paclet:ref/Placed]) with symbolic locations to control label placement along an edge:

Table[RandomGraph[{3,3},EdgeLabels->{1\[UndirectedEdge]2->Placed["■■■",p]},PlotLabel->p],{p,{"Start","Middle","End"}}]

Use explicit coordinates to place labels:

Table[RandomGraph[{3,3},EdgeLabels->{1\[UndirectedEdge]2->Placed["■■■",p]},PlotLabel->p,BaselinePosition->Bottom],{p,{0,1/4,1/3}}]

Vary positions within the label:

Table[RandomGraph[{3,3},EdgeLabels->{1\[UndirectedEdge]2->Placed["■■■",{1/2,p}]},PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place multiple labels:

RandomGraph[{3,3},EdgeLabels->{3\[UndirectedEdge]1->Placed[{"lbl1","lbl2"},{"Start","End"}]}]

RandomGraph[{3,3},EdgeLabels->{3\[UndirectedEdge]1->Placed[{"lbl1","lbl2","lbl3"},{"Start","Middle","End"}]}]

Use automatic labeling by values through (RefLink[Tooltip, paclet:ref/Tooltip]) and (RefLink[StatusArea, paclet:ref/StatusArea]):

RandomGraph[{3,3},EdgeLabels->Placed["Name",Tooltip]]

RandomGraph[{3,3},EdgeLabels->Placed["Name",StatusArea]]

OpenersExampleSubsection2(Spacer1)EdgeShapeFunction  (6)

Get a list of built-in settings for (RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]):

GraphElementData["Edge"]

Undirected edges including the basic line:

RandomGraph[{3,3},EdgeShapeFunction->"Line"]

Lines with different glyphs on the edges:

Table[RandomGraph[{3,3},EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,{"BoxLine","DiamondLine","DotLine"}}]

Directed edges including solid arrows:

Table[RandomGraph[{3,3},EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","FilledArrow"]}]

Line arrows:

Table[RandomGraph[{3,3},EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","UnfilledArrow"]}]

Open arrows:

Table[RandomGraph[{3,3},EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","CarvedArrow"]}]

Specify an edge function for an individual edge:

RandomGraph[{3,3},EdgeShapeFunction->{1\[UndirectedEdge]2->"DotLine"}]

Combine with a different default edge function:

RandomGraph[{3,3},EdgeShapeFunction->{1\[UndirectedEdge]2->"BoxLine","DotLine"}]

Draw edges by running a program:

ef[pts_List,e_]:=
Block[{s=0.015,g=},{Arrowheads[{{s,0.33,g},{s,0.67,g}}],Arrow[pts]}]

RandomGraph[{3,3},EdgeShapeFunction->ef]

(RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]) can be combined with (RefLink[EdgeStyle, paclet:ref/EdgeStyle]):

RandomGraph[{3,3},EdgeStyle->Blue,EdgeShapeFunction->(Line[#1]&)]

(RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]) has higher priority than (RefLink[EdgeStyle, paclet:ref/EdgeStyle]):

RandomGraph[{3,3},EdgeStyle->Blue,EdgeShapeFunction->({Red,Line[#1]}&)]

OpenersExampleSubsection3(Spacer1)EdgeStyle  (2)

Style all edges:

Table[RandomGraph[{6,6},EdgeStyle->style,PlotLabel->style],{style,{Gray,Dashed,Thick}}]

Style individual edges:

RandomGraph[{3,3},EdgeStyle->{1\[UndirectedEdge]2->Blue,2\[UndirectedEdge]3->Dashed}]

OpenersExampleSubsection4(Spacer1)GraphHighlight  (3)

Highlight the vertex 1:

RandomGraph[{3,3},VertexSize->Tiny,GraphHighlight->{1}]

Highlight the edge 2<->3:

RandomGraph[{3,3},VertexSize->Tiny,GraphHighlight->{2\[UndirectedEdge]3}]

Highlight vertices and edges:

RandomGraph[{3,3},VertexSize->Tiny,GraphHighlight->{1,2,1\[UndirectedEdge]2,1\[UndirectedEdge]3}]

OpenersExampleSubsection5(Spacer1)GraphHighlightStyle  (2)

Get a list of built-in settings for (RefLink[GraphHighlightStyle, paclet:ref/GraphHighlightStyle]):

GraphElementData["GraphHighlightStyle"]

Use built-in settings for (RefLink[GraphHighlightStyle, paclet:ref/GraphHighlightStyle]):

RandomGraph[{3,3},GraphHighlight->{1,2\[UndirectedEdge]3},VertexSize->Small,GraphHighlightStyle->#,PlotLabel->#]&/@Select[GraphElementData["GraphHighlightStyle"],#=!=Automatic&]

OpenersExampleSubsection6(Spacer1)GraphLayout  (4)

By default, the layout is chosen automatically:

RandomGraph[{3,3},GraphLayout->Automatic]

Specify layouts on special curves:

Table[RandomGraph[{10,20},GraphLayout->l,PlotLabel->l],{l,{"CircularEmbedding","SpiralEmbedding"}}]

Specify layouts that satisfy optimality criteria:

Table[RandomGraph[{10,20},GraphLayout->l,PlotLabel->l],{l,{"SpringEmbedding","SpringElectricalEmbedding","HighDimensionalEmbedding"}}]

Use (RefLink[AbsoluteOptions, paclet:ref/AbsoluteOptions]) to extract (RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) computed using a layout algorithm:

RandomGraph[{3,3}]

AbsoluteOptions[%,VertexCoordinates]

OpenersExampleSubsection7(Spacer1)PlotTheme  (4)

OpenersExampleSubsubsection0(Spacer1)Base Themes  (2)

Use a common base theme:

RandomGraph[{3,3},PlotTheme->"Business"]

Use a monochrome theme:

RandomGraph[{3,3},PlotTheme->"Monochrome"]

OpenersExampleSubsubsection1(Spacer1)Feature Themes  (2)

Use a large graph theme:

RandomGraph[{3,3},PlotTheme->"LargeGraph"]

Use a classic diagram theme:

RandomGraph[{3,3},PlotTheme->"ClassicDiagram"]

OpenersExampleSubsection9(Spacer1)VertexCoordinates  (3)

By default, any vertex coordinates are computed automatically:

RandomGraph[{3,3}]

Extract the resulting vertex coordinates using (RefLink[AbsoluteOptions, paclet:ref/AbsoluteOptions]):

AbsoluteOptions[%,VertexCoordinates]

Specify a layout function along an ellipse:

ellipseLayout[n_,{a_,b_}]:=Table[{a Cos[2Pi/n u],b Sin[2Pi/n u]},{u,1,n}]

Graphics[Point[ellipseLayout[20,{2,1}]]]

Use it to generate vertex coordinates for a graph:

RandomGraph[{20,25},VertexCoordinates->ellipseLayout[20,{2,1}]]

(RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) has higher priority than (RefLink[GraphLayout, paclet:ref/GraphLayout]):

RandomGraph[{3,3},VertexCoordinates->Table[{i,i},{i,3}],GraphLayout->"CircularEmbedding"]

OpenersExampleSubsection10(Spacer1)VertexLabels  (13)

Use vertex names as labels:

RandomGraph[{3,3},VertexLabels->"Name"]

Label individual vertices:

RandomGraph[{3,3},VertexLabels->{3->"one"}]

Label all vertices:

RandomGraph[{3,3},VertexLabels->Table[i->(Subscript[v, i]),{i,3}]]

Use any expression as a label:

RandomGraph[{3,3},VertexLabels->{1->,2->,3->},ImagePadding->30]

Use (RefLink[Placed, paclet:ref/Placed]) with symbolic locations to control label placement, including outside positions:

Table[RandomGraph[{3,3},VertexSize->0.1,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p,ImagePadding->20],{p,{Before,After,Below,Above}}]

Symbolic outside corner positions:

pl={{Before,Below},{After,Below},{Before,Above},{After,Above}};

Table[RandomGraph[{3,3},VertexSize->0.1,VertexShapeFunction->"Square",ImagePadding->20,VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p],{p,pl}]

Symbolic inside positions:

Table[RandomGraph[{3,3},VertexSize->0.6,VertexLabels->Table[i->Placed["■■■",p],{i,3}],VertexShapeFunction->"Square",PlotLabel->p],{p,{Left,Top,Right,Bottom}}]

Symbolic inside corner positions:

pl={{Left,Bottom},{Right,Bottom},{Left,Top},{Right,Top}};

Table[RandomGraph[{3,3},VertexSize->0.6,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p],{p,pl}]

Use explicit coordinates to place the center of labels:

Table[RandomGraph[{3,3},VertexSize->0.6,ImagePadding->10,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed[,p],{i,3}],PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:

Table[RandomGraph[{3,3},VertexSize->0.6,VertexShapeFunction->"Square",ImagePadding->20,VertexLabels->Table[i->Placed[,{{1,1},p}],{i,3}],PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place multiple labels:

RandomGraph[{3,3},VertexLabels->{1->Placed[{"lbl1","lbl2"},{Above,Below}]}]

Any number of labels can be used:

RandomGraph[{3,3},VertexLabels->{1->Placed[{"lbl1","lbl2","lbl3","lbl4"},{Above,After,Below,Before}]}]

Use the argument to (RefLink[Placed, paclet:ref/Placed]) to control formatting, including (RefLink[Tooltip, paclet:ref/Tooltip]):

RandomGraph[{3,3},VertexLabels->Placed["Name",Tooltip]]

Or (RefLink[StatusArea, paclet:ref/StatusArea]):

RandomGraph[{3,3},VertexLabels->Placed["Name",StatusArea]]

Use more elaborate formatting functions:

rotateLabel[lab_]:=Rotate[lab,45Degree]

RandomGraph[{3,3},VertexLabels->Table[i->Placed["xxx",Below,rotateLabel],{i,3}]]

panelLabel[lab_]:=Panel[lab,FrameMargins->0,Background->Lighter[Yellow,0.7]]

RandomGraph[{3,3},VertexLabels->Table[i->Placed["xxx",Center,panelLabel],{i,3}]]

hyperlinkLabel[lab_]:=Hyperlink[lab,"http://www.wolfram.com"]

RandomGraph[{3,3},VertexLabels->Table[i->Placed["xxx",Center,hyperlinkLabel],{i,3}]]

OpenersExampleSubsection11(Spacer1)VertexShape  (5)

Use any (RefLink[Graphics, paclet:ref/Graphics]), (RefLink[Image, paclet:ref/Image]), or (RefLink[Graphics3D, paclet:ref/Graphics3D]) as a vertex shape:

Table[RandomGraph[{3,3},VertexShape->s,VertexSize->Medium],{s,{,,}}]

Specify vertex shapes for individual vertices:

RandomGraph[{3,3},VertexShape->{2->},VertexSize->Medium]

(RefLink[VertexShape, paclet:ref/VertexShape]) can be combined with (RefLink[VertexSize, paclet:ref/VertexSize]):

Table[RandomGraph[{3,3},VertexSize->s,VertexShape->],{s,{Small,Large}}]

(RefLink[VertexShape, paclet:ref/VertexShape]) is not affected by (RefLink[VertexStyle, paclet:ref/VertexStyle]):

RandomGraph[{3,3},VertexSize->0.2,VertexShape->,VertexStyle->Blue]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexShape, paclet:ref/VertexShape]):

RandomGraph[{3,3},VertexSize->0.1,VertexShapeFunction->"Square",VertexShape->]

OpenersExampleSubsection12(Spacer1)VertexShapeFunction  (9)

Get a list of built-in collections for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]):

GraphElementData["Vertex"]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Basic" collection:

GraphElementData["Vertex","Basic"]

Simple basic shapes:

Table[RandomGraph[{3,3},VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,{"Triangle","Square","Rectangle","Pentagon","Hexagon","Octagon"}}]

Common basic shapes:

Table[RandomGraph[{3,3},VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,{"DownTrapezoid","UpTrapezoid","Parallelogram","FiveDown","Circle","Diamond","Star","Capsule"}}]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Rounded" collection:

GraphElementData["Vertex","Rounded"]

Table[RandomGraph[{3,3},VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,GraphElementData["Vertex","Rounded"]}]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Concave" collection:

GraphElementData["Vertex","Concave"]

Table[RandomGraph[{3,3},VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,GraphElementData["Vertex","Concave"]}]

Draw individual vertices:

RandomGraph[{3,3},VertexShapeFunction->{ 1->"Square"},VertexSize->0.2]

Combine with a default vertex function:

RandomGraph[{3,3},VertexShapeFunction->{ 1->"Square","Triangle"},VertexSize->0.2]

Draw vertices by running a program:

vf[{xc_,yc_},name_,{w_,h_}]:=
Block[{xmin=xc-w,xmax=xc+w,ymin=yc-h,ymax=yc+h},
Polygon[{{xmin,ymin},{xmax,ymax},{xmin,ymax},{xmax,ymin}}]
];

RandomGraph[{3,3},VertexShapeFunction->vf,VertexSize->0.1]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf1[{xc_,yc_},name_,{w_,h_}]:=Rectangle[{xc-w,yc-h},{xc+w,yc+h}]

RandomGraph[{3,3},VertexSize->0.1,VertexStyle->Blue,VertexShapeFunction->vf1]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf2[{xc_,yc_},name_,{w_,h_}]:={Red,Rectangle[{xc-w,yc-h},{xc+w,yc+h}]}

RandomGraph[{3,3},VertexSize->0.1,VertexStyle->Blue,VertexShapeFunction->vf2]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexShape, paclet:ref/VertexShape]):

RandomGraph[{3,3},VertexSize->0.3,VertexShape->{1->}]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexShape, paclet:ref/VertexShape]):

RandomGraph[{3,3},VertexSize->0.3,VertexShapeFunction->"Star",VertexShape->]

OpenersExampleSubsection13(Spacer1)VertexSize  (8)

By default, the size of vertices is computed automatically:

RandomGraph[{3,3},VertexSize->Automatic]

Specify the size of all vertices using symbolic vertex size:

Table[RandomGraph[{3,3},VertexSize->s,PlotLabel->s],{s,{Tiny,Small,Medium,Large}}]

Use a fraction of the minimum distance between vertex coordinates:

Table[RandomGraph[{3,3},VertexSize->s,PlotLabel->s],{s,0.1,1,0.3}]

Use a fraction of the overall diagonal for all vertex coordinates:

Table[RandomGraph[{3,3},VertexSize->{"Scaled", s},PlotLabel->{"Scaled", s}],{s,0.1,1,0.3}]

Specify size in both the x and y directions:

Table[RandomGraph[{3,3},VertexSize->s,PlotLabel->s],{s,{{0.1,0.2},{0.2,0.1}}}]

Specify the size for individual vertices:

RandomGraph[{3,3},VertexSize->{1->0.2,2->0.3}]

(RefLink[VertexSize, paclet:ref/VertexSize]) can be combined with (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]):

Table[RandomGraph[{3,3},VertexSize->s,VertexShapeFunction->"Square",PlotLabel->s],{s,{0.05,0.1,0.2}}]

(RefLink[VertexSize, paclet:ref/VertexSize]) can be combined with (RefLink[VertexShape, paclet:ref/VertexShape]):

Table[RandomGraph[{3,3},VertexSize->s,VertexShape->,PlotLabel->s],{s,{0.1,0.2,0.4}}]

OpenersExampleSubsection14(Spacer1)VertexStyle  (4)

Style all vertices:

Table[RandomGraph[{3,3},VertexStyle->style,VertexSize->0.3,PlotLabel->style],{style,{Yellow,EdgeForm[Dashed]}}]

Style individual vertices:

RandomGraph[{3,3},VertexStyle->{1->Blue,2->Red},VertexSize->Small]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf1[{xc_,yc_},name_,{w_,h_}]:=Rectangle[{xc-w,yc-h},{xc+w,yc+h}]

RandomGraph[{3,3},VertexSize->0.1,VertexStyle->Blue,VertexShapeFunction->vf1]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf2[{xc_,yc_},name_,{w_,h_}]:={Red,Rectangle[{xc-w,yc-h},{xc+w,yc+h}]}

RandomGraph[{3,3},VertexSize->0.1,VertexStyle->Blue,VertexShapeFunction->vf2]

(RefLink[VertexStyle, paclet:ref/VertexStyle]) can be combined with (RefLink[BaseStyle, paclet:ref/BaseStyle]):

RandomGraph[{3,3},VertexStyle->LightBlue,BaseStyle->EdgeForm[Dotted],VertexSize->0.2]

(RefLink[VertexStyle, paclet:ref/VertexStyle]) has higher priority than (RefLink[BaseStyle, paclet:ref/BaseStyle]):

RandomGraph[{3,3},VertexStyle->LightBlue,BaseStyle->Gray,VertexSize->0.2]

OpenersExampleSection3(Spacer1)Applications  (3)

Generate random data for a property of a graph distribution and compare its histogram to the PDF:

data=EdgeCount/@RandomGraph[BernoulliGraphDistribution[10,0.7],10^3];

𝒟=GraphPropertyDistribution[EdgeCount[g],g\[Distributed]BernoulliGraphDistribution[10,0.7]];

Show[Histogram[data,Automatic,"ProbabilityDensity"],DiscretePlot[PDF[𝒟,k],{k,20,40},PlotStyle->PointSize[Medium]]]

Verify that the degree for a vertex in a Bernoulli graph follows a binomial distribution:

data=VertexDegree[#,1]&/@RandomGraph[BernoulliGraphDistribution[15,0.7],10^3];

EstimatedDistribution[data,BinomialDistribution[n,p]]

Show[Histogram[data,Automatic,"ProbabilityDensity"],DiscretePlot[PDF[%,k],{k,0,15},PlotStyle->PointSize[Medium]]]

Simulate interaction networks, knowing the number of interactions of each node within the group:

𝒢=DegreeGraphDistribution[{2,4,4,4,3,3,2}];

RandomGraph[𝒢,4]

OpenersExampleSection4(Spacer1)Properties & Relations  (10)

(RefLink[RandomGraph, paclet:ref/RandomGraph]) uses integer vertices:

g=RandomGraph[{7,10},VertexLabels-> "Name"]

VertexList[g]

Use (RefLink[VertexReplace, paclet:ref/VertexReplace]) to replace vertices in the graph:

VertexReplace[g,{1->(Subscript[v, 1]),2->(Subscript[v, 2]),3->(Subscript[v, 3]),4->(Subscript[v, 4]),5->(Subscript[v, 5]),6->(Subscript[v, 6]),7->(Subscript[v, 7])}]

VertexList[%]

Use (RefLink[SeedRandom, paclet:ref/SeedRandom]) to get repeatable random graphs:

{RandomGraph[{6,5}],RandomGraph[{6,5}]}

{SeedRandom[1];RandomGraph[{6,5}],SeedRandom[1];RandomGraph[{6,5}]}

Use (RefLink[BlockRandom, paclet:ref/BlockRandom]) to block one use of (RefLink[RandomGraph, paclet:ref/RandomGraph]) from affecting others:

{BlockRandom[RandomGraph[{6,5}]],RandomGraph[{6,5}]}

(RefLink[RandomVariate, paclet:ref/RandomVariate]) generates variates from probability distributions:

RandomVariate[NormalDistribution[]]

(RefLink[RandomInteger, paclet:ref/RandomInteger]) generates uniform discrete random variates:

RandomInteger[{0,10},10]

(RefLink[RandomReal, paclet:ref/RandomReal]) generates uniform continuous variates:

RandomReal[{0,10},10]

(RefLink[RandomChoice, paclet:ref/RandomChoice]) generates random choices with replacement from a list:

RandomChoice[Range[10],10]

(RefLink[RandomSample, paclet:ref/RandomSample]) generates random choice without replacement from a list:

RandomSample[Range[20],10]

(RefLink[RandomPrime, paclet:ref/RandomPrime]) generates a random prime number:

RandomPrime[{1,100},10]

(RefLink[RandomImage, paclet:ref/RandomImage]) generates a random image:

RandomImage[LaplaceDistribution[0,.2],{100,100}]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

The number of edges of a simple graph on n vertices is less than or equal to (Binomial[n, 2]):

RandomGraph[{5,11}]

(RefLink[RandomGraph, paclet:ref/RandomGraph])[{n,(RefLink[Binomial, paclet:ref/Binomial])[n,2]}] always gives the complete graph with n vertices:

RandomGraph[{5,10},3]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Generate random star constellations:

RandomGraph[SpatialGraphDistribution[100,0.08],VertexStyle->White,EdgeStyle->Gray,Background->Black,VertexSize->Table[i->RandomReal[{1,3}],{i,100}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BernoulliGraphDistribution, paclet:ref/BernoulliGraphDistribution])  ▪  (RefLink[UniformGraphDistribution, paclet:ref/UniformGraphDistribution])  ▪  (RefLink[BarabasiAlbertGraphDistribution, paclet:ref/BarabasiAlbertGraphDistribution])  ▪  (RefLink[PriceGraphDistribution, paclet:ref/PriceGraphDistribution])  ▪  (RefLink[WattsStrogatzGraphDistribution, paclet:ref/WattsStrogatzGraphDistribution])  ▪  (RefLink[DegreeGraphDistribution, paclet:ref/DegreeGraphDistribution])  ▪  (RefLink[SeedRandom, paclet:ref/SeedRandom])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Social Network Analysis, paclet:guide/SocialNetworks])}, {▪(RefLinkPlain[Graph Construction & Representation, paclet:guide/GraphConstructionAndRepresentation])}, {▪(RefLinkPlain[Random Graphs, paclet:guide/RandomGraphs])}, {▪(RefLinkPlain[Graphs & Networks, paclet:guide/GraphsAndNetworks])}, {▪(RefLinkPlain[Scientific Models, paclet:guide/ScientificModels])}, {▪(RefLinkPlain[Random Number Generation, paclet:guide/RandomNumberGeneration])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/21-graphs-and-networks.html])(WebLink[: Graphs and Networks, https://www.wolfram.com/language/elementary-introduction/21-graphs-and-networks.html])}})}})