Directed graph utilities
Factor handbook » The language » Collections

Prev:Boxes
Next:Locked I/O buffers


Words for treating associative mappings as directed graphs can be found in the graphs vocabulary. A directed graph is represented as an assoc mapping each vertex to a hash-set of edges entering that vertex.

To create a new graph, just create an assoc, for example by calling <hashtable>. To add vertices and edges to a graph:
add-vertex ( vertex edges graph -- )


To remove vertices from the graph:
remove-vertex ( vertex edges graph -- )


Since graphs are represented as assocs, they can be cleared out by calling clear-assoc.

You can perform queries on a graph:
closure ( vertex quot: ( vertex -- edges ) -- set )


Directed graphs are used to maintain cross-referencing information for Definitions.