Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I want define new graph in sage. Let $V$ be vector space over finite field $GF(q)$. The graph's vertices are 1-dimensional subspace from $V$ and $n-1$ -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?

share|improve this question
3  
ask.sagemath.org is probably more appropriate. –  Jair Taylor Aug 22 '12 at 20:37
    
I vote AGAINST closing. Questions about mathematical software are stated as being okay in the FAQ somewhere (don't remember where). If any one wants to vote to close, please cancel this vote against closing instead of actually voting to close. –  Graphth Sep 25 '12 at 20:27
    
Actually, it's one of the first things in the FAQ: math.stackexchange.com/faq It specifically says that questions are welcome if they are about "Software that mathematicians use" So anyone voting to close as off-topic is voting against the FAQ. –  Graphth Sep 25 '12 at 20:30

1 Answer 1

up vote 5 down vote accepted

Here is a simple algorithm to create the graph you want.

p=5
n=3
V=VectorSpace(GF(p),n)
edges=[]
for i in V.subspaces(1):
  for j in V.subspaces(n-1):
    gens=list(j.gens())
    gens.append(i.gens()[0])
    H=V.subspace(gens)
    if(H.dimension()==n):
      edges.append((i,j))

G=Graph(edges)

I'm not sure what you want to label them, so the edges are actually the current vectorspaces, which is rather inefficient. You should probably come up with a simple naming scheme using a python dictionary, for instance. There are also likely faster ways to compute this that cut out a good deal of the tests.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.