VectorSpace with labelled elements ?

4 views
Skip to first unread message

Nathann Cohen

unread,
Jul 27, 2010, 4:41:07 AM7/27/10
to Sage Support
Hello everybody !!!!

I have a small problems with graphs => I would like to be able to talk
about a Z/2Z vector space defined over its edges (any set of edges is
independent)

Of course I can just create a Z/2Z vector space of dimension G.size()
(number of edges), but this would later mean that I constantly have to
keep track of which edge is represented by [ 0 0 0 .... 0 1 0 ... 0 ].
Is there any nice way to define elements of a VectorSpace from an edge
without having to build dictionaries in bth way (as soon as something
is computed using the vector space, one would need to "convert" the
result to have it in term of edges)..

Thank youuuuu ! :-)

Nathann

Jason Grout

unread,
Jul 27, 2010, 5:31:20 AM7/27/10
to sage-s...@googlegroups.com

It sounds like you are just wanting an order on the edges. If you can
easily compute the index of an edge, you're set (that's the coordinate
of the edge). However, if your problem does not lend itself to that, it
sounds like the easiest thing to do is to maintain dicts to map between
an edge and its coordinate.

Of course, you can label the edge with it's coordinate vector, right?
There's your map going to the vector space. Coming from the vector
space probably requires the dict.

Thanks,

Jason

Nathann Cohen

unread,
Jul 27, 2010, 5:36:57 AM7/27/10
to sage-s...@googlegroups.com
> It sounds like you are just wanting an order on the edges.  If you can
> easily compute the index of an edge, you're set (that's the coordinate of
> the edge).  However, if your problem does not lend itself to that, it sounds
> like the easiest thing to do is to maintain dicts to map between an edge and
> its coordinate.
>
> Of course, you can label the edge with it's coordinate vector, right?
> There's your map going to the vector space.  Coming from the vector space
> probably requires the dict.

Hmmm... To be honest, if it was in my own code, or inside of a method,
I wouldn't mind at all... In this case, I am using the new method
cycle_basis from NetworkX to write a cycle_space method (if I find a
good way to do it), and I would like to return a "Nice" object...
Something like a vector space + a basis, and such that the elements of
the vector space can be easily translated to a set of edges, in both
directions. If I have to return dictionaries like this, perhaps it is
better to just forget about this cycle_space method, as it would mean
the user has to deal with all the nasty aspects of translation by
himself... :-/

Nathann

Reply all
Reply to author
Forward
0 new messages