7.2.1. Manipulating Graphs
(lsh/libgraph/graph.lsh)




7.2.1.0. Gbag Class
(lsh/libgraph/graph.lsh)


a useful Lisp class to handle dynamically allocated data structures.

7.2.1.0.0. (new Gbag)
[CLASS] (lsh/libgraph/graph.lsh)


Allocates a new collection of GPTRs. The housekeeping data structures will be allocated on pool specified with method add . The following messages are supported:
See: (==> gbag add pool gptr )
See: (==> gbag rem gptr )
See: (==> gbag test gptr )
See: (==> gbag size)


7.2.1.0.1. (==> gbag size)
[MSG] (lsh/libgraph/graph.lsh)


Returns the number of elements in the bag gbag .

7.2.1.0.2. (==> gbag add pool gptr)
[MSG] (lsh/libgraph/graph.lsh)


Adds a new element GPTR in the bag gbag . Memory will be allocated from pool pool . It is safer to always use the same pool with a given bag. This pool, as well as the data pointed to by gptr *must* outlive the bag.

7.2.1.0.3. (==> gbag test gptr)
[MSG] (lsh/libgraph/graph.lsh)


Tests if element gptr belongs to bad gbag .

7.2.1.0.4. (==> gbag rem gptr)
[MSG] (lsh/libgraph/graph.lsh)


Remove all occurences of element gptr in the bag gbag . This function also resets the iterator.

7.2.1.0.5. (==> gbag empty)
[MSG] (lsh/libgraph/graph.lsh)


Removes all elements in a bag

7.2.1.0.6. (gbagelt-peek-data gptr)
(lsh/libgraph/graph.lsh)


Peek data in a gbag element.

7.2.1.0.7. (gbagelt-peek-next gptr)
(lsh/libgraph/graph.lsh)


Peek next gbag element.

7.2.1.0.8. (all-bag (var bag) ...prog...)
(lsh/libgraph/graph.lsh)


Iterate prog with var taking all values in bag .

7.2.1.1. GGraph Class
(lsh/libgraph/graph.lsh)




7.2.1.1.0. (new GGraph)
[CLASS] (lsh/libgraph/graph.lsh)


Class GGraph defines the functions for handling graphs. Graphs are handled via two other classes of objects.

7.2.1.1.1. :graph:apool
(lsh/libgraph/graph.lsh)


Slot apool in a graph contains the pool used for storing all objects depending on the graph. This pool is created when you create the graph object. You may use this pool to allocate objects stored in the data slots of the nodes and the links.

7.2.1.1.2. :graph:nnodes
(lsh/libgraph/graph.lsh)


Slot nnodes in a graph contains the number of nodes allocated in a graph.

7.2.1.1.3. :graph:startnode
(lsh/libgraph/graph.lsh)


Slot startnode in a graph contains the start node of the graph. This node is created when the graph is created.

7.2.1.1.4. :graph:endnode
(lsh/libgraph/graph.lsh)


Slot endnode in a graph contains the final node of the graph. This node is created when the graph is created.

7.2.1.1.5. :node:id
(lsh/libgraph/graph.lsh)


Slot id in a node contains the ordinal number of the node. This number was allocated when you created the node. You should not change it.

7.2.1.1.6. :node:data
(lsh/libgraph/graph.lsh)


Slot data of a node contains an arbitrary GPTR. This GPTR is not used by the graph library and is available for you. You must of course take the usual precautions with GPTRs.

7.2.1.1.7. :link:upnode
(lsh/libgraph/graph.lsh)


Slot downnode of a link contains the upstream node of the link.

7.2.1.1.8. :link:downnode
(lsh/libgraph/graph.lsh)


Slot downnode of a link contains the downstream node of the link.

7.2.1.1.9. :link:cost
(lsh/libgraph/graph.lsh)


Slot cost of a link is a floating point number for storing the cost associated with a link. Costs are real number (both positive and negative). The smaller the cost the better the link. You can view these costs as -log(probability) .

7.2.1.1.10. :link:dcost
(lsh/libgraph/graph.lsh)


Slot dcost of a link is a floating point number intended for storing the derivative of the global cost with respect to the contents of the slot cost . This slot is set by functions g-clear-gradients and g-forward-backward .

7.2.1.1.11. :link:label
(lsh/libgraph/graph.lsh)


Slot label of a link contains an arbitrary integer. This integer is not used by the graph library and is available for you.

7.2.1.1.12. :link:data
(lsh/libgraph/graph.lsh)


Slot data of a link contains an arbitrary GPTR. This GPTR is not used by the graph library and is available for you. You must of course take the usual precautions with GPTRs.

7.2.1.2. GNode Class
(lsh/libgraph/graph.lsh)




7.2.1.3. GLink Class
(lsh/libgraph/graph.lsh)




7.2.1.3.0. (all-nodes (var graph) ...prog...)
(lsh/libgraph/graph.lsh)


Iterate prog with var being all nodes in graph graph .

7.2.1.3.1. (all-downlink (var node) ...prog...)
(lsh/libgraph/graph.lsh)


Iterate prog with var being all links downstream of node .

7.2.1.3.2. (all-uplink (var node) ...prog...)
(lsh/libgraph/graph.lsh)


Iterate prog with var being all links upstream of node .

7.2.1.3.3. (==> graph newnode data)
[MSG] (lsh/libgraph/graph.lsh)


Creates a new node in the graph. The new node points to data GPTR data . All data pointed to by data MUST outlive the graph. You can for instance allocate this data on the pool :graph:apool .

7.2.1.3.4. (==> graph link node1 node2 cost label data)
[MSG] (lsh/libgraph/graph.lsh)


Creates a new arc in the graph between nodes node1 and node2 . The new arc is assigned a cost cost , an integer interpretation label and the data pointed to by the GPTR data . All data pointed to by data MUST outlive the graph. You can for instance allocate this data on the pool :graph:apool .

7.2.1.3.5. (==> graph linkm node1 node2 cost label meaning data)
[MSG] (lsh/libgraph/graph.lsh)


See: (==> graph link node1 node2 cost label data )
A link creation function which also sets the meaning field. The default creation function store the same value in both the label and meaning fields

7.2.1.3.6. (==> graph cut link)
[MSG] (lsh/libgraph/graph.lsh)


Removes arc link from the graph. No memory is reclaimed. Links may be cut in a frozen graph.

7.2.1.3.7. (==> graph freeze)
[MSG] (lsh/libgraph/graph.lsh)


Forbids any further alteration of the graph.

7.2.1.3.8. (==> graph dump)
[MSG] (lsh/libgraph/graph.lsh)


Dumps a graph on the standard output.