Directed graph utilities

Factor handbook » The language » Collections

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:

To remove vertices from the graph:

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

You can perform queries on a graph:

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

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.

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2173, heads/master-f3ee5c5979, Sep 18 2022 13:17:51)