Re: Graphs, etc...



Hi!

I spent some time on my maxima/graphs.lisp project and found solutions to
most of my "problems". I now have a lisp file (attached) containing the
ideas of the future implementation.

The next step is to make a maxima package out of this. I started doing
this, but there is a lot missing. By the way, how should I call $matrix
and $array (for n-hypergraphs I have an adjacency array, not a matrix...)
from lisp?

Martin

Comments are very welcome!

to get an impression, try the following:

(start-your-favorite-lisp-engine)

(load "graphs.lisp.lisp")

(print-props (setq g (hypergraph '(a b c d) 
               '(((a b) 3.14) ((a b) 2.5) ((a b)) ((b c)) ((c d)) 
                ((a d))))))

; this makes g a graph with 4 vertices and 5 edges. There is a weighted
; edge from a to b as well as a simple edge (which has default weight 1).

(g-adjacency-matrix g)
; well, the adjacency matrix of the directed graph... see the comments in 
; the source: look for "underlying"

(g-components g)
(g-perfect-matchings g)
(print-props g)

(print-props (setq g2 (remove-edges g '(((0 1)) ((0 1) 3.14))))) 

; remove two edges the interface to remove-edges requires the indices of
; the vertices -- not their names -- at the moment. Note that you can 
; remove more than one edge at the time. (There specification needs to be 
; unambiguous, by the way)

(print-props g2)
; note that the perfect matchings were not computed

(print-props (setq g3 (remove-edges g2 '(((0 1))))))
; remove another edge

(print-props g3)

(g-adjacency-matrix g3)
(g-components g3)
(g-perfect-matchings g3)
(print-props g3)

; I also implemented the complete graph

(g-adjacency-matrix (complete-graph 3))

; and a certain 4-hypergraph which is related to the aztec diamond

(g-perfect-matchings (3aztec 3))