Search code examples
sage

Create Graph in Sage


I want define new graph in sage. Let V be vector space over finite field GF(q). The graph's vertices are i-dimensional subspace from V and n-i -dimensional subspace from V and two vertices are adjacent if and only if direct sum of two subspace is V.

I have trouble with define this graph in sage. Any suggestion?


Solution

  • This should get you started:

    sage: p = 5
    sage: K = GF(p^2, 'a')
    sage: V = K^4
    sage: len(list(V.subspaces(1)))
    16276
    sage: len(list(V.subspaces(3)))
    16276
    

    So this graph is going to be pretty large: 16276 * 2 = 32552 vertices. Let's do a smaller example. Then you could do something like

    sage: p = 3
    sage: K = GF(p)
    sage: V = K^4
    sage: vertices = list(V.subspaces(1)) + list(V.subspaces(3))
    sage: for X in vertices:
    ....:     L = []
    ....:     for Y in vertices:
    ....:         if X + Y == V:
    ....:             L.append(Y)
    ....:     d[X] = L
    ....:     
    sage: Graph(d)
    Graph on 80 vertices