Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: [Q] Problem with combinatorica

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.


You are not getting the value of g out. The following versions work:

CG[n_,p_] := 
       g := RandomGraph[n,p,Directed];
      If[ConnectedQ[g,Directed], g; Break[]] ];g) (*final g added*)

CG[n_,p_] := 
       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
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642

  • Prev by Date: Re: saving styles from notebooks: help, please!
  • Next by Date: Re: MathLink portnumbers and internal types
  • Prev by thread: [Q] Problem with combinatorica
  • Next by thread: prograMing: trees and indexes, 3