Re: [Q] Problem with combinatorica
- To: mathgroup@smc.vnet.net
- Subject: [mg11007] Re: [Q] Problem with combinatorica
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Mon, 16 Feb 1998 18:15:15 -0500
- References: <6c8prf$aqc@smc.vnet.net>
Konopnicki David wrote: > ... I defined > the following function: > CG[n_,p_] := > While[True, > g := RandomGraph[n,p,Directed]; > If[ConnectedQ[g,Directed], g; Break[]] ] > However, it doesn't work and I don't know why. David: You are not getting the value of g out. The following versions work: CG[n_,p_] := (While[True, g := RandomGraph[n,p,Directed]; If[ConnectedQ[g,Directed], g; Break[]] ];g) (*final g added*) CG[n_,p_] := Catch[While[True, g := RandomGraph[n,p,Directed]; If[ConnectedQ[g,Directed], Throw[g] ]]] CG[n_,p_] := FixedPoint[RandomGraph[n,p,Directed]&,1, SameTest -> (ConnectedQ[#2]&)] -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642