Axiom currently lacks an implementation of the mathematical concept of graph in the sense of Graph Theory See also: Graph_(mathematics) The concept of a graph is fundamental in many areas of mathematics and is the starting point for category theory. Graphs are also very important data structures in many algorithms in computer science. Our goal here therefore is to develop the concept of graph in Axiom in the most general way possible. Axiom Version axiom )version Spad VersionSee SandBox Category of Graphs in SPAD Aldor Verison First we define the general category of graphs. Note that
we use a [lowercase] short name aldor #include "axiom.as"
define GraphCategory(nodes:Type, edges:Type): Category == with {
source:edges->nodes;
target:edges->nodes;
}
aldor Compiling FriCAS source code from file
/var/zope2/var/LatexWiki/graphcat.as using AXIOM-XL compiler and
options
-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
Compiling Lisp source code from file ./graphcat.lsp
Issuing )library command for graphcat
Reading /var/zope2/var/LatexWiki/graphcat.asy
GraphCategory is now explicitly exposed in frame initial
GraphCategory will be automatically loaded when needed from
/var/zope2/var/LatexWiki/graphcatNow we define finite graphs as follows: aldor #include "axiom.as"; #library graphcat "graphcat.ao"; import from graphcat; inline from graphcat; edges ==> Record(source:nodes,target:nodes); aldor Compiling FriCAS source code from file
/var/zope2/var/LatexWiki/fgraph.as using AXIOM-XL compiler and
options
-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
Compiling Lisp source code from file ./fgraph.lsp
Issuing )library command for fgraph
Reading /var/zope2/var/LatexWiki/fgraph.asy
FiniteGraph is now explicitly exposed in frame initial
FiniteGraph will be automatically loaded when needed from
/var/zope2/var/LatexWiki/fgraphMake sure that FiniteGraph? and GraphCategory? are known to Axiom:
\begin{axiom}
)lisp (si::allocate-contiguous-pages 3000 t)
)library graphcat fgraph
\end{axiom}
If we use UPPERCASE in the name of the Aldor library the example below results in:
>> System error:
AxiomXL file "GRAPHCAT" is missing!
But if we use lowercase, it (sometimes) works! However quite often when we refresh this page even without editing it, we get now the error:
>> System error:
Contiguous blocks exhausted.
Currently, 1354 pages are allocated.
Use ALLOCATE-CONTIGUOUS-PAGES to expand the space.
Example 1: create a simple finite graph: axiom g:FiniteGraph(INT) Type: Void
axiom g:=new()$FiniteGraph(INT) Type: FiniteGraph? Integer
axiom addNode(g,1)
Type: PositiveInteger
axiom addNode(g,2)
Type: PositiveInteger
axiom e:=addEdge(g,1,2)
Type: Record(source: Integer,target: Integer)
axiom source(e) Why do I need to specify axiom source(e)$FiniteGraph(INT)
Type: Integer
But without the category definition this seems to be ok? aldor #include "axiom.as" aldor Compiling FriCAS source code from file
/var/zope2/var/LatexWiki/8126689142996008028-25px006.as using
AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
Compiling Lisp source code from file
./8126689142996008028-25px006.lsp
Issuing )library command for 8126689142996008028-25px006
Reading /var/zope2/var/LatexWiki/8126689142996008028-25px006.asy
FiniteGraph is already explicitly exposed in frame initial
FiniteGraph will be automatically loaded when needed from
/var/zope2/var/LatexWiki/8126689142996008028-25px006Example 2: create a simple finite graph: axiom g:FiniteGraph(INT) Type: Void
axiom g:=new()$FiniteGraph(INT) Type: FiniteGraph? Integer
axiom addNode(g,1)
Type: PositiveInteger
axiom addNode(g,2)
Type: PositiveInteger
axiom e:=addEdge(g,1,2)
Type: Record(source: Integer,target: Integer)
axiom source(e)
Type: PositiveInteger
axiom )lisp (room) Here is another Aldor version SandBox Category of Graphs 2 |