[GAP Forum] Issue with "Read" function - in GAP
Chris Jefferson
caj21 at st-andrews.ac.uk
Sun Nov 10 22:29:55 GMT 2013
The short answer is, your code is working as (I think) you expect,
except when you call 'Read', GAP does not print out results after every
statement, like it does in interactive mode.
So, you have to have a 'LoadPackage("grape")' either at the start of
your .g file, or interactively (or both, it doesn't matter if you load a
package twice).
GAP has read your file and run all the commands, you can see this by
typing 'C' after your Read, like this:
gap> Read("C:/Users/Home/Desktop/Collage/Independent_Studies/Programs/Symm_Star_3.g");
gap> C;
rec( adjacencies := [ [ 3, 6 ] ], group := Group([ (1,4,5)(2,3,6), (1,3)(2,4)(5,6) ]), isGraph := true, isSimple := true, names := [ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ], order := 6,
representatives := [ 1 ], schreierVector := [ -1, 2, 2, 1, 1, 1 ] )
If you want output from a file you read, then use the Print statement. For example, changing your file to:
LoadPackage("grape");
C := CayleyGraph(SymmetricGroup(3),[(1,2),(1,3)]);
Print("The Diameter is:", Diameter(C), "\n");
Gives me the output:
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Loading GRAPE 4.6.1 (GRaph Algorithms using PErmutation groups)
by Leonard H. Soicher (http://www.maths.qmul.ac.uk/~leonard/).
Homepage: http://www.maths.qmul.ac.uk/~leonard/grape/
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
The Diameter is:3
(The "\n" in the 'Print' Statement is a term used in many languages for "start a new line")
On 26/10/13 19:03, Sreedevi Muthukumar wrote:
> Dear All,
>
> I'm a new GAP user and a student, I'm working with Grape package in GAP to
> learn about graphs.
>
> I tried to execute a "xxx.g" file using "Read" function as given below in
> two methods.
>
> Please kindly check the methods I have tried and guide me to correct this
> problem.
>
>
> *Method 1: *
>
> As Read("Path/filename.g"); function is used to read and execute set of
> commands in GAP.
>
> I created a file named "Symm_Star_3.g" to create a cayley graph.
>
> *Symm_Star_3.g*
> C := CayleyGraph(SymmetricGroup(3),[(1,2),(1,3)]);
> Diameter(C);
>
> After executing the Read function I got the below error message.
>
> gap>
> Read("C:/Users/Home/Desktop/Collage/Independent_Studies/Programs/Symm_Star_3.g");
> Error, Variable: 'CayleyGraph' must have a value
> not in any function at line 1 of
> C:/Users/Home/Desktop/Collage/Independent_Studies/Programs/Symm_Star_3.g
>
> *As CayleyGraph command is present in grape package , I invoked the grape
> package as follows,then executed the .g file*
>
> gap> LoadPackage("grape");
> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> Loading GRAPE 4.6.1 (GRaph Algorithms using PErmutation groups)
> by Leonard H. Soicher (http://www.maths.qmul.ac.uk/~leonard/).
> Homepage: http://www.maths.qmul.ac.uk/~leonard/grape/
> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> true
>
> gap>
> Read("C:/Users/Home/Desktop/Collage/Independent_Studies/Programs/Symm_Star_3.g");
> gap>
>
> Now after invoking the grape package and then executing the Read function,
> is not producing any output as shown above.
>
> *Method 2:*
>
> I tried to invoke the package directly from the .g file as follows.
>
> *Symm_Star_3.g*
> *
> *
> LoadPackage("grape");
> C := CayleyGraph(SymmetricGroup(3),[(1,2),(1,3)]);
> Diameter(C);
>
>
> Now executing the Read function , is just invoking the package and not
> executing the other commands in the .g file.
>
> gap>
> Read("C:/Users/Home/Desktop/Collage/Independent_Studies/Programs/Symm_Star_3.g");
> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> Loading GRAPE 4.6.1 (GRaph Algorithms using PErmutation groups)
> by Leonard H. Soicher (http://www.maths.qmul.ac.uk/~leonard/).
> Homepage: http://www.maths.qmul.ac.uk/~leonard/grape/
> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> gap>
>
>
> Please guide me to correct this issue and help me to use "Read" function ,
> to read a file with set of graph commands, after invoking Grape package.
>
> Thanking you,
> Sree Devi.
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
More information about the Forum
mailing list