Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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.

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




  • 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