changeset 151:4a8c122725b0

Move all the example files to "examples/"
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 07 May 2026 16:12:15 +0200
parents 4acf578ae93f
children 66d49e49b06b
files docs/algorithm-dinic.description docs/algorithm-edmonds-karp.pseudocode docs/algorithm-ford-fulkerson.pseudocode docs/conf.py docs/example-1.pseudocode docs/examples/algorithm-dinic.description docs/examples/algorithm-edmonds-karp.pseudocode docs/examples/algorithm-ford-fulkerson.pseudocode docs/examples/example-1.pseudocode docs/intro.rst
diffstat 10 files changed, 136 insertions(+), 136 deletions(-) [+]
line wrap: on
line diff
--- a/docs/algorithm-dinic.description	Thu May 07 16:06:59 2026 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-// -*- coding: utf-8; indent-tabs-mode: nil -*-
-\ALGORITHM{Dinic's Algorithm} \WITH
-  \INPUT{A network \expr{G = ((V , E), c, s, t)}.}
-  \OUTPUT{An \expr{s–t} flow \expr{f} of maximum value.}
-\IS
-  \TEXT{1. Set \expr{f(e) = 0} for each \expr{e ∈ E}.
-  2. Construct \expr{G_L} from \expr{G_f} of \expr{G}.
-     If \expr{\text{dist}(t) = ∞}, stop and output \expr{f}.
-  3. Find a blocking flow \expr{f\'} in \expr{G_L}.
-  4. Augment flow \expr{f} by \expr{f\'} and go back to step 2.}
-\END ALGORITHM
--- a/docs/algorithm-edmonds-karp.pseudocode	Thu May 07 16:06:59 2026 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-// -*- coding: utf-8; indent-tabs-mode: nil -*-
-\ALGORITHM{Edmonds–Karp} \WITH
-    \INPUT{
-      \expr{graph}:  \expr{graph[v]} should be the list of edges coming out of vertex \expr{v} in the
-              original graph and their corresponding constructed reverse edges
-              which are used for push-back flow.
-              Each edge should have a capacity \expr{cap}, \expr{flow}, source \expr{s} and sink \expr{t} 
-              as parameters, as well as a pointer to the reverse edge \expr{rev}.
-      \expr{s}:      Source vertex
-      \expr{t}:      Sink vertex}
-    \OUTPUT{
-      \expr{flow}:  Value of maximum flow)}
-\IS
-    flow := 0
-    \REPEAT
-        /* Run a breadth-first search (bfs) to find the shortest s-t path.
-           We use 'pred' to store the edge taken to get to each vertex,
-           so we can recover the path afterwards. */
-        q := queue()
-        q.push(s)
-        pred := array(graph.length)
-        \WHILE not empty(q) and pred[t] = null \DO
-            cur := q.pop()
-            \FOR \text{Edge} e in graph[cur] \DO
-                \IF pred[e.t] = null and e.t != s and e.cap > e.flow \THEN
-                    pred[e.t] := e
-                    q.push(e.t)
-                \END IF
-            \END FOR
-        \END WHILE
-        \IF not (pred[t] = null) \THEN
-            /* We found an augmenting path.
-               See how much flow we can send */
-            df := ∞
-            \FOR (e := pred[t]; e != null; e := pred[e.s]) \DO
-                df := min(df, e.cap - e.flow)
-            \END FOR
-            /* And update edges by that amount */
-            \FOR (e := pred[t]; e != null; e := pred[e.s]) \DO
-                e.flow  := e.flow + df
-                e.rev.flow := e.rev.flow - df
-            \END FOR
-            flow := flow + df
-        \END IF
-    \UNTIL pred[t] = null      \REM i.e., until no augmenting path was found
-    \RETURN flow
-\END ALGORITHM {Edmonds–Karp}
--- a/docs/algorithm-ford-fulkerson.pseudocode	Thu May 07 16:06:59 2026 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-// -*- coding: utf-8; indent-tabs-mode: nil -*-
-\ALGORITHM{Ford–Fulkerson} \WITH
-  \INPUTS{Given a network \expr{G = (V, E)} with flow capacity \expr{c}, a source node \expr{s}, and a sink node \expr{t}}
-  \OUTPUT{Compute a flow \expr{f} from \expr{s} to \expr{t} of maximum value}
-\IS
-  \TEXT{1. \expr{f(u, v) \gets 0} for all edges \expr{(u, v)}
-
-  2. While there is a path \expr{p} from \expr{s} to \expr{t} in \expr{G_f},
-     such that \expr{c_f(u, v) > 0} for all edges \expr{(u, v) ∈ p}:
-
-     1. Find \expr{c_f(p) = min{c_f(u, v): (u, v) ∈ p\}}
-
-     2. For each edge \expr{(u, v) ∈ p}
-
-        1. \expr{f(u, v) \gets f(u, v) + c_f(p)}   \rem Send flow along the path
-
-	2. \expr{f(v, u) \gets f(v, u) - c_f(p)}   \rem The flow might be "returned" later
-}
-\END ALGORITHM {Ford–Fulkerson}
--- a/docs/conf.py	Thu May 07 16:06:59 2026 +0200
+++ b/docs/conf.py	Thu May 07 16:12:15 2026 +0200
@@ -69,7 +69,7 @@
 # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
 
 html_static_path = ['_static']
-html_extra_path = ['../LICENSES']
+html_extra_path = ['../LICENSES', './examples']
 
 #html_theme = 'alabaster'
 html_theme = 'haiku'
--- a/docs/example-1.pseudocode	Thu May 07 16:06:59 2026 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-// -*- coding: utf-8; indent-tabs-mode: nil -*-
-\PROGRAM {The Pseudocode Lexer} \IS
-
-  /*
-   * The program is here, but it also could be an \ALGORITHM
-   *
-   * /* YES! Nested multi-line comments work! */
-   */
-
-  \PROC {A Procedure name} \IS
-    \TBLOCK {A text block 1}
-    \TBLOCK {A text block 2 with a nested expression: \expr{flag is FALSE}}
-    \BLOCK {
-        \REMARK  A remark on its own line within a "BLOCK"
-    }
-  \END-PROC {A Procedure name}
-
-  \FUNCTION{A Function with {escaped\} text} \IS
-    a and b xor (c in d)      \rem this is another remark
-    \block {foo bar}
-
-    \IF a is nil \THEN
-      \text{Set something}
-    \ELSEIF
-      \text{Set some other thing}
-    \END-IF
-  \END FUNCTION{A Function with {escaped\} text}
-
-  \CLASS{A Class} \IS
-    // This is a one-line comment
-    a and b xor (c in d)      \rem this is another remark
-
-    # This is another one-line comment
-
-    (* Here is a "block" of expressions.
-       A block has a leading symbol. *)
-    \block {foo
-      bar}
-    \block{a 1.2 {x in X\} c}
-    (* Analogous there is a variant that is in text-mode by default.
-       It has an other leading symbol. *)
-    \tstate{We will compute next \expr{a xor b or (\text{set} X is Empty)} \rem without c!
-      or multiply it the other way round}
-
-    \tstate{foo bar     \rem A remark within a text statement until LF!
-      nextfoo nextbar
-      nextnextfoo nextnextbar}
-  \ENDCLASS{A Class}
-
-  @A_XXX
-  FOO BAR
-\ENDPROG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/examples/algorithm-dinic.description	Thu May 07 16:12:15 2026 +0200
@@ -0,0 +1,11 @@
+// -*- coding: utf-8; indent-tabs-mode: nil -*-
+\ALGORITHM{Dinic's Algorithm} \WITH
+  \INPUT{A network \expr{G = ((V , E), c, s, t)}.}
+  \OUTPUT{An \expr{s–t} flow \expr{f} of maximum value.}
+\IS
+  \TEXT{1. Set \expr{f(e) = 0} for each \expr{e ∈ E}.
+  2. Construct \expr{G_L} from \expr{G_f} of \expr{G}.
+     If \expr{\text{dist}(t) = ∞}, stop and output \expr{f}.
+  3. Find a blocking flow \expr{f\'} in \expr{G_L}.
+  4. Augment flow \expr{f} by \expr{f\'} and go back to step 2.}
+\END ALGORITHM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/examples/algorithm-edmonds-karp.pseudocode	Thu May 07 16:12:15 2026 +0200
@@ -0,0 +1,47 @@
+// -*- coding: utf-8; indent-tabs-mode: nil -*-
+\ALGORITHM{Edmonds–Karp} \WITH
+    \INPUT{
+      \expr{graph}:  \expr{graph[v]} should be the list of edges coming out of vertex \expr{v} in the
+              original graph and their corresponding constructed reverse edges
+              which are used for push-back flow.
+              Each edge should have a capacity \expr{cap}, \expr{flow}, source \expr{s} and sink \expr{t} 
+              as parameters, as well as a pointer to the reverse edge \expr{rev}.
+      \expr{s}:      Source vertex
+      \expr{t}:      Sink vertex}
+    \OUTPUT{
+      \expr{flow}:  Value of maximum flow)}
+\IS
+    flow := 0
+    \REPEAT
+        /* Run a breadth-first search (bfs) to find the shortest s-t path.
+           We use 'pred' to store the edge taken to get to each vertex,
+           so we can recover the path afterwards. */
+        q := queue()
+        q.push(s)
+        pred := array(graph.length)
+        \WHILE not empty(q) and pred[t] = null \DO
+            cur := q.pop()
+            \FOR \text{Edge} e in graph[cur] \DO
+                \IF pred[e.t] = null and e.t != s and e.cap > e.flow \THEN
+                    pred[e.t] := e
+                    q.push(e.t)
+                \END IF
+            \END FOR
+        \END WHILE
+        \IF not (pred[t] = null) \THEN
+            /* We found an augmenting path.
+               See how much flow we can send */
+            df := ∞
+            \FOR (e := pred[t]; e != null; e := pred[e.s]) \DO
+                df := min(df, e.cap - e.flow)
+            \END FOR
+            /* And update edges by that amount */
+            \FOR (e := pred[t]; e != null; e := pred[e.s]) \DO
+                e.flow  := e.flow + df
+                e.rev.flow := e.rev.flow - df
+            \END FOR
+            flow := flow + df
+        \END IF
+    \UNTIL pred[t] = null      \REM i.e., until no augmenting path was found
+    \RETURN flow
+\END ALGORITHM {Edmonds–Karp}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/examples/algorithm-ford-fulkerson.pseudocode	Thu May 07 16:12:15 2026 +0200
@@ -0,0 +1,19 @@
+// -*- coding: utf-8; indent-tabs-mode: nil -*-
+\ALGORITHM{Ford–Fulkerson} \WITH
+  \INPUTS{Given a network \expr{G = (V, E)} with flow capacity \expr{c}, a source node \expr{s}, and a sink node \expr{t}}
+  \OUTPUT{Compute a flow \expr{f} from \expr{s} to \expr{t} of maximum value}
+\IS
+  \TEXT{1. \expr{f(u, v) \gets 0} for all edges \expr{(u, v)}
+
+  2. While there is a path \expr{p} from \expr{s} to \expr{t} in \expr{G_f},
+     such that \expr{c_f(u, v) > 0} for all edges \expr{(u, v) ∈ p}:
+
+     1. Find \expr{c_f(p) = min{c_f(u, v): (u, v) ∈ p\}}
+
+     2. For each edge \expr{(u, v) ∈ p}
+
+        1. \expr{f(u, v) \gets f(u, v) + c_f(p)}   \rem Send flow along the path
+
+	2. \expr{f(v, u) \gets f(v, u) - c_f(p)}   \rem The flow might be "returned" later
+}
+\END ALGORITHM {Ford–Fulkerson}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/examples/example-1.pseudocode	Thu May 07 16:12:15 2026 +0200
@@ -0,0 +1,52 @@
+// -*- coding: utf-8; indent-tabs-mode: nil -*-
+\PROGRAM {The Pseudocode Lexer} \IS
+
+  /*
+   * The program is here, but it also could be an \ALGORITHM
+   *
+   * /* YES! Nested multi-line comments work! */
+   */
+
+  \PROC {A Procedure name} \IS
+    \TBLOCK {A text block 1}
+    \TBLOCK {A text block 2 with a nested expression: \expr{flag is FALSE}}
+    \BLOCK {
+        \REMARK  A remark on its own line within a "BLOCK"
+    }
+  \END-PROC {A Procedure name}
+
+  \FUNCTION{A Function with {escaped\} text} \IS
+    a and b xor (c in d)      \rem this is another remark
+    \block {foo bar}
+
+    \IF a is nil \THEN
+      \text{Set something}
+    \ELSEIF
+      \text{Set some other thing}
+    \END-IF
+  \END FUNCTION{A Function with {escaped\} text}
+
+  \CLASS{A Class} \IS
+    // This is a one-line comment
+    a and b xor (c in d)      \rem this is another remark
+
+    # This is another one-line comment
+
+    (* Here is a "block" of expressions.
+       A block has a leading symbol. *)
+    \block {foo
+      bar}
+    \block{a 1.2 {x in X\} c}
+    (* Analogous there is a variant that is in text-mode by default.
+       It has an other leading symbol. *)
+    \tstate{We will compute next \expr{a xor b or (\text{set} X is Empty)} \rem without c!
+      or multiply it the other way round}
+
+    \tstate{foo bar     \rem A remark within a text statement until LF!
+      nextfoo nextbar
+      nextnextfoo nextnextbar}
+  \ENDCLASS{A Class}
+
+  @A_XXX
+  FOO BAR
+\ENDPROG
--- a/docs/intro.rst	Thu May 07 16:06:59 2026 +0200
+++ b/docs/intro.rst	Thu May 07 16:12:15 2026 +0200
@@ -85,40 +85,40 @@
 
 A synthetic example with most features:
 
-.. literalinclude:: example-1.pseudocode
+.. literalinclude:: examples/example-1.pseudocode
    :language: algpseudocode
    :lines: 2-
 
 With a customized `AlgPseudocodeLexer` and its `no_end`
 option set to ``True``.
 
-.. literalinclude:: example-1.pseudocode
+.. literalinclude:: examples/example-1.pseudocode
    :language: NoEndAlgPseudocode
    :lines: 2-
 
 This is Wikipedia's description of *Dinic's Algorithm*
 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm):
 
-.. literalinclude:: algorithm-dinic.description
+.. literalinclude:: examples/algorithm-dinic.description
    :language: algpseudocode
    :lines: 2-
 
 This is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm*
 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm):
 
-.. literalinclude:: algorithm-ford-fulkerson.pseudocode
+.. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode
    :language: algpseudocode
    :lines: 2-
 
 This is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm*
 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm):
 
-.. literalinclude:: algorithm-edmonds-karp.pseudocode
+.. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
    :language: NoEndAlgPseudocode
    :lines: 2-
 
 And now the *Edmonds–Karp Algorithm* with french keywords:
 
-.. literalinclude:: algorithm-edmonds-karp.pseudocode
+.. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
    :language: algpseudocode-fr
    :lines: 2-