Bug introduced in 9.0 or earlier and fixed in 12.0
Test the below function:
Func[g_] :=
Module[{G, vl, vdG},
G = g;
While[VertexCount[G] != 0,
vl = VertexList[G];
vdG = Map[VertexDegree[G, #] &, vl];
vl = Extract[vl, Position[vdG, Max[vdG]]];
G = VertexDelete[G, vl[[1]]];
];
Return[True];
]
with
While[g = RandomGraph[
BernoulliGraphDistribution[ RandomInteger[{50, 100}],
RandomReal[]]]; Func[g]; True]
The same if Module[{G=g,...
Good if G = Graph[VertexList[g], EdgeList[g]];
Is there any method to copy a graph efficiently?
{}
button above the edit window. The edit window help button?
is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$