clean up all the current warnings
[cl-graph.git] / dev / api.lisp
1 (in-package #:cl-graph)
2
3
4 (defgeneric make-vertex-container (graph initial-size)
5   (:documentation "Make-vertex-container is called during graph creation and can be used to create specialized containers to hold graph vertexes."))
6
7
8 (defgeneric make-edge-container (graph initial-size)
9   (:documentation "Make-edge-container is called during graph creation and can be used to create specialized containers to hold graph edges."))
10
11 ;;; API
12
13 (defgeneric make-graph (graph-type &key &allow-other-keys)
14   (:documentation "Create a new graph of type `graph-type'. Graph type can be 
15 a symbol naming a sub-class of basic-graph or a list. If it is a list of symbols naming
16 different classes. If graph-type is a list, then a class which has all of the listed 
17 classes as superclasses will be found (or created). In either case, the new graph will
18 be created as if with a call to make-instance."))
19
20
21 (defgeneric make-edge-for-graph (graph vertex-1 vertex-2 
22                                        &key edge-type edge-class &allow-other-keys)
23   (:documentation "It should not usually necessary to call this in user code. Creates a new edge between vertex-1 and vertex-2 for the graph. If the edge-type and edge-class are not specified, they will be determined from the defaults of the graph."))
24
25
26 (defgeneric add-edge (graph edge &rest args &key force-new?)
27   (:documentation "Add-edge adds an existing edge to a graph. As add-edge-between-vertexes is generally more natural to use, this method is rarely called."))
28
29
30 (defgeneric add-edge-between-vertexes (graph value-or-vertex-1 value-or-vertex-2
31                                               &rest args &key if-duplicate-do
32                                               edge-type &allow-other-keys)
33   (:documentation "Adds an edge between two vertexes and returns it.  
34 If force-new? is true, 
35 the edge is added even if one already exists. 
36 If the vertexes are not 
37 found in the graph, they will be added \(unless :error-if-not-found? is
38 true\). The class of the edge can be specified using :edge-class or
39 :edge-type. If :edge-type is used, it can be either :directed or 
40 :undirected; the actual class of the edge will be determined by using
41 the edge-types of the graph. If neither :edge-type nor :edge-class is
42 specified, then a directed edge will be created.
43
44 If-duplicate-do is used when the 'same' edge is added more than once. It can be
45 either a function on one variable or :ignore or :force. If it is :ignore, then
46 the previously added edge is returned; if it is :force, then another edge is
47 added between the two vertexes; if it is a function, then this function will
48 be called with the previous edge."))
49
50
51 (defgeneric delete-edge (graph edge)
52   (:documentation "Delete the `edge' from the `graph' and returns it."))
53
54 (defgeneric delete-all-edges (graph)
55   (:documentation "Delete all edges from `graph'. Returns the graph.."))
56
57
58 (defgeneric delete-edge-between-vertexes (graph value-or-vertex-1
59                                                 value-or-vertex-2 &rest args)
60   (:documentation "Finds an edge in the graph between the two specified vertexes. If values (i.e., non-vertexes) are passed in, then the graph will be searched for matching vertexes."))
61
62
63 (defgeneric add-vertex (graph value-or-vertex &key if-duplicate-do &allow-other-keys)
64   (:documentation  "Adds a vertex to a graph. If called with a vertex, then this vertex is added. If called with a value, then a new vertex is created to hold the value. If-duplicate-do can be one of :ignore, :force, :replace, :replace-value or a function. The default is :ignore."))
65
66
67 (defgeneric delete-vertex (graph value-or-vertex)
68   (:documentation "Remove a vertex from a graph. The 'vertex-or-value' argument can be
69 a vertex of the graph or a 'value' that will find a vertex via a call to find-vertex. A
70 graph-vertex-not-found-error will be raised if the vertex is not found or is not part of
71 the graph."))
72
73
74 (defgeneric find-vertex (graph value &optional error-if-not-found?)
75   (:documentation "Search 'graph' for a vertex with element 'value'. The search is fast but inflexible because it uses an associative-container. If you need more flexibity, see search-for-vertex."))
76
77
78 (defgeneric search-for-vertex (graph value &key key test error-if-not-found?)
79   (:documentation "Search 'graph' for a vertex with element 'value'. The 'key' function is applied to each element before that element is compared with the value. The comparison is done using the function 'test'. If you don't need to use key or test, then consider using find-vertex instead."))
80
81
82 (defgeneric find-edge (graph edge &optional error-if-not-found?)
83   (:documentation "Search `graph` for an edge whose vertexes match `edge`. This means that `vertex-1` of the edge in the graph must match `vertex-1` of `edge` and so forth. Wil signal an error of type `graph-edge-not-found-error` unless `error-if-not-found?` is nil. [?? Unused. Remove?]"))
84
85
86 (defgeneric find-edge-between-vertexes (graph value-or-vertex-1 value-or-vertex-2
87                                               &key error-if-not-found?)
88   (:documentation "Searches `graph` for an edge that connects vertex-1 and vertex-2.  [?? Ignores error-if-not-found? Does directedness matter? need test]"))
89
90
91 (defgeneric source-vertex (edge)
92   (:documentation "Returns the source-vertex of a directed edge. Compare with `vertex-1`."))
93
94
95 (defgeneric target-vertex (edge)
96   (:documentation "Returns the target-vertex of a directed edge. Compare with `vertex-2`."))
97
98
99 (defgeneric iterate-edges (graph-or-vertex fn)
100   (:documentation "Calls `fn` on each edge of graph or vertex."))
101
102
103 (defgeneric iterate-source-edges (vertex fn)
104   (:documentation "In a directed graph, calls `fn` on each edge of a vertex that begins at vertex. In an undirected graph, this is equivalent to `iterate-edges`."))
105
106
107 (defgeneric iterate-target-edges (vertex fn)
108   (:documentation "In a directed graph, calls `fn` on each edge of a vertex that ends at vertex. In an undirected graph, this is equivalent to `iterate-edges`."))
109
110 (defgeneric has-children-p (vertex)
111   (:documentation "In a directed graph, returns true if vertex has any edges that point from vertex to some other vertex (cf. iterate-target-edges). In an undirected graph, `has-children-p` is testing only whether or not the vertex has any edges."))
112
113
114 (defgeneric has-parent-p (vertex)
115   (:documentation "In a directed graph, returns true if vertex has any edges that point from some other vertex to this vertex (cf. iterate-source-edges). In an undirected graph, `has-parent-p` is testing only whether or not the vertex has any edges."))
116
117
118 (defgeneric iterate-parents (vertex fn)
119   (:documentation "Calls fn on every vertex that is either connected to vertex by an undirected edge or is at the source end of a directed edge."))
120
121
122 (defgeneric iterate-neighbors (vertex fn)
123   (:documentation "Calls fn on every vertex adjecent to vertex See also iterate-children and iterate-parents."))
124
125
126 (defgeneric renumber-vertexes (graph)
127   (:documentation "Assign a number to each vertex in a graph in some unspecified order. [?? internal]"))
128
129
130 (defgeneric renumber-edges (graph)
131   (:documentation "Assign a number to each edge in a graph in some unspecified order. [?? internal]"))
132
133
134 (defgeneric generate-directed-free-tree (graph root)
135   (:documentation "Returns a version of graph which is a directed free tree
136 rooted at root."))
137
138
139 (defgeneric in-undirected-cycle-p (graph start-vertex &optional marked previous)
140   (:documentation "Return true if-and-only-if an undirected cycle in graph is reachable from start-vertex."))
141
142
143 (defgeneric undirected-edge-p (edge)
144   (:documentation "Returns true if-and-only-if edge is undirected"))
145
146
147 (defgeneric directed-edge-p (edge)
148   (:documentation "Returns true if-and-only-if edge is directed"))
149
150
151 (defgeneric tagged-edge-p (edge)
152   (:documentation "Returns true if-and-only-if edge's tag slot is t"))
153
154
155 (defgeneric untagged-edge-p (edge)
156   (:documentation "Returns true if-and-only-if edge's tage slot is nil"))
157           
158
159 (defgeneric adjacentp (graph vertex-1 vertex-2)
160   (:documentation "Return true if vertex-1 and vertex-2 are connected by an edge. [?? compare with vertices-share-edge-p and remove one or maybe call one directed-adjacentp]"))
161
162
163 (defgeneric make-filtered-graph (old-graph test-fn &key
164                                            graph-completion-method depth
165                                            new-graph)
166   (:documentation "Takes a GRAPH and a TEST-FN (a single argument function
167 returning NIL or non-NIL), and filters the graph nodes according to 
168 the test-fn (those that return non-NIL are accepted), returning 
169 a new graph with only nodes corresponding to those in the 
170 original graph that satisfy the test (the nodes in the new graph 
171 are new, but their values and name point to the same contents of 
172 the original graph).  There are four options for how the new 
173 graph is filled-out, depending on the following keywords passed 
174 to the optional GRAPH-COMPLETION-METHOD argument:
175
176 *  NIL (default)    
177
178      New graph has only nodes that correspond to those in
179        the original graph that pass the test.  NO LINKS are
180        reproduced.
181
182 *  :COMPLETE-LINKS  
183
184      New graph has only nodes that pass, but reproduces 
185        corresponding links between passing nodes in the
186        original graph.
187
188 *  :COMPLETE-CLOSURE-NODES-ONLY
189
190      New graph also includes nodes corresponding to the 
191        transitive closure(s) that include the passign nodes 
192        in the original graph.  NO LINKS are reproduced.
193
194 *  :COMPLETE-CLOSURE-WITH-LINKS
195
196      Same as above, except corresponding links are reproduced.
197
198 For both transitive closure options, an additional optional argument,
199 DEPTH, specifies how many links away from a source vertex to travel 
200 in gathering vertexes of the closure.  E.g., a depth of 1 returns the 
201 source vertex and the parents and children of that vertex (all vertexes
202 one link away from the source).  The default value is NIL, indicating
203 that all vertexes are to be included, no matter their depth.  This
204 value is ignored in non closure options."))
205
206
207 (defgeneric project-bipartite-graph  
208   (new-graph existing-graph vertex-class vertex-classifier)
209   (:documentation "Creates the unimodal bipartite projects of existing-graph with
210 vertexes for each vertex of existing graph whose `vertex-classifier` is eq to `vertex-class` and where an edge existing between two vertexes of the graph if and only if they are connected to a shared vertex in the existing-graph."))
211
212
213 (defgeneric assortativity-coefficient (mixing-matrix)
214   (:documentation "An assortative graph is one where vertexes of the same type are more likely to 
215 have edges between them. The \(discrete\) assortativity-coefficient measures how
216 assortative a graph is based on its mixing matrix. The definition we use is from 
217 Mixing Patterns in Networks by Mark Newman. See the citation 'newman200-mixing' in moab 
218 or the URL 'http://arxiv.org/abs/cond-mat/0209450'."))
219
220
221 (defgeneric graph->dot (graph output
222                        &key 
223                        graph-formatter
224                        vertex-key
225                        vertex-labeler
226                        vertex-formatter
227                        edge-labeler 
228                        edge-formatter)
229   (:documentation 
230    "Generates a description of `graph` in DOT file format. The formatting can be altered using `graph->dot-properties,` `vertex->dot,` and `edge->dot` as well as `edge-formatter,` `vertex-formatter,` `vertex-labeler,` and `edge-labeler`. These can be specified directly in the call to `graph->dot` or by creating subclasses of basic-graph, basic-vertex and basic-edge. 
231
232 The output can be a stream or pathname or one of the values `nil` or `t`. If output is `nil`, then graph->dot returns a string containing the DOT description. If it is `t`, then the DOT description is written to *standard-output*.
233
234 Here is an example;
235
236     (let ((g (make-container 'graph-container :default-edge-type :directed)))
237       (loop for (a b) in '((a b) (b c) (b d) (d e) (e f) (d f)) do
238             (add-edge-between-vertexes g a b))
239       (graph->dot g nil))
240
241     \"digraph G {
242     E []
243     C []
244     B []
245     A []
246     D []
247     F []
248     E->F []
249     B->C []
250     B->D []
251     A->B []
252     D->E []
253     D->F []
254     }\"
255
256 For more information about DOT file format, search the web for 'DOTTY' and 
257 'GRAPHVIZ'."))
258
259
260 (defgeneric graph->dot-properties (g stream)
261   (:documentation "Unless a different graph-formatter is specified, this method is called by graph->dot to output graph-properties onto a stream. The function can assume that the openning and closing brackets will be taken care of by the graph->dot."))
262
263
264 (defgeneric vertex->dot (vertex stream)
265   (:documentation "Unless a different vertex-formatter is specified with a keyword argument, this is used by graph->dot to output vertex formatting for `vertex` onto the `stream`. The function can assume that openning and closing square brackets and label have already been taken care of."))
266
267
268 (defgeneric edge->dot (edge stream)
269   (:documentation "Used by graph->dot to output edge formatting for `edge` onto the `stream`. The function can assume that openning and closing square brackets and label have already been taken care of."))
270
271
272 (defgeneric generate-gnm (generator graph n m &key)
273   (:documentation "Generate a 'classic' random graph G(n, m) with n vertexes and m edges."))
274
275
276 (defgeneric generate-gnp (generator graph n p &key)
277   (:documentation  "Generate the Erd\"os-R\'enyi random graph G\(n, p\). I.e., a graph with n vertexes where
278 each possible edge appears with probability p. This implementation is from Efficient Generation
279 of Large Random Networks \(see batagelj-generation-2005 in doab\)."))
280
281
282 (defgeneric generate-undirected-graph-via-assortativity-matrix 
283   (generator graph-class size edge-count kind-matrix assortativity-matrix
284              vertex-labeler &key)
285   (:documentation "This generates a random graph with 'size' vertexes. 
286 The vertexes can be in multiple different classes and the number of vertexes in each class is specified in the 'kind-matrix'. If the matrix has all fixnums, then it specifies the counts and these should add up to the size. If the kind-matrix contains non-fixnums then the values are treated as ratios.
287
288 The assortativity-matrix specifies the number of edges between vertexes of different kinds.
289
290 The vertex-labeler is a function of two parameters: the vertex kind and the index. It should return whatever the 'value' of the vertex ought to be."))
291
292
293 (defgeneric generate-undirected-graph-via-vertex-probabilities 
294   (generator graph-class size kind-matrix probability-matrix vertex-labeler)
295   (:documentation   "Generate an Erd\"os-R/'enyi like random graph having multiple vertex kinds. See the function
296 Gnp for the simple one vertex kind method.
297
298 Generator and graph-class specify the random number generator used and the class of the graph produced; Size
299 the number of vertexes. Kind matrix is a vector of ratios specifying the distribution of vertex kinds {0 ... \(1- k\)}.
300 The probability-matrix is a k x k matrix specifying the probability that two vertexes of the row-kind and the
301 column-kind will have an edge between them. vertex-labeler is a function of two arguments \(the kind and the vertex number\)
302 called to create values for vertexes. It will be called only once for each vertex created.
303
304 The clever sequential sampling technique in this implementation is from Efficient Generation
305 of Large Random Networks \(see batagelj-generation-2005 in moab\)."))
306
307
308 (defgeneric generate-scale-free-graph 
309   (generator graph size kind-matrix add-edge-count
310              other-vertex-kind-samplers vertex-labeler &key)
311   (:documentation "Generates a 'scale-free' graph using preferential attachment -- too damn slow.
312
313 Size is the number of vertexes; 
314 kind-matrix is as in generate-undirected-graph-via-assortativity-matrix, etc.;
315 add-edge-count is the number of edges to add for each vertex;
316 other-vertex-kind-samplers are confusing...; and
317 vertex-labeler is used to create vertex elements \(as in other generators\)."))
318
319
320 (defgeneric generate-assortative-graph-with-degree-distributions
321   (generator graph
322              edge-count assortativity-matrix
323              average-degrees
324              degree-distributions
325              vertex-labeler
326              &key)
327   (:documentation ""))
328
329
330 (defgeneric generate-simple-preferential-attachment-graph (generator graph size minimum-degree)
331   (:documentation "Generate a simple scale-free graph using the preferential attachment
332 mechanism of Barabasi and Albert. The implementation is from Efficient Generation
333 of Large Random Networks \(see batagelj-generation-2005 in moab\). Self-edges are possible."))
334
335
336 (defgeneric generate-preferential-attachment-graph 
337   (generator graph size kind-matrix minimum-degree 
338              assortativity-matrix 
339              &key)
340   (:documentation "Generate a Barabasi-Albert type scale free graph with multiple vertex kinds.
341
342 The idea behind this implementation is from Efficient Generation
343 of Large Random Networks \(see batagelj-generation-2005 in moab\)."))
344
345
346 ;;; more
347
348 (defgeneric make-vertex-for-graph (graph &key &allow-other-keys)
349   (:documentation "Creates a new vertex for graph `graph`. The keyword arguments include:
350
351 * vertex-class : specify the class of the vertex
352 * element      : specify the `element` of the vertex
353
354 and any other initialization arguments that make sense for the vertex class."))
355
356
357 (defgeneric tag-all-edges (thing)
358   (:documentation "Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?\]"))
359
360
361 (defgeneric untag-all-edges (thing)
362   (:documentation "Sets the `tag` of all the edges of `thing` to nil.  [?? why does this exist?\]"))
363
364
365 (defgeneric untag-edges (edges)
366   (:documentation "Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?\]"))
367
368
369 (defgeneric tag-edges (edges)
370   (:documentation "Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?\]"))
371
372
373 (defgeneric replace-vertex (graph old new)
374   (:documentation "Replace vertex `old` in graph `graph` with vertex `new`. The edge structure of the graph is maintained."))
375
376
377 (defgeneric add-edge-to-vertex (edge vertex)
378   (:documentation "Attaches the edge `edge` to the vertex `vertex`."))
379
380
381 (defgeneric source-edges (vertex &optional filter)
382   (:documentation "Returns a list of the source edges of `vertex`. I.e., 
383 the edges that begin at `vertex`."))
384
385
386 (defgeneric target-edges (vertex &optional filter)
387   (:documentation "Returns a list of the target edges of `vertex`. 
388 I.e., the edges that end at `vertex`."))
389
390
391 (defgeneric child-vertexes (vertex &optional filter)
392   (:documentation "Returns a list of the vertexes to which `vertex` 
393 is connected by an edge and for which `vertex` is the source vertex. 
394 If the connecting edge is undirected, then the vertex is always 
395 counted as a source. [?? Could be a defun]."))
396
397
398 (defgeneric parent-vertexes (vertex &optional filter)
399   (:documentation "Returns a list of the vertexes to which `vertex` is connected by an edge and for which `vertex` is the target vertex. If the connecting edge is undirected, then the vertex is always counted as a target. [?? Could be a defun]."))
400
401
402 (defgeneric neighbor-vertexes (vertex &optional filter)
403   (:documentation "Returns a list of the vertexes to which `vertex` is connected by an edge disregarding edge direction. In a directed graph, neighbor-vertexes is the union of parent-vertexes and child-vertexes. [?? Could be a defun]."))
404
405
406 (defgeneric number-of-neighbors (vertex)
407   (:documentation "Returns the number of neighbors of `vertex` (cf. `neighbor-vertexes`). [?? could be a defun]"))
408
409
410 (defgeneric in-cycle-p (graph start-vertex)
411   (:documentation "Returns true if `start-vertex` is in some cycle in `graph`. This uses child-vertexes to generate the vertexes adjacent to a vertex."))
412
413
414 (defgeneric iterate-vertexes (thing fn)
415   (:documentation "Calls `fn` on each of the vertexes of `thing`."))
416
417
418 (defgeneric edges (thing)
419   (:documentation "Returns a list of the edges of `thing`."))
420
421
422 (defgeneric vertex-count (graph)
423   (:documentation "Returns the number of vertexes in `graph`. [?? could be a defun]"))
424
425
426 (defgeneric vertexes (thing)
427   (:documentation "Returns a list of the vertexes of `thing`."))
428
429
430 (defgeneric source-edge-count (vertex)
431   (:documentation "Returns the number of source edges of vertex (cf. source-edges). [?? could be a defun]"))
432
433
434 (defgeneric target-edge-count (vertex)
435   (:documentation "Returns the number of target edges of vertex (cf. target-edges). [?? could be a defun]"))
436
437
438 (defgeneric graph-roots (graph)
439   (:documentation "Returns a list of the roots of graph. A root is defined as a vertex with no source edges \(i.e., all of the edges are out-going\). (cf. rootp) [?? could be a defun]"))
440
441
442 (defgeneric rootp (vertex)
443   (:documentation "Returns true if `vertex` is a root vertex \(i.e., it has no incoming \(source\) edges\)."))
444
445
446 (defgeneric find-vertex-if (thing predicate &key key)
447   (:documentation "Returns the first vertex in `thing` for which the `predicate` function returns non-nil. If the `key` is supplied, then it is applied to the vertex before the predicate is."))
448
449
450 (defgeneric find-edge-if (graph fn &key key)
451   (:documentation "Returns the first edge in `thing` for which the `predicate` function returns non-nil. If the `key` is supplied, then it is applied to the edge before the predicate is."))
452
453
454 (defgeneric find-edges-if (thing predicate)
455   (:documentation "Returns a list of edges in `thing` for which the `predicate` returns non-nil. [?? why no key function?]"))
456
457
458 (defgeneric find-vertexes-if (thing predicate)
459   (:documentation "Returns a list of vertexes in `thing` for which the `predicate` returns non-nil. [?? why no key function?]"))
460
461
462 (defgeneric force-undirected (graph)
463   (:documentation "Ensures that the graph is undirected (possibly by calling change-class on the edges)."))
464
465
466 (defgeneric traverse-elements (thing style fn)
467   (:documentation "WIP"))
468
469 (defgeneric traverse-elements-helper (thing style marker fn)
470   (:documentation "WIP"))
471
472 (defgeneric any-undirected-cycle-p (graph)
473   (:documentation "Returns true if there are any undirected cycles in `graph`."))
474
475 (defgeneric edge-count (vertex)
476   (:documentation "Returns the number of edges attached to `vertex`. Compare with the more flexible `vertex-degree`."))
477
478 (defgeneric topological-sort (graph)
479   (:documentation "Returns a list of vertexes sorted by the depth from the roots of the graph. See also assign-level and graph-roots."))
480
481 (defgeneric assign-level (vertex level)
482   (:documentation "Sets the depth of `vertex` to level and then recursively sets the depth of all of the children of `vertex` to \(1+ level\)."))
483
484 (defgeneric depth (graph)
485   (:documentation "Returns the maximum depth of the vertexes in graph assuming that the roots are of depth 0 and that each edge distance from the roots increments the depth by one."))
486
487 (defgeneric make-vertex-edges-container (vertex container-class &rest args)
488   (:documentation "Called during the initialization of a vertex to create the create the container used to store the edges incident to the vertex. The initarg :vertex-edges-container-class can be used to alter the default container class."))
489
490 (defgeneric other-vertex (edge value-or-vertex)
491   (:documentation "Assuming that the value-or-vertex corresponds to one of the vertexes for `edge`, this method returns the other vertex of `edge`. If the value-or-vertex is not part of edge, then an error is signaled. [?? Should create a new condition for this]"))
492
493 (defgeneric find-edge-between-vertexes-if 
494   (graph value-or-vertex-1 value-or-vertex-2 fn &key error-if-not-found?)
495   (:documentation "Finds and returns an edge between value-or-vertex-1 and value-or-vertex-2 if one exists. Unless error-if-not-found? is nil, then a error will be signaled. [?? Error not signal, need test.]"))
496
497 (defgeneric vertices-share-edge-p (vertex-1 vertex-2)
498   (:documentation "Return true if vertex-1 and vertex-2 are connected by an edge. [?? Compare adjacentp]"))
499
500 (defgeneric graph-edge-mixture-matrix (graph vertex-classifier &key edge-weight)
501   (:documentation "Return the `mixing-matrix` of graph based on the classifier and the edge-weight function. The mixing matrix is a matrix whose runs and columns represent each class of vertex in the graph. The entries of the matrix show the total number of edges between vertexes of the two kinds. [?? Edge-weight is not used; also compare with graph-mixture-matrix.]"))
502
503 (defgeneric graph-mixing-matrix (graph vertex-classifier &key edge-weight)
504   (:documentation "Return the `mixing-matrix` of graph based on the classifier and the edge-weight function. The mixing matrix is a matrix whose runs and columns represent each class of vertex in the graph. The entries of the matrix show the total number of edges between vertexes of the two kinds. [?? Edge-weight is not used; also compare with graph-edge-mixture-matrix.]"))
505
506 (defgeneric connected-components (graph)
507   (:documentation "Returns a union-find-container representing the connected-components of `graph`."))
508
509 (defgeneric connected-component-count (graph)
510   (:documentation "Returns the number of connected-components of graph."))
511
512 (defgeneric find-connected-components (graph)
513   (:documentation "Returns a list of sub-graphs of `graph` where each sub-graph is a different connected component of graph. Compare with connected-components and connected-component-count."))
514
515 (defgeneric initialize-vertex-data (graph)
516   (:documentation ""))
517
518 (defgeneric breadth-first-visitor (graph source fn)
519   (:documentation ""))
520
521 (defgeneric breadth-first-search-graph (graph source)
522   (:documentation ""))
523
524 (defgeneric mst-find-set (vertex)
525   (:documentation ""))
526
527 (defgeneric mst-make-set (vertex)
528   (:documentation ""))
529
530 (defgeneric mst-tree-union (v1 v2)
531   (:documentation ""))
532
533 (defgeneric mst-link (v1 v2)
534   (:documentation ""))
535
536 (defgeneric add-edges-to-graph (graph edges &key if-duplicate-do)
537   (:documentation ""))
538
539 (defgeneric make-graph-from-vertexes (vertex-list)
540   (:documentation "Create a new graph given a list of vertexes \(which are assumed to be from the same graph\). The new graph contains all of the vertexes in the list and all of the edges between any vertexes on the list."))
541
542 (defgeneric edge-lessp-by-weight (edge-1 edge-2)
543   (:documentation "Returns true if the weight of edge-1 is strictly less than the weight of edge-2."))
544
545 (defgeneric minimum-spanning-tree (graph &key edge-sorter)
546   (:documentation "Returns a minimum spanning tree of graph if one exists and nil otherwise."))
547
548 (defgeneric connected-graph-p (graph &key edge-sorter)
549   (:documentation "Returns true if graph is a connected graph and nil otherwise."))
550
551 (defgeneric edge-lessp-by-direction (edge-1 edge-2)
552   (:documentation "Returns true if and only if edge-1 is undirected and edge-2 is directed."))
553
554 (defgeneric out-edge-for-vertex-p (edge vertex)
555   (:documentation "Returns true if the edge is connected to vertex and is either an undirected edge or a directed edge for which vertex is the source vertex of the edge."))
556
557 (defgeneric dfs (graph root fn &key out-edge-sorter)
558   (:documentation ""))
559
560 (defgeneric dfs-visit (graph u fn sorter)
561   (:documentation ""))
562
563 (defgeneric dfs-tree-edge-p (edge)
564   (:documentation ""))
565
566 (defgeneric dfs-back-edge-p (edge)
567   (:documentation ""))
568
569 (defgeneric dfs-forward-edge-p (edge)
570   (:documentation ""))
571
572 (defgeneric dfs-cross-edge-p (edge)
573   (:documentation ""))
574
575 (defgeneric dfs-edge-type (edge)
576   (:documentation ""))
577
578 (defgeneric map-over-all-combinations-of-k-vertexes (graph k fn)
579   (:documentation ""))
580
581 (defgeneric map-over-all-combinations-of-k-edges (vertex k fn)
582   (:documentation ""))
583
584 (defgeneric complete-links (new-graph old-graph)
585   (:documentation "Add edges between vertexes in the new-graph for which the matching  vertexes in the old-graph have edges. The vertex matching is done using `find-vertex`."))
586
587 (defgeneric subgraph-containing (graph vertex &key depth new-graph)
588   (:documentation "Returns a new graph that is a subset of `graph` 
589 that contains `vertex` and all of the other vertexes that can be 
590 reached from vertex by paths of less than or equal of length `depth`. 
591 If depth is not specified, then the entire sub-graph reachable 
592 from vertex will be returned. [?? Edge weights are always assumed
593 to be one.]"))
594
595
596 (defgeneric weight (edge)
597   (:documentation "Returns the weight of an edge. This defaults
598 to 1.0 and can only be altered if the edge is a sub-class of 
599 `weighted-edge-mixin`."))
600
601 (defgeneric (setf dot-attribute-value) (value attribute thing)
602   )
603
604 (defgeneric dot-attribute-value (attribute thing)
605   )
606
607 (defgeneric graph->dot-external (graph file-name &key type)
608   )
609
610 (defgeneric ensure-valid-dot-attribute (key object)
611   )
612
613 (defgeneric write-name-for-dot (attribute stream)
614   )
615
616