File: index.rst

package info (click to toggle)
python-pytooling 8.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,564 kB
  • sloc: python: 23,883; makefile: 13
file content (87 lines) | stat: -rw-r--r-- 26,775 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.. _STRUCT:

Overview
########

Currently, the following data structures are implemented:

* :ref:`STRUCT/Path/Generic`

  * :ref:`STRUCT/Path/URL`


+---------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| :ref:`STRUCT/Graph`                                                                                                 | :ref:`STRUCT/Tree`                                                                                                 | :ref:`STRUCT/Statemachine`                                                                                          |
+=====================================================================================================================+====================================================================================================================+=====================================================================================================================+
| .. mermaid::                                                                                                        | .. mermaid::                                                                                                       | .. mermaid::                                                                                                        |
|    :caption: A directed graph with backward-edges denoted by dotted vertex relations.                               |    :caption: Root of the current node are marked in blue.                                                          |    :caption: A statemachine graph.                                                                                  |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    %%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%%  |    %%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%% |    %%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%%  |
|    graph LR                                                                                                         |    graph TD                                                                                                        |    graph TD                                                                                                         |
|      A(A); B(B); C(C); D(D); E(E); F(F) ; G(G); H(H); I(I)                                                          |      R(Root)                                                                                                       |      A(Idle); B(Check); C(Prepare); D(Read); E(Finished); F(Write) ; G(Retry); H(WriteWait); I(ReadWait)            |
|                                                                                                                     |      A(...)                                                                                                        |                                                                                                                     |
|      A --> B --> E                                                                                                  |      BL(Node); B(GrandParent); BR(Node)                                                                            |      A:::mark1 --> B --> C --> F                                                                                    |
|      G --> F                                                                                                        |      CL(Uncle); C(Parent); CR(Aunt)                                                                                |      F --> H --> E:::cur                                                                                            |
|      A --> C --> G --> H --> D                                                                                      |      DL(Sibling); D(Node);  DR(Sibling)                                                                            |      B --> G --> B                                                                                                  |
|      D -.-> A                                                                                                       |      ELN1(Niece); ELN2(Nephew)                                                                                     |      G -.-> A --> C                                                                                                 |
|      D & F -.-> B                                                                                                   |      EL(Child);   E(Child); ER(Child);                                                                             |      D -.-> A                                                                                                       |
|      I ---> E --> F --> D                                                                                           |      ERN1(Niece);ERN2(Nephew)                                                                                      |      C ---> D --> I --> E -.-> A                                                                                    |
|                                                                                                                     |      F1(GrandChild); F2(GrandChild)                                                                                |                                                                                                                     |
|      classDef node fill:#eee,stroke:#777,font-size:smaller;                                                         |                                                                                                                    |      classDef node fill:#eee,stroke:#777,font-size:smaller;                                                         |
|      classDef node fill:#eee,stroke:#777,font-size:smaller;                                                         |      R:::mark1 --> A                                                                                               |      classDef cur fill:#9e9,stroke:#6e6;                                                                            |
|      classDef node fill:#eee,stroke:#777,font-size:smaller;                                                         |      A --> BL & B & BR                                                                                             |      classDef mark1 fill:#69f,stroke:#37f,color:#eee;                                                               |
|                                                                                                                     |      B --> CL & C & CR                                                                                             |                                                                                                                     |
|                                                                                                                     |      C --> DL & D & DR                                                                                             |                                                                                                                     |
|                                                                                                                     |      DL --> ELN1 & ELN2                                                                                            |                                                                                                                     |
|                                                                                                                     |      D:::cur --> EL & E & ER                                                                                       |                                                                                                                     |
|                                                                                                                     |      DR --> ERN1 & ERN2                                                                                            |                                                                                                                     |
|                                                                                                                     |      E --> F1 & F2                                                                                                 |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |      classDef node fill:#eee,stroke:#777,font-size:smaller;                                                        |                                                                                                                     |
|                                                                                                                     |      classDef cur fill:#9e9,stroke:#6e6;                                                                           |                                                                                                                     |
|                                                                                                                     |      classDef mark1 fill:#69f,stroke:#37f,color:#eee;                                                              |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
+---------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| .. code-block:: python                                                                                              | .. code-block:: python                                                                                             | .. code-block:: python                                                                                              |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    from pyTooling.Graph import Graph                                                                                |    from pyTooling.Tree import Node                                                                                 |    from pyTooling.StateMachine import FSM, State                                                                    |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    graph = Graph(name="Example Graph")                                                                              |    root = Node(id="Root")                                                                                          |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Create a standalone vertex A in the graph                                                                      |    dir1 = Node(id="Dir1", parent=root)                                                                             |                                                                                                                     |
|    rootA = Vertex(value="A", graph=graph)                                                                           |    dir2 = Node(id="Dir2", parent=root)                                                                             |                                                                                                                     |
|                                                                                                                     |    file0 = Node(id="File0", parent=root)                                                                           |                                                                                                                     |
|    # Add 2 vertices B,C and add edges from A                                                                        |    dir3 = Node(id="Dir3", parent=root)                                                                             |                                                                                                                     |
|    edgeAB = rootA.EdgeToNewVertex(vertexValue="B")                                                                  |                                                                                                                    |                                                                                                                     |
|    edgeAC = rootA.EdgeToNewVertex(vertexValue="C")                                                                  |    file1 = Node(id="File1", parent=dir1)                                                                           |                                                                                                                     |
|                                                                                                                     |    file2 = Node(id="File2", parent=dir1)                                                                           |                                                                                                                     |
|    # Get vertices B,C                                                                                               |    file3 = Node(id="File3", parent=dir1)                                                                           |                                                                                                                     |
|    vertexB = edgeAB.Destination                                                                                     |                                                                                                                    |                                                                                                                     |
|    vertexC = edgeAC.Destination                                                                                     |    file4 = Node(id="File4", parent=dir2)                                                                           |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Add more standalone vertices D,E,F,G                                                                           |    file5 = Node(id="File5", parent=dir3)                                                                           |                                                                                                                     |
|    vertexD = Vertex(value="D", graph=graph)                                                                         |    file6 = Node(id="File6", parent=dir3)                                                                           |                                                                                                                     |
|    vertexE = Vertex(value="E", graph=graph)                                                                         |                                                                                                                    |                                                                                                                     |
|    vertexF = Vertex(value="F", graph=graph)                                                                         |                                                                                                                    |                                                                                                                     |
|    vertexG = Vertex(value="G", graph=graph)                                                                         |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Create edges between B-E,C-G,D-A,D-B                                                                           |                                                                                                                    |                                                                                                                     |
|    vertexB.EdgeTo(vertexE)                                                                                          |                                                                                                                    |                                                                                                                     |
|    vertexC.EdgeTo(vertexG)                                                                                          |                                                                                                                    |                                                                                                                     |
|    vertexD.EdgeTo(rootA)                                                                                            |                                                                                                                    |                                                                                                                     |
|    vertexD.EdgeTo(vertexB)                                                                                          |                                                                                                                    |                                                                                                                     |
|    vertexE.EdgeTo(vertexF)                                                                                          |                                                                                                                    |                                                                                                                     |
|    vertexF.EdgeTo(vertexB)                                                                                          |                                                                                                                    |                                                                                                                     |
|    vertexG.EdgeTo(vertexF)                                                                                          |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Create edge from                                                                                               |                                                                                                                    |                                                                                                                     |
|    vertexD.EdgeFrom(vertexF)                                                                                        |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Add vertex I,H and add edge from new vertex to existing                                                        |                                                                                                                    |                                                                                                                     |
|    vertexE.EdgeFromNewVertex(vertexValue="I")                                                                       |                                                                                                                    |                                                                                                                     |
|    vertexD.EdgeFromNewVertex(vertexValue="H")                                                                       |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
|    # Lookup vertices and link them                                                                                  |                                                                                                                    |                                                                                                                     |
|    vertexG.EdgeTo(graph.GetVertexByValue("H"))                                                                      |                                                                                                                    |                                                                                                                     |
|                                                                                                                     |                                                                                                                    |                                                                                                                     |
+---------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+