]> gitweb.factorcode.org Git - factor.git/blob - core/graphs/graphs-docs.factor
Revert "interpolate: allow format directives to be used"
[factor.git] / core / graphs / graphs-docs.factor
1 USING: assocs hashtables hash-sets help.markup help.syntax
2 kernel sequences sets ;
3 IN: graphs
4
5 ARTICLE: "graphs" "Directed graph utilities"
6 "Words for treating associative mappings as directed graphs can be found in the " { $vocab-link "graphs" } " vocabulary. A directed graph is represented as an assoc mapping each vertex to a " { $link hash-set } " of edges entering that vertex."
7 $nl
8 "To create a new graph, just create an assoc, for example by calling " { $link <hashtable> } ". To add vertices and edges to a graph:"
9 { $subsections add-vertex }
10 "To remove vertices from the graph:"
11 { $subsections remove-vertex }
12 "Since graphs are represented as assocs, they can be cleared out by calling " { $link clear-assoc } "."
13 $nl
14 "You can perform queries on a graph:"
15 { $subsections closure }
16 "Directed graphs are used to maintain cross-referencing information for " { $link "definitions" } "." ;
17
18 ABOUT: "graphs"
19
20 HELP: add-vertex
21 { $values { "vertex" object } { "edges" sequence } { "graph" "an " { $link assoc } " mapping vertices to " { $link hash-set } " of edges" } }
22 { $description "Adds a vertex to a directed graph, with " { $snippet "edges" } " as the outward edges from the vertex." }
23 { $side-effects "graph" } ;
24
25 HELP: remove-vertex
26 { $values { "vertex" object } { "edges" sequence } { "graph" "an " { $link assoc } " mapping vertices to " { $link set } "s of edges" } }
27 { $description "Removes a vertex from a graph, using the given edges sequence." }
28 { $notes "The " { $snippet "edges" } " sequence must have all the values passed to " { $link add-vertex } ", otherwise some vertices of the graph may continue to refer to the removed vertex." }
29 { $side-effects "graph" } ;
30
31 HELP: closure
32 { $values { "vertex" object } { "quot" { $quotation ( vertex -- edges ) } } { "set" hash-set } }
33 { $description "Outputs all vertices reachable from " { $snippet "vertex" } " via edges given by the quotation. The set always includes " { $snippet "vertex" } "." } ;