I'm stuck with a function in Gap. I want to construct an induced subgraph but when I remove a vertex, example 3 in V=(1,2,3,4,5), Gap numbers the remaining vertices from 1-4. Can I somehow keep the vertex number as they were before? I use the trivial group when constructing graph with EdgeOrbitsGraph. There is a third parameter in the function but I haven't learned about groups yet so I don't know how to use it. Thank you
Example
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> T:=SymmetricGroup(0);
Group(())
gap> L:=[[1,2],[2,1],[1,3],[3,1],[2,3],[3,2]];
[ [ 1, 2 ], [ 2, 1 ], [ 1, 3 ], [ 3, 1 ], [ 2, 3 ], [ 3, 2 ] ]
gap> G:=EdgeOrbitsGraph(T, L, 3);
rec( adjacencies := [ [ 2, 3 ], [ 1, 3 ], [ 1, 2 ] ], group := Group(()),
isGraph := true, order := 3, representatives := [ 1, 2, 3 ],
schreierVector := [ -1, -2, -3 ] )
gap> V1:=[1,3];
[ 1, 3 ]
gap> H:=InducedSubgraph(G, V1);
rec( adjacencies := [ [ 2 ], [ 1 ] ], group := Group(()), isGraph := true,
names := [ 1, 3 ], order := 2, representatives := [ 1, 2 ],
schreierVector := [ -1, -2 ] )
As Alexander Konovalov says in his comments this is a documented feature of the function
InducedSubgraph. In fact, the vertex set of every graph in Grape is a range, for instance[ 1, 2, 3 ]and[ 1, 2 ]in your examplesGandH. The original vertex name/number can be found usingVertexName(H, v), whereHis the induced subgraph andvis a number in the vertex set, soVertexName(H, 2)in your example will return3.There are several reasons that graphs are implemented this way in Grape. Many of the algorithms in Grape (and graph algorithms in general) use the
adjacenciescomponent of the graph object in some way or other. For example,in your graph
G. The vertices adjacent to vertex1areadjacencies[1] = [ 2, 3 ].Suppose you have a graph with 1000000 vertices, and you want the induced subgraph with vertices
999999and1000000. If these vertices are not renamed, then the list ofadjacencieshas length1000000and uses as much memory as theadjacenciesof a 1 million vertex graph would. Even worse, many of the algorithms in Grape sequentially inspect the entries of the list of adjacencies. So, instead of inspecting two entries in our example, we have to inspect 1000000, even though only two of them even have a value. This results in more complicated and less efficient code.This could also be resolved by making the correspondence between the indices of
adjacenciesand the vertices in the graph different (i.e.adjacencies[i]wouldn't any longer be those vertices adjacent to the vertexi). But again this would make the code more complicated.