Hello everybody !!! I have been working with graphs in Sage for some time now, and I have a few remarks about how labels are defined in Graphs ( I may be wrong as I do not think I know ALL about graphs in Sage, so please tell me when I'm wrong ) :
- Vertices do not have any kind label. They just have names. - Edges have labels of the form (u,v,label) Well. Most of the time, I do not care about labels in graphs, and I do not like the fact that I have to write : for (u,v,l) in g.edges(): To iterate over the edges, always ignoring the last variable 'l'. It is weird to see an information appear where is never has to be used. You think this is just a unimportant remark, which is faaaaaaar from being one of the worst problems sage has ? I agree :-) The thing is that this label on the edges is the only way I know to deal with weighted graphs. And that I do not have the slightest idea of how to deal with graphs whose weights are associated to vertices instead of edges ( algorithms such as cliquer, or all the Linear Programming related graphs, deal with Weighted cliques, or Weighted cover, etc, etc ), and I see no clean way to implement functions dealing with vertex-weighted graphs. Actually, my question is the following : would it be a problem to have classes like Vertex, or Edge which would encode these data in a Graph ? It would also solve another problem : an edge (a,b) is sometimes returned as (b,a), and one has to check whether the two are equal. It would also let us define a numbering on the vertices totally independent from the labels... Many graphs algorithms are easy to implement when the vertices have names from [0,1,...,n-1], and the current "solution" when one has to build a function on an unknown graph is to first build a copy of that graph which would be correctly labeled, apply the algorithm and then return an answer according to the original graph's labels. Well, I just sent this message to gather thoughts about these things and begin to think about how to fix it. I only have my own experience, for the moment, so I need your help to devise a not-too-bad answer to all that :-) Thankkkkkks !!! Nathann Copying a graph just to ensure it is correctly labeled is not an elegant way to code for me ^^; --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---