]> gitweb.factorcode.org Git - factor.git/blob - core/collections/graphs.facts
2847355636fef90930b14dbc4fb53d0b5e7f8e34
[factor.git] / core / collections / graphs.facts
1 IN: graphs
2 USING: help ;
3
4 HELP: add-vertex
5 { $values { "vertex" "an object" } { "edges" "a quotation with stack effect " { $snippet "( vertex -- seq )" } } { "graph" "a hashtable mapping vertices to sequences of edges" } }
6 { $description "Adds a vertex to a directed graph, using the " { $snippet "edges" } " quotation to generate a sequence of edges leaving the vertex." }
7 { $side-effects "graph" } ;
8
9 HELP: build-graph
10 { $values { "seq" "a sequence" } { "edges" "a quotation with stack effect " { $snippet "( vertex -- seq )" } } { "graph" "a hashtable mapping vertices to sequences of edges" } }
11 { $description "Removes all vertices from the graph, then reconstructs it using the given sequence of vertices and quotation to generate a sequence of edges leaving each vertex." }
12 { $side-effects "graph" } ;
13
14 HELP: remove-vertex
15 { $values { "vertex" "an object" } { "edges" "a quotation with stack effect " { $snippet "( vertex -- seq )" } } { "graph" "a hashtable mapping vertices to sequences of edges" } }
16 { $description "Removes a vertex from a graph, using the quotation to generate a sequence of edges leaving the vertex." } 
17 { $notes "The " { $snippet "edges" } " quotation must produce the same return value as it did when " { $link add-vertex } " was called, otherwise some vertices of the graph may continue to refer to the removed vertex." }
18 { $side-effects "graph" } ;
19
20 HELP: in-edges
21 { $values { "vertex" "an object" } { "graph" "a hashtable mapping vertices to sequences of edges" } { "seq" "a sequence of vertices" } }
22 { $description "Outputs a sequence of vertices incident to an edge entering the given vertex." } ;
23
24 HELP: closure
25 { $values { "obj" "an object" } { "quot" "a a quotation with stack effect " { $snippet "( obj -- seq )" } } { "seq" "a new sequence" } }
26 { $description "Outputs a sequence of all vertices reachable from " { $snippet "vertex" } " via edges given by the quotation. This sequence always includes " { $snippet "vertex" } "." } ;