graphs



 
I just made my graphs project sort of working within maxima. I think it
should be fairly easy now to improve it. Rather important probably, the
way the adjacency matrix (resp. array for hypergraphs) is stored should be
changed, to use sparse arrays if necessary...

Other than this, the following is already implemented, more or less 
intelligently... Certainly you will find stupid mistakes and stupid 
implementations. However, it was fun...

Comments, corrections and additions are very welcome.

Martin

(defun $hypergraph (vertices edges &rest type)
sets up a hypergraph, for example
z:hypergraph(['a,'b,'c,'d],[[['a,'b],'w],[['a,'b]],[['c,'d]],[['a,'c]]]);
makes z a graph with four vertices and three edges, two of which are 
weighted (an unweighted edge has in fact weight one)

z:hypergraph(['a,'b,'c,'d],[[['a,'b],'w],[['a,'b]],[['c,'d]],[['a,'c]]],'UNDIRECTED);
would give the underlying undirected graph.

(defun $complete_graph (n)
is the (undirected) complete graph on n+1 vertices

(defun $three_aztec (n)
is a special hypergraph (for odd n) that started all this, don't 
calculate its adjacency matrix!!! (too big, see the comment above)

(defun $edges (hgraph)
(defun $vertices (hgraph) (mvertices hgraph (G-vertices hgraph)))
(defun $adjacency_matrix (hgraph)
(defun $perfect_matchings (hgraph)
(defun $components (hgraph)

(defun $degree (hgraph vertex)
total degree of a vertex

(defun $degree_sequence (hgraph)

(defun $remove_edges (hgraph edges)
removes the edges specified from the hypergraph
eg:
y:remove_edges(z,[[['a,'b]]]);
will remove the edge [['a,'b]] with weight one.

(defun print-props (hgraph)
lists the properties already calculated

Attached file: graphs.lisp