login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

First we define the general category of graphs.

)abbrev category GRAPHS GraphCategory
GraphCategory(nodes:Type, edges:Type): Category == with
   Compiling FriCAS source code from file 
      using old system compiler.
   GRAPHS abbreviates category GraphCategory 
   initializing NRLIB GRAPHS for GraphCategory 
   compiling into NRLIB GRAPHS 
;;; *** |GraphCategory| REDEFINED Time: 0 SEC.
finalizing NRLIB GRAPHS Processing GraphCategory for Browser database: --->-->GraphCategory(constructor): Not documented!!!! --->-->GraphCategory((source (nodes edges))): Not documented!!!! --->-->GraphCategory((target (nodes edges))): Not documented!!!! --->-->GraphCategory(): Missing Description ; compiling file "/var/aw/var/LatexWiki/GRAPHS.NRLIB/GRAPHS.lsp" (written 04 APR 2022 05:15:01 PM):
; /var/aw/var/LatexWiki/GRAPHS.NRLIB/GRAPHS.fasl written ; compilation finished in 0:00:00.004 ------------------------------------------------------------------------ GraphCategory is now explicitly exposed in frame initial GraphCategory will be automatically loaded when needed from /var/aw/var/LatexWiki/GRAPHS.NRLIB/GRAPHS

Now we define finite graphs as follows:

)abbrev domain FGRAPHS FiniteGraph
FiniteGraph(nodes: BasicType): exports == implementation where edges ==> Record(source:nodes,target:nodes) exports == GraphCategory(nodes,edges) with new: () -> % addNode: (%,List nodes) -> List nodes addNode: (%,nodes) -> List nodes addEdge: (%,nodes,nodes) -> edges edgeList: (%) -> List edges nodeList: (%) -> List nodes
implementation == add Rep == Record(node: List nodes, edge: List edges)
new:% == n:List(nodes):=[] e:List(edges):=[] [n,e]$Rep pretend %
addNode(g:%,n:List nodes):List nodes == G:Rep:=g pretend Rep; if #G.node=0 then G.node:=n else concat!(G.node,n) n
addNode(g:%,n:nodes):List nodes == addNode(g,[n])
addEdge(g:%,src:nodes,tar:nodes):edges == G:Rep:=g pretend Rep; if #G.edge=0 then G.edge:=[[src,tar]$edges] else concat!(G.edge,[[src,tar]$edges]) [src,tar]$edges
edgeList(g:%):List edges == G:Rep:=g pretend Rep; G.edge nodeList(g:%):List nodes == G:Rep:=g pretend Rep; G.node
source(ed:edges):nodes == ed.source target(ed:edges):nodes == ed.target
   Compiling FriCAS source code from file 
      using old system compiler.
   FGRAPHS abbreviates domain FiniteGraph 
   initializing NRLIB FGRAPHS for FiniteGraph 
   compiling into NRLIB FGRAPHS 
************* USER ERROR **********
available signatures for Rep: 
NEED Rep: () -> ?
****** comp fails at level 1 with expression: ******
((DEF (|Rep|) (NIL) (NIL)
  (|Record| (|:| |node| (|List| |nodes|))
            (|:| |edge|
                  (|Record| (|:| |source| |nodes|) (|:| |target| |nodes|)))))))
****** level 1  ******
$x:= (DEF (Rep) (NIL) (NIL) (Record (: node (List nodes)) (: edge (List (Record (: source nodes) (: target nodes))))))
$m:= $EmptyMode
((((~= #) (= #) (|$DomainsInScope| # # #) (|target| #) ...)))
>> Apparent user error: unspecified error

Example 1: create a simple finite graph:

Type: Void
There are 1 exposed and 8 unexposed library operations named new having 0 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op new to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a no-argument definition or library operation named new .

  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: