Common Lisp Package: CL-GRAPH

CL-Graph is a Common Lisp library for manipulating graphs and running graph algorithms.

README:

FUNCTION

Public

GET-TRANSITIVE-CLOSURE (VERTEX-LIST &OPTIONAL (DEPTH NIL))

Given a list of vertices, returns a combined list of all of the nodes in the transitive closure(s) of each of the vertices in the list (without duplicates). Optional DEPTH limits the depth (in _both_ the child and parent directions) to which the closure is gathered; default nil gathers the entire closure(s).

MAP-PATHS (GRAPH START-VERTEX LENGTH FN &KEY (FILTER (CONSTANTLY T)))

Apply fn to each path that starts at start-vertex and is of exactly length length

MAP-SHORTEST-PATHS (GRAPH START-VERTEX DEPTH FN &KEY (FILTER (CONSTANTLY T)))

Apply fn to each shortest path starting at `start-vertex` of depth `depth`. The `filter` predicate is used to remove vertexes from consideration.

Undocumented

Private

COPY-VERTEX-DATUM (SEQUENCE)

Return a copy of SEQUENCE which is EQUAL to SEQUENCE but not EQ.

GET-NODELIST-RELATIVES (NODE-LIST)

Collects set of unique relatives of nodes in node-list.

GRAPH-SEARCH-FOR-CL-GRAPH (STATES GOAL-P SUCCESSORS COMBINER &KEY (STATE= #'EQL) OLD-STATES (NEW-STATE-FN (ERROR argument required)))

Find a state that satisfies goal-p. Start with states, and search according to successors and combiner. Don't try the same state twice.

REMOVE-LIST (ORIGINAL TARGET)

Removes all elements in original from target.

Undocumented

APPEND-UNIQUE (LIST1 LIST2)

FORMAT-DOT-ATTRIBUTES (OBJECT DOT-ATTRIBUTES STREAM)

MAKE-VERTEX-DATUM (&KEY ((COLOR DUM1) NIL) ((DEPTH DUM2) MOST-POSITIVE-FIXNUM) ((PARENT DUM3) NIL))

NEIGHBORS-TO-CHILDREN (NEW-GRAPH ROOT &OPTIONAL VISITED-LIST)

NODE-COLOR (STRUCTURE)

SETFNODE-COLOR (NEW-VALUE STRUCTURE)

NODE-DEPTH (STRUCTURE)

SETFNODE-DEPTH (NEW-VALUE STRUCTURE)

NODE-PARENT (STRUCTURE)

SETFNODE-PARENT (NEW-VALUE STRUCTURE)

TEXTIFY (OBJECT)

MACRO

Public

WITH-CHANGING-VERTEX ((VERTEX) &BODY BODY)

This is used to maintain consistency when changing the value of vertex elements while iterating over the vertexes...

Private

Undocumented

DEFPIXEL-INCH-ACCESSORS (NAME ATTR TYPE)

GENERIC-FUNCTION

Public

ADD-EDGE (GRAPH EDGE &REST ARGS &KEY FORCE-NEW?)

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.

ADD-EDGE-BETWEEN-VERTEXES (GRAPH VALUE-OR-VERTEX-1 VALUE-OR-VERTEX-2 &REST ARGS &KEY IF-DUPLICATE-DO EDGE-TYPE (IF-DUPLICATE-DO IGNORE) (VALUE NIL) &ALLOW-OTHER-KEYS)

Adds an edge between two vertexes and returns it. If force-new? is true, the edge is added even if one already exists. If the vertexes are not found in the graph, they will be added (unless :error-if-not-found? is true). The class of the edge can be specified using :edge-class or :edge-type. If :edge-type is used, it can be either :directed or :undirected; the actual class of the edge will be determined by using the edge-types of the graph. If neither :edge-type nor :edge-class is specified, then a directed edge will be created. If-duplicate-do is used when the 'same' edge is added more than once. It can be either a function on one variable or :ignore or :force. If it is :ignore, then the previously added edge is returned; if it is :force, then another edge is added between the two vertexes; if it is a function, then this function will be called with the previous edge.

ADD-VERTEX (GRAPH VALUE-OR-VERTEX &KEY IF-DUPLICATE-DO &ALLOW-OTHER-KEYS)

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, :error, or a function. The default is :ignore.

ADJACENTP (GRAPH VERTEX-1 VERTEX-2)

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]

ANY-UNDIRECTED-CYCLE-P (GRAPH)

Returns true if there are any undirected cycles in `graph`.

ASSORTATIVITY-COEFFICIENT (MIXING-MATRIX)

An assortative graph is one where vertexes of the same type are more likely to have edges between them. The (discrete) assortativity-coefficient measures how assortative a graph is based on its mixing matrix. The definition we use is from Mixing Patterns in Networks by Mark Newman. See the citation 'newman200-mixing' in moab or the URL 'http://arxiv.org/abs/cond-mat/0209450'.

CHILD-VERTEXES (VERTEX &OPTIONAL FILTER)

Returns a list of the vertexes to which `vertex` is connected by an edge and for which `vertex` is the source vertex. If the connecting edge is undirected, then the vertex is always counted as a source. [?? Could be a defun].

CONNECTED-COMPONENT-COUNT (GRAPH)

Returns the number of connected-components of graph.

CONNECTED-COMPONENTS (GRAPH)

Returns a union-find-container representing the connected-components of `graph`.

CONNECTED-GRAPH-P (GRAPH &KEY EDGE-SORTER (EDGE-SORTER 'EDGE-LESSP-BY-WEIGHT))

Returns true if graph is a connected graph and nil otherwise.

DELETE-ALL-EDGES (GRAPH)

Delete all edges from `graph'. Returns the graph..

DELETE-EDGE (GRAPH EDGE)

Delete the `edge' from the `graph' and returns it.

DELETE-EDGE-BETWEEN-VERTEXES (GRAPH VALUE-OR-VERTEX-1 VALUE-OR-VERTEX-2 &REST ARGS)

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.

DELETE-VERTEX (GRAPH VALUE-OR-VERTEX)

Remove a vertex from a graph. The 'vertex-or-value' argument can be a vertex of the graph or a 'value' that will find a vertex via a call to find-vertex. A graph-vertex-not-found-error will be raised if the vertex is not found or is not part of the graph.

DEPTH (GRAPH)

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.

DFS (GRAPH ROOT FN &KEY OUT-EDGE-SORTER (OUT-EDGE-SORTER #'EDGE-LESSP-BY-DIRECTION))

DFS-BACK-EDGE-P (EDGE)

DFS-EDGE-TYPE (EDGE)

DFS-TREE-EDGE-P (EDGE)

DIRECTED-EDGE-P (EDGE)

Returns true if-and-only-if edge is directed

EDGE->DOT (EDGE STREAM)

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.

EDGE-COUNT (VERTEX)

Returns the number of edges attached to `vertex`. Compare with the more flexible `vertex-degree`.

EDGE-LESSP-BY-DIRECTION (EDGE-1 EDGE-2)

Returns true if and only if edge-1 is undirected and edge-2 is directed.

EDGE-LESSP-BY-WEIGHT (EDGE-1 EDGE-2)

Returns true if the weight of edge-1 is strictly less than the weight of edge-2.

EDGES (THING)

Returns a list of the edges of `thing`.

FIND-CONNECTED-COMPONENTS (GRAPH)

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.

FIND-EDGE (GRAPH EDGE &OPTIONAL ERROR-IF-NOT-FOUND?)

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?]

FIND-EDGE-BETWEEN-VERTEXES (GRAPH VALUE-OR-VERTEX-1 VALUE-OR-VERTEX-2 &KEY ERROR-IF-NOT-FOUND? (ERROR-IF-NOT-FOUND? T))

Searches `graph` for an edge that connects vertex-1 and vertex-2. [?? Ignores error-if-not-found? Does directedness matter? need test]

FIND-EDGE-BETWEEN-VERTEXES-IF (GRAPH VALUE-OR-VERTEX-1 VALUE-OR-VERTEX-2 FN &KEY ERROR-IF-NOT-FOUND?)

Finds and returns an edge between value-or-vertex-1 and value-or-vertex-2 which returns true (as a generalized boolean) when evaluated by `fn`. Unless error-if-not-found? is nil, then a error will be signaled. [?? IS error really signaled? need a test.]

FIND-EDGE-IF (GRAPH FN &KEY KEY)

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.

FIND-EDGES-IF (THING PREDICATE)

Returns a list of edges in `thing` for which the `predicate` returns non-nil. [?? why no key function?]

FIND-VERTEX (GRAPH VALUE &OPTIONAL ERROR-IF-NOT-FOUND?)

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.

FIND-VERTEX-IF (THING PREDICATE &KEY KEY)

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.

FIND-VERTEXES-IF (THING PREDICATE)

Returns a list of vertexes in `thing` for which the `predicate` returns non-nil. [?? why no key function?]

FORCE-UNDIRECTED (GRAPH)

Ensures that the graph is undirected (possibly by calling change-class on the edges).

GENERATE-DIRECTED-FREE-TREE (GRAPH ROOT)

Returns a version of graph which is a directed free tree rooted at root.

GRAPH->DOT (GRAPH OUTPUT &KEY GRAPH-FORMATTER VERTEX-KEY VERTEX-LABELER VERTEX-FORMATTER EDGE-LABELER EDGE-FORMATTER (GRAPH-FORMATTER 'GRAPH->DOT-PROPERTIES) (VERTEX-KEY 'VERTEX-ID) (VERTEX-LABELER NIL) (VERTEX-FORMATTER 'VERTEX->DOT) (EDGE-LABELER 'PRINC) (EDGE-FORMATTER 'EDGE->DOT) &ALLOW-OTHER-KEYS)

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. 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\*. Here is an example; (let ((g (make-container 'graph-container :default-edge-type :directed))) (loop for (a b) in '((a b) (b c) (b d) (d e) (e f) (d f)) do (add-edge-between-vertexes g a b)) (graph->dot g nil)) "digraph G { E [] C [] B [] A [] D [] F [] E->F [] B->C [] B->D [] A->B [] D->E [] D->F [] }" For more information about DOT file format, search the web for 'DOTTY' and 'GRAPHVIZ'.

GRAPH->DOT-PROPERTIES (G STREAM)

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.

GRAPH-EDGE-MIXTURE-MATRIX (GRAPH VERTEX-CLASSIFIER &KEY EDGE-WEIGHT)

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.]

GRAPH-MIXING-MATRIX (GRAPH VERTEX-CLASSIFIER &KEY EDGE-WEIGHT)

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.]

GRAPH-ROOTS (GRAPH)

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]

HAS-CHILDREN-P (VERTEX)

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.

HAS-PARENT-P (VERTEX)

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.

IN-CYCLE-P (GRAPH START-VERTEX)

Returns true if `start-vertex` is in some cycle in `graph`. This uses child-vertexes to generate the vertexes adjacent to a vertex.

IN-UNDIRECTED-CYCLE-P (GRAPH START-VERTEX &OPTIONAL MARKED PREVIOUS)

Return true if-and-only-if an undirected cycle in graph is reachable from start-vertex.

ITERATE-CHILDREN (NODE FN)

Calls `fn` on every child of `node`.

ITERATE-CONTAINER (ITERATOR FN)

ITERATE-EDGES (GRAPH-OR-VERTEX FN)

Calls `fn` on each edge of graph or vertex.

ITERATE-NEIGHBORS (VERTEX FN)

Calls fn on every vertex adjecent to vertex See also iterate-children and iterate-parents.

ITERATE-PARENTS (VERTEX FN)

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.

ITERATE-SOURCE-EDGES (VERTEX FN)

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`.

ITERATE-TARGET-EDGES (VERTEX FN)

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`.

ITERATE-VERTEXES (THING FN)

Calls `fn` on each of the vertexes of `thing`.

MAKE-FILTERED-GRAPH (OLD-GRAPH TEST-FN &KEY GRAPH-COMPLETION-METHOD DEPTH NEW-GRAPH)

Takes a GRAPH and a TEST-FN (a single argument function returning NIL or non-NIL), and filters the graph nodes according to the test-fn (those that return non-NIL are accepted), returning a new graph with only nodes corresponding to those in the original graph that satisfy the test (the nodes in the new graph are new, but their values and name point to the same contents of the original graph). There are four options for how the new graph is filled-out, depending on the following keywords passed to the optional GRAPH-COMPLETION-METHOD argument: * NIL (default) New graph has only nodes that correspond to those in the original graph that pass the test. NO LINKS are reproduced. * :COMPLETE-LINKS New graph has only nodes that pass, but reproduces corresponding links between passing nodes in the original graph. * :COMPLETE-CLOSURE-NODES-ONLY New graph also includes nodes corresponding to the transitive closure(s) that include the passign nodes in the original graph. NO LINKS are reproduced. * :COMPLETE-CLOSURE-WITH-LINKS Same as above, except corresponding links are reproduced. For both transitive closure options, an additional optional argument, DEPTH, specifies how many links away from a source vertex to travel in gathering vertexes of the closure. E.g., a depth of 1 returns the source vertex and the parents and children of that vertex (all vertexes one link away from the source). The default value is NIL, indicating that all vertexes are to be included, no matter their depth. This value is ignored in non closure options.

MAKE-GRAPH (GRAPH-TYPE &ALLOW-OTHER-KEYS)

Create a new graph of type `graph-type'. Graph type can be a symbol naming a sub-class of basic-graph or a list. If it is a list of symbols naming different classes. If graph-type is a list, then a class which has all of the listed classes as superclasses will be found (or created). In either case, the new graph will be created as if with a call to make-instance.

MAKE-GRAPH-FROM-VERTEXES (VERTEX-LIST)

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.

MAKE-VERTEX-EDGES-CONTAINER (VERTEX CONTAINER-CLASS &REST ARGS)

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.

MAKE-VERTEX-FOR-GRAPH (GRAPH &KEY (VERTEX-CLASS (VERTEX-CLASS GRAPH)) &ALLOW-OTHER-KEYS)

Creates a new vertex for graph `graph`. The keyword arguments include: * vertex-class : specify the class of the vertex * element : specify the `element` of the vertex and any other initialization arguments that make sense for the vertex class.

MINIMUM-SPANNING-TREE (GRAPH &KEY EDGE-SORTER (EDGE-SORTER #'EDGE-LESSP-BY-WEIGHT))

Returns a minimum spanning tree of graph if one exists and nil otherwise.

NEIGHBOR-VERTEXES (VERTEX &OPTIONAL FILTER)

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].

NUMBER-OF-NEIGHBORS (VERTEX)

Returns the number of neighbors of `vertex` (cf. `neighbor-vertexes`). [?? could be a defun]

OTHER-VERTEX (EDGE VALUE-OR-VERTEX)

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]

OUT-EDGE-FOR-VERTEX-P (EDGE VERTEX)

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.

PARENT-VERTEXES (VERTEX &OPTIONAL FILTER)

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].

PROJECT-BIPARTITE-GRAPH (NEW-GRAPH EXISTING-GRAPH VERTEX-CLASS VERTEX-CLASSIFIER)

Creates the unimodal bipartite projects of existing-graph with 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.

RENUMBER-EDGES (GRAPH)

Assign a number to each edge in a graph in some unspecified order. [?? internal]

RENUMBER-VERTEXES (GRAPH)

Assign a number to each vertex in a graph in some unspecified order. [?? internal]

REPLACE-VERTEX (GRAPH OLD NEW)

Replace vertex `old` in graph `graph` with vertex `new`. The edge structure of the graph is maintained.

ROOTED-DFS (GRAPH ROOT FN &KEY OUT-EDGE-SORTER (OUT-EDGE-SORTER #'EDGE-LESSP-BY-DIRECTION))

A variant of DFS that does not visit nodes that are unreachable from the ROOT.

ROOTP (VERTEX)

Returns true if `vertex` is a root vertex (i.e., it has no incoming (source) edges).

SEARCH-FOR-VERTEX (GRAPH VALUE &KEY KEY TEST ERROR-IF-NOT-FOUND? (ERROR-IF-NOT-FOUND? T) (TEST 'EQUAL) (KEY (VERTEX-KEY GRAPH)))

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.

SOURCE-EDGE-COUNT (VERTEX)

Returns the number of source edges of vertex (cf. source-edges). [?? could be a defun]

SOURCE-EDGES (VERTEX &OPTIONAL FILTER)

Returns a list of the source edges of `vertex`. I.e., the edges that begin at `vertex`.

SOURCE-VERTEX (EDGE)

Returns the source-vertex of a directed edge. Compare with `vertex-1`.

SUBGRAPH-CONTAINING (GRAPH VERTEX &KEY DEPTH NEW-GRAPH)

Returns a new graph that is a subset of `graph` that contains `vertex` and all of the other vertexes that can be reached from vertex by paths of less than or equal of length `depth`. If depth is not specified, then the entire sub-graph reachable from vertex will be returned. [?? Edge weights are always assumed to be one.]

TAG-ALL-EDGES (THING)

Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?]

TAGGED-EDGE-P (EDGE)

Returns true if-and-only-if edge's tag slot is t

TARGET-EDGE-COUNT (VERTEX)

Returns the number of target edges of vertex (cf. target-edges). [?? could be a defun]

TARGET-EDGES (VERTEX &OPTIONAL FILTER)

Returns a list of the target edges of `vertex`. I.e., the edges that end at `vertex`.

TARGET-VERTEX (EDGE)

Returns the target-vertex of a directed edge. Compare with `vertex-2`.

TOPOLOGICAL-SORT (GRAPH)

Returns a list of vertexes sorted by the depth from the roots of the graph. See also assign-level and graph-roots.

UNDIRECTED-EDGE-P (EDGE)

Returns true if-and-only-if edge is undirected

UNTAG-ALL-EDGES (THING)

Sets the `tag` of all the edges of `thing` to nil. [?? why does this exist?]

UNTAGGED-EDGE-P (EDGE)

Returns true if-and-only-if edge's tage slot is nil

VERTEX->DOT (VERTEX STREAM)

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.

VERTEX-COUNT (GRAPH)

Returns the number of vertexes in `graph`. [?? could be a defun]

VERTEXES (THING)

Returns a list of the vertexes of `thing`.

VERTICES-SHARE-EDGE-P (VERTEX-1 VERTEX-2)

Return true if vertex-1 and vertex-2 are connected by an edge. [?? Compare adjacentp]

Undocumented

DOT-ATTRIBUTE-VALUE (ATTRIBUTE THING)

SETFDOT-ATTRIBUTE-VALUE (VALUE ATTRIBUTE THING)

EDGE (CONDITION)

GRAPH->DOT-EXTERNAL (GRAPH FILE-NAME &KEY TYPE (TYPE PS))

HEIGHT-IN-PIXELS (THING)

SETFHEIGHT-IN-PIXELS (VALUE THING)

VERTEX (CONDITION)

WIDTH-IN-PIXELS (THING)

SETFWIDTH-IN-PIXELS (VALUE THING)

Private

ADD-EDGE-TO-VERTEX (EDGE VERTEX)

Attaches the edge `edge` to the vertex `vertex`.

ADD-EDGES-TO-GRAPH (GRAPH EDGES &KEY IF-DUPLICATE-DO (IF-DUPLICATE-DO IGNORE))

ASSIGN-LEVEL (VERTEX LEVEL)

Sets the depth of `vertex` to level and then recursively sets the depth of all of the children of `vertex` to (1+ level).

BREADTH-FIRST-SEARCH-GRAPH (GRAPH SOURCE)

BREADTH-FIRST-VISITOR (GRAPH SOURCE FN)

DFS-CROSS-EDGE-P (EDGE)

DFS-FORWARD-EDGE-P (EDGE)

DFS-VISIT (GRAPH U FN SORTER)

GENERATE-ASSORTATIVE-GRAPH-WITH-DEGREE-DISTRIBUTIONS (GENERATOR GRAPH EDGE-COUNT ASSORTATIVITY-MATRIX AVERAGE-DEGREES DEGREE-DISTRIBUTIONS VERTEX-LABELER &KEY)

GENERATE-GNM (GENERATOR GRAPH N M &KEY)

Generate a 'classic' random graph G(n, m) with n vertexes and m edges.

GENERATE-GNP (GENERATOR GRAPH N P &KEY)

Generate the Erd"os-R'enyi random graph G(n, p). I.e., a graph with n vertexes where each possible edge appears with probability p. This implementation is from Efficient Generation of Large Random Networks (see batagelj-generation-2005 in doab).

GENERATE-PREFERENTIAL-ATTACHMENT-GRAPH (GENERATOR GRAPH SIZE KIND-MATRIX MINIMUM-DEGREE ASSORTATIVITY-MATRIX &KEY)

Generate a Barabasi-Albert type scale free graph with multiple vertex kinds. The idea behind this implementation is from Efficient Generation of Large Random Networks (see batagelj-generation-2005 in moab).

GENERATE-SCALE-FREE-GRAPH (GENERATOR GRAPH SIZE KIND-MATRIX ADD-EDGE-COUNT OTHER-VERTEX-KIND-SAMPLERS VERTEX-LABELER &KEY)

Generates a 'scale-free' graph using preferential attachment -- too damn slow. Size is the number of vertexes; kind-matrix is as in generate-undirected-graph-via-assortativity-matrix, etc.; add-edge-count is the number of edges to add for each vertex; other-vertex-kind-samplers are confusing...; and vertex-labeler is used to create vertex elements (as in other generators).

GENERATE-SIMPLE-PREFERENTIAL-ATTACHMENT-GRAPH (GENERATOR GRAPH SIZE MINIMUM-DEGREE)

Generate a simple scale-free graph using the preferential attachment mechanism of Barabasi and Albert. The implementation is from Efficient Generation of Large Random Networks (see batagelj-generation-2005 in moab). Self-edges are possible.

GENERATE-UNDIRECTED-GRAPH-VIA-ASSORTATIVITY-MATRIX (GENERATOR GRAPH-CLASS SIZE EDGE-COUNT KIND-MATRIX ASSORTATIVITY-MATRIX VERTEX-LABELER &KEY)

This generates a random graph with 'size' vertexes. 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. The assortativity-matrix specifies the number of edges between vertexes of different kinds. 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.

GENERATE-UNDIRECTED-GRAPH-VIA-VERTEX-PROBABILITIES (GENERATOR GRAPH-CLASS SIZE KIND-MATRIX PROBABILITY-MATRIX VERTEX-LABELER)

Generate an Erd"os-R/'enyi like random graph having multiple vertex kinds. See the function Gnp for the simple one vertex kind method. Generator and graph-class specify the random number generator used and the class of the graph produced; Size the number of vertexes. Kind matrix is a vector of ratios specifying the distribution of vertex kinds {0 ... (1- k)}. The probability-matrix is a k x k matrix specifying the probability that two vertexes of the row-kind and the column-kind will have an edge between them. vertex-labeler is a function of two arguments (the kind and the vertex number) called to create values for vertexes. It will be called only once for each vertex created. The clever sequential sampling technique in this implementation is from Efficient Generation of Large Random Networks (see batagelj-generation-2005 in moab).

INITIALIZE-VERTEX-DATA (GRAPH)

MAKE-EDGE-CONTAINER (GRAPH INITIAL-SIZE)

Make-edge-container is called during graph creation and can be used to create specialized containers to hold graph edges.

MAKE-EDGE-FOR-GRAPH (GRAPH VERTEX-1 VERTEX-2 &KEY EDGE-TYPE EDGE-CLASS (EDGE-TYPE (DEFAULT-EDGE-TYPE GRAPH)) (EDGE-CLASS (DEFAULT-EDGE-CLASS GRAPH)) &ALLOW-OTHER-KEYS)

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.

MAKE-VERTEX-CONTAINER (GRAPH INITIAL-SIZE)

Make-vertex-container is called during graph creation and can be used to create specialized containers to hold graph vertexes.

MAP-OVER-ALL-COMBINATIONS-OF-K-EDGES (VERTEX K FN)

MAP-OVER-ALL-COMBINATIONS-OF-K-VERTEXES (GRAPH K FN)

MST-FIND-SET (VERTEX)

MST-MAKE-SET (VERTEX)

MST-TREE-UNION (V1 V2)

TAG-EDGES (EDGES)

Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?]

TRAVERSE-ELEMENTS (THING STYLE FN)

WIP

TRAVERSE-ELEMENTS-HELPER (THING STYLE MARKER FN)

WIP

UNTAG-EDGES (EDGES)

Sets the `tag` of all the edges of `thing` to true. [?? why does this exist?]

Undocumented

ENSURE-VALID-DOT-ATTRIBUTE (KEY OBJECT)

WRITE-NAME-FOR-DOT (ATTRIBUTE STREAM)

SLOT-ACCESSOR

Public

COLOR (OBJECT)

The `color` is used by some algorithms for bookkeeping. [?? Should probably be in a mixin]

SETFCOLOR (NEW-VALUE OBJECT)

The `color` is used by some algorithms for bookkeeping. [?? Should probably be in a mixin]

CONTAINS-DIRECTED-EDGE-P (OBJECT)

Returns true if graph contains at least one directed edge. [?? Not sure if this is really keep up-to-date.]

SETFCONTAINS-DIRECTED-EDGE-P (NEW-VALUE OBJECT)

Returns true if graph contains at least one directed edge. [?? Not sure if this is really keep up-to-date.]

CONTAINS-UNDIRECTED-EDGE-P (OBJECT)

Returns true if graph contains at least one undirected edge. [?? Not sure if this is really keep up-to-date.]

SETFCONTAINS-UNDIRECTED-EDGE-P (NEW-VALUE OBJECT)

Returns true if graph contains at least one undirected edge. [?? Not sure if this is really keep up-to-date.]

DEFAULT-EDGE-CLASS (OBJECT)

The default edge class for the graph.

DEFAULT-EDGE-TYPE (OBJECT)

The default edge type for the graph. This should be one of :undirected or :directed.

DEPTH-LEVEL (OBJECT)

`Depth-level` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFDEPTH-LEVEL (NEW-VALUE OBJECT)

`Depth-level` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

DIRECTED-EDGE-CLASS (OBJECT)

The class used to create directed edges in the graph. This must extend the base-class for edges of the graph type and directed-edge-mixin. E.g., the directed-edge-class of a graph-container must extend graph-container-edge and directed-edge-mixin.

DISCOVERY-TIME (OBJECT)

`Discovery-time` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFDISCOVERY-TIME (NEW-VALUE OBJECT)

`Discovery-time` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

EDGE-ID (OBJECT)

The `edge-id` is used internally by CL-Graph for bookkeeping.

SETFEDGE-ID (NEW-VALUE OBJECT)

The `edge-id` is used internally by CL-Graph for bookkeeping.

ELEMENT (CONDITION)

The `element` is the value that this vertex represents.

SETFELEMENT (NEW-VALUE OBJECT)

The `element` is the value that this vertex represents.

FINISH-TIME (OBJECT)

`Finish-time` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFFINISH-TIME (NEW-VALUE OBJECT)

`Finish-time` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

GRAPH (CONDITION)

The `graph` of which this edge is a part.

SETFGRAPH (NEW-VALUE OBJECT)

The graph in which this vertex is contained.

NEXT-NODE (OBJECT)

`Next-node` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFNEXT-NODE (NEW-VALUE OBJECT)

`Next-node` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

PREVIOUS-NODE (OBJECT)

`Previous-node` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFPREVIOUS-NODE (NEW-VALUE OBJECT)

`Previous-node` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

RANK (OBJECT)

The `rank` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

SETFRANK (NEW-VALUE OBJECT)

The `rank` is used by some algorithms for bookkeeping. [?? Should be in a mixin]

TAG (OBJECT)

The `tag` is used by some algorithms for bookkeeping. [?? Should probably be in a mixin]

SETFTAG (NEW-VALUE OBJECT)

The `tag` is used by some algorithms for bookkeeping. [?? Should probably be in a mixin]

UNDIRECTED-EDGE-CLASS (OBJECT)

The class used to create undirected edges in the graph. This must extend the base-class for edges of the graph type. E.g., all edges of a graph-container must extend graph-container-edge

VERTEX-1 (CONDITION)

`Vertex-1` is one of the two vertexes that an edge connects. In a directed-edge, `vertex-1` is also the `source-edge`.

VERTEX-2 (CONDITION)

`Vertex-2` is one of the two vertexes that an edge connects. In a directed edge, `vertex-2` is also the `target-vertex`.

VERTEX-CLASS (OBJECT)

The class of the vertexes in the graph. This must extend the base-class for vertexes of the graph type. E.g., all vertexes of a graph-container must extend graph-container-vertex.

VERTEX-ID (OBJECT)

`Vertex-id` is used internally to keep track of vertexes.

WEIGHT (EDGE)

The Returns the weight of an edge. This defaults to 1.0 and can only be altered if the edge is a sub-class of `weighted-edge-mixin`.

SETFWEIGHT (NEW-VALUE OBJECT)

Set the Returns the weight of an edge. This defaults to 1.0 and can only be altered if the edge is a sub-class of `weighted-edge-mixin`.

Undocumented

DOT-ATTRIBUTES (OBJECT)

SETFDOT-ATTRIBUTES (NEW-VALUE OBJECT)

GRAPH-EDGES (OBJECT)

GRAPH-VERTEXES (OBJECT)

Private

VALUE (OBJECT)

The `element` is the value that this vertex represents.

SETFVALUE (NEW-VALUE OBJECT)

The `element` is the value that this vertex represents.

Undocumented

ADJENCENCY-MATRIX (OBJECT)

EDGE-KEY (OBJECT)

EDGE-TEST (OBJECT)

LARGEST-EDGE-ID (OBJECT)

LARGEST-VERTEX-ID (OBJECT)

VERTEX-EDGES (OBJECT)

VERTEX-KEY (OBJECT)

VERTEX-PAIR->EDGE (OBJECT)

VERTEX-TEST (OBJECT)

VARIABLE

Public

Undocumented

*DOT-GRAPH-ATTRIBUTES*

Private

*DOT-PATH*

Path to `dot`

Undocumented

*DEPTH-FIRST-SEARCH-TIMER*

*DOT-EDGE-ATTRIBUTES*

*DOT-VERTEX-ATTRIBUTES*

CLASS

Public

BASIC-EDGE

This is the root class for all edges in CL-Graph.

BASIC-GRAPH

This is the root class for all graphs in CL-Graph.

BASIC-VERTEX

This is the root class for all vertexes in CL-Graph.

DIRECTED-EDGE-MIXIN

This mixin class is used to indicate that an edge is directed.

GRAPH-CONTAINER

A graph container is essentially an adjacency list graph representation [?? The Bad name comes from it being implemented with containers... ugh]

GRAPH-CONTAINER-DIRECTED-EDGE

A graph-container-directed-edge is both a directed-edge-mixin and a graph-container-edge.

GRAPH-CONTAINER-EDGE

This is the root class for edges in graph-containers. It adds vertex-1 and vertex-2 slots.

GRAPH-CONTAINER-VERTEX

A graph container vertex keeps track of its edges in the the vertex-edges slot. The storage for this defaults to a vector-container but can be changed using the vertex-edges-container-class initarg.

GRAPH-MATRIX

Stub for matrix based graph. Not implemented.

GRAPH-MATRIX-EDGE

Stub for matrix based graph. Not implemented.

GRAPH-MATRIX-VERTEX

Stub for matrix based graph. Not implemented.

WEIGHTED-EDGE

A weighted edge is both a weighted-edge-mixin and a graph-container-edge.

WEIGHTED-EDGE-MIXIN

This mixin class adds a `weight` slot to an edge.

Undocumented

DOT-ATTRIBUTES-MIXIN

DOT-DIRECTED-EDGE

DOT-EDGE

DOT-EDGE-MIXIN

DOT-GRAPH

DOT-GRAPH-MIXIN

DOT-VERTEX

DOT-VERTEX-MIXIN

CONDITION

Public

EDGE-ERROR

This is the root condition for graph errors that have to do with edges.

GRAPH-EDGE-NOT-FOUND-ERROR

This condition is signaled when an edge cannot be found in a graph.

GRAPH-ERROR

This is the root condition for errors that occur while running code in CL-Graph.

GRAPH-VERTEX-NOT-FOUND-ERROR

This condition is signaled when a vertex can not be found in a graph.

GRAPH-VERTEX-NOT-FOUND-IN-EDGE-ERROR

This condition is signaled when a vertex can not be found in an edge.