changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/obj/graph.lisp

changeset 104: 6e5caf0c68a1
child: 524dfb768c7a
author: ellis <ellis@rwest.io>
date: Sat, 16 Dec 2023 21:28:03 -0500
permissions: -rw-r--r--
description: obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
104
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
1
 ;;; lib/obj/graph.lisp --- Graphs
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
2
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
3
 ;;
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
4
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
5
 ;;; Code:
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
6
 (in-package :obj/graph)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
7
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
8
 ;;; Vertex
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
9
 (defclass vertex (node id)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
10
   ()
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
11
   (:documentation "generic vertex mixin. The difference between this class and NODE is
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
12
 that a vertex always carries an ID slot."))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
13
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
14
 ;;; Edge
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
15
 (defclass edge (node id)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
16
   ()
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
17
   (:documentation "generic edge mixin. Compatible with the NODE and ID protocols."))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
18
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
19
 (defclass directed-edge (edge))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
20
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
21
 (defclass undirected-edge (edge))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
22
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
23
 (defclass weighted-edge (edge)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
24
   ((weight :initform 1d0 :initarg :weight :accessor weight-of)))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
25
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
26
 (defgeneric edge-weight (edge &key &allow-other-keys)
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
27
   (:method ((edge t) &key &allow-other-keys) (values 1.0)))
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
28
 
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
29
 ;;; Graph
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
30
 (defclass graph ()
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
31
   ()
6e5caf0c68a1 obj tree, id, hash, seq, graph.. added cli/progress and init cli/repl
ellis <ellis@rwest.io>
parents:
diff changeset
32
   (:documentation "generic graph mixin."))