I am executing a program "Newprogram.gap" in GAP file in My Binder. There, I have an output which is an adjacency matrix, $A$ corresponding to a Cayley graph.
1). I need to add the command "PlotGraph(A);" to my program, so that when I input the necessary parameters to "Newprogram(arg);", an output which shows the plot will be generated in the GAP-Jupyter notebook.
Is there a way to do this? (Like, is there a command like Display(PlotGraph(A)); which enables me to plot it by running the program?)
When I first obtained the output of the adjacency matrix in the notebook, as "A1:=Newprogram(arg);" and then typed "PlotGraph(A1);" in the notebook, it was successfult and a plot was generated. But I would like to include the command to the program and execute it so that the output will be the graph.
2). Also, if there is another matrix or a list of coordinate pairs representing edges, which corresponds to a subgraph of the above graph, is there a way to plot the subgraph also on top of the same graph, marking the edges in a different colour?
I was able to load the packages like "JupyterViz" successfully, by typing "LoadPackage("PackageManager");" at the beginning of the notebook.
Thanks a lot in advance.
I am not familiar with JupyterViz. However, I know that you can use the Digraphs package to obtain some basic visualisation of directed and undirected graphs in GAP, including from within a Jupyter notebook. These are suitable for graphs on a small number of vertices.
The documentation of these features is given in Chapter 9, Section 1 of the Digraphs manual. The Digraphs package give a visualisation as a string in the
dotformat, which can be rendered via theSplashcommand – although within a Jupyter notebook, the commandJupyterSplashDotfrom theJupyterKernelpackage must be used instead ofSplash.There are many ways of specifying graphs and digraphs within the Digraphs package, including via a list of adjacencies, via an adjacency matrix, as the Cayley graph of some group, and so on (see Chapter 3 of the Digraphs manual).
Here is a basic example that might suit your purposes:
And this is how the output might look in a Jupyter notebook, using GAP's try-gap-in-jupyter binder: Link to screenshot of the output in a Jupyter notebook.
Moreover, in Digraphs v1.4.0 (the newest version, which is newer than the version available in that binder), it is possible to give colours to vertices and edges in these visualisations. For example:
gives the following output on my local machine: Link to screenshot of the output of a graph visualisation with coloured edges.