How to specify display



> But as usual output I'd like to have maxima print only the number of
> vertices and edges, its dimension, ... and the name of the graph.

That's fine; you can use the techniques I mentioned.

> I will probably have a problem with my current internal
> format, which is
>
> ((%hypergraph) (prop1 . value1) (prop2 . value2) ...)
>
> won't I ?

The problem with that format is not in display -- which can handle
anything you like -- but in the rest of the system.  Maxima general
representation (GR) requires everything to be either an atom or of the
form ((<symbol> <sexpr>...) <GR>...).  Maxima does use some non-GR
representations, notably rational expressions and Poisson series, but
unfortunately those are special-cased throughout the system, so you may
encounter problems -- at the very least, your users will get alarming
internal error messages rather than sensible error messages if they use
functions which don't know about this representation (e.g. length).  You
will also not be able to take advantage of Maxima's generic manipulation
facilities (e.g. subst, ev, map, part, ...).

> I don't think that it is necessary (or even wise) that a graph can be
> reconstructed from its output.

That is certainly your decision to make, though in general Maxima does
display the full value, even if it is very large -- the user can use "$"
instead of ";" if s/he doesn't want to display the full value.  You can
have a separate function for summarizing, e.g.

  (C1) graph_summary(z:complete_graph(5));
  (D1) [vertices: 5, 2edges: 10]

I would *very strongly* recommend, though, that the *linear* form
(grind) of a graph give enough information to reconstruct it.  That
allows the user to save the expression to a file in a readable format,
to cut and paste between processes, etc.

> ...a graph which is not assigned to a variable gets garbage collected,
> which is a good thing in my opinion

Yes, of course if the value is not accessible it gets garbage
collected -- that is handled by the underlying Lisp system, and you
don't even need to think about it.  But the result of a command is
always assigned to the variable Dnnn.  This is not handled by your graph
package, but by the Maxima system.  Once it is assigned to Dnnn, it will
not be garbage collected.  There is no difference as far as the system
is concerned between assigning to Z and to D123.  And this is an
important part of the Maxima system's semantics and interaction style.

This does not mean that the *display* of the value must include full
information on the value.  You can eat your cake and have it, too: just
define a display function (dimension-graph) which only shows what you
want it to show.

You mention the possibility of assigning a unique symbol to each graph.
You could of course do that, but what is the rationale?  It is not
consistent with other parts of Maxima (arithmetic expressions, matrices,
Taylor series, ...).  And variable assignment probably does what you
need; after all, assigning Graph2:Graph1 only copies a pointer, not the
full graph structure.

My recommendations in summary:

  * The internal form should follow General Representation.
  * The two-dimensional display form (dimension) can be a description
    rather than the full value.
  * The linear display form (grind) should include the full value.
  * Normal semantics should apply to graph values, assignment, etc.

Let me know if you need more information.

      -s