Needs["Combinatorica`"]
Needs["GraphUtilities`"]

nodeEventProb = 0.7; (* Node-event probability *)
edgeEventProb = 0.95; (* Edge-event probability *)
duplEventProb = 0.75; (* Duplication-event probability (duplication or fusion) *)

(* Conditional node-addition probability (given a node event). Conditional probability of node removal is 1-nodeAddProb *)
nodeAddProb = 1; 

(* Conditional edge-addition probability (given an edge event). 1-edgeAddProb is the conditional probability that an edge is removed *)
edgeAddProb = 0.9;

(* Conditional node-duplication probability (given a duplication/fusion event). Conditional node-merging probability is 1-duplProb *)
duplProb = 1;

(* Execute the function decideNodeEvent on the specified graph, use the resulting graph as input to decideEdgeEvent, use the resulting graph as input to decideDuplEvent *)
runEvents[graph_] := Composition[decideDuplEvent, decideEdgeEvent, decideNodeEvent][graph]

(* Call runNodeEvent and return the results or return the graph unchanged. Either way, it feeds into decideEdgeEvent, and so on  *)
decideNodeEvent[graph_] := RandomChoice[{nodeEventProb,(1-nodeEventProb)}->{runNodeEvent[graph],graph}]
decideEdgeEvent[graph_] := RandomChoice[{edgeEventProb,(1-edgeEventProb)}->{runEdgeEvent[graph],graph}]
decideDuplEvent[graph_] := RandomChoice[{duplEventProb,(1-duplEventProb)}->{runDuplEvent[graph],graph}]

(* Given that a node event will occur this iteration, choose between adding or removing  *)
runNodeEvent[graph_] := RandomChoice[{nodeAddProb,(1-nodeAddProb)}->{addNode[graph],removeNode[graph]}]
runEdgeEvent[graph_] := RandomChoice[{edgeAddProb,(1-edgeAddProb)}->{addEdge[graph],removeEdge[graph]}]
runDuplEvent[graph_] := RandomChoice[{duplProb,(1-duplProb)}->{duplicateNode[graph],mergeNodes[graph]}]

addNode[graph_] := AddVertex[graph]
removeNode[graph_] := If[V[graph]>1,
(*then*)DeleteVertex[graph,RandomChoice[VertexList[graph]]],
(*else*)graph
]

(* Adds an edge between two existing vertices (RandomSample will choose two different items from the range of 1 through #nodes) *)
addEdge[graph_] := If[V[graph]>1,
(*then*)MakeSimple[AddEdges[graph,{{RandomSample[Range[1,nodeCount[graph]],2]}}]] ,
(*else*)graph
]
removeEdge[graph_] := If[M[graph]>1,
(*then*)DeleteEdge[graph,RandomChoice[Edges[graph]]],
(*else*)graph
]

duplicateNode[graph_] := If[V[graph]>5,
(*then*)Module[{chosenNode = RandomChoice[VertexList[graph]]},
neighbors = Neighborhood[graph,chosenNode,1]; (* Neighborhood[g,v,k] returns the subset of vertices in g that are at a distance of k or less from vertex v *)
neighbors = DeleteCases[neighbors,chosenNode]; (* Don't include the chosen node itself in the list of its neighbors *)
graph = AddVertex[graph];
newNode = nodeCount[graph];
attachNode[neighbor_] := {{newNode,neighbor}};
newEdges = Map[attachNode,neighbors]; (* Build a list of all the new edges to be added *)
graph = MakeSimple[AddEdges[graph,newEdges]]
],
(*else*)graph
]
mergeNodes[graph_] := If[V[graph]>5,
(*then*)Contract[graph,RandomSample[Range[1,nodeCount[graph]],2]],
(*else*)graph
]

SeedRandom[123];
maxNodes = 250; 
myGraph = MakeGraph[{1}, False, Type->Undirected] ;(* One starting vertex, Edge rule is always False at outset, undirected graph *)
nodeCount[graph_] := V[graph] (* Delayed evaluation: V[] gives the number of vertices in the graph *)

iterationCount = 0;
While[nodeCount[myGraph] < maxNodes && iterationCount < 5000,
myGraph = runEvents[myGraph];
iterationCount = iterationCount + 1;
]
Print["myGraph: ",myGraph]
Print["Iterations to generate myGraph: ",iterationCount]

mySeq = DegreeSequence[myGraph]; (* Gives the sorted degree sequence of the graph *)
Print["myGraph degree sequence: ",mySeq]

myGraphNodes = V[myGraph] ;
myGraphEdges = M[myGraph] ;
(* Calculate the fraction of how many of the possible distinct edges in myGraph exist *)
randEdgeProb = (2 * myGraphEdges) / (myGraphNodes * (myGraphNodes-1)); 
Print["Edge probability for random graph: ",randEdgeProb, "  ~  ",randEdgeProb // N]

(* RandomGraph[n,p] Constructs a random labeled graph on n vertices with an edge probability of p. *)
randomGraph = RandomGraph[maxNodes,randEdgeProb];
Print["randomGraph: ",randomGraph]
randomSeq = DegreeSequence[randomGraph];
Print["randomGraph degree sequence: ",randomSeq]

Histogram[mySeq, Automatic,"Count",PlotRange->All, ImageSize->360,ImageMargins->5,AxesLabel->{"k","N(k)"},LabelStyle->Directive[10,FontFamily->"Century Schoolbook"],PlotLabel->Style["Growth process network, maxNodes = 250",12]
]
Export["myGraphHistogram.bmp",%];

Histogram[randomSeq, Automatic,"Count",PlotRange->All, ImageSize->360,ImageMargins->5,AxesLabel->{"k","N(k)"},LabelStyle->Directive[10,FontFamily->"Century Schoolbook"],PlotLabel->Style["Mathematica RandomGraph, maxNodes = 250",12]
]
Export["randomGraphHistogram.bmp",%];

ImagePad[ImageCrop[GraphPlot[myGraph,
Method->{"SpringElectricalEmbedding","RepulsiveForcePower"->-8,"InferentialDistance"->.5},
EdgeLabeling->Automatic,
VertexLabeling->Tooltip,
PackingMethod->{"ClosestPackingCenter","Padding"->1},
VertexRenderingFunction->({ColorData["DeepSeaColors"][(Degrees[myGraph][[#2]]/mySeq[[1]])],Opacity[0.9],EdgeForm[{Thin,Black}],Disk[#1,.01+.035*(Degrees[myGraph][[#2]]/mySeq[[1]])],Black}&),
EdgeRenderingFunction->({Opacity[0.3],AbsoluteThickness[0.5],Line[#1]}&),
ImageSize->1200,
ImageMargins->0]],20, White]
Export["myGraph.png",%];

ImagePad[ImageCrop[GraphPlot[randomGraph,
Method->{"SpringElectricalEmbedding","RepulsiveForcePower"->-8,"InferentialDistance"->.5},
EdgeLabeling->Automatic,
VertexLabeling->Tooltip,
PackingMethod->{"ClosestPackingCenter","Padding"->1},
VertexRenderingFunction->({ColorData["DeepSeaColors"][(Degrees[randomGraph][[#2]]/randomSeq[[1]])],Opacity[0.9],EdgeForm[{Thin,Black}],Disk[#1,.035*(Degrees[randomGraph][[#2]]/randomSeq[[1]])],Black}&),
EdgeRenderingFunction->({Opacity[0.3],AbsoluteThickness[0.5],Line[#1]}&),
ImageSize->1200,
ImageMargins->0]],20, White]
Export["randomGraph.png",%];