Overview

Currently, the following data structures are implemented:

Graph

Tree

StateMachine

%%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%% graph LR A(A); B(B); C(C); D(D); E(E); F(F) ; G(G); H(H); I(I) A --> B --> E G --> F A --> C --> G --> H --> D D -.-> A D & F -.-> B I ---> E --> F --> D 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;

A directed graph with backward-edges denoted by dotted vertex relations.

%%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%% graph TD R(Root) A(...) BL(Node); B(GrandParent); BR(Node) CL(Uncle); C(Parent); CR(Aunt) DL(Sibling); D(Node); DR(Sibling) ELN1(Niece); ELN2(Nephew) EL(Child); E(Child); ER(Child); ERN1(Niece);ERN2(Nephew) F1(GrandChild); F2(GrandChild) R:::mark1 --> A A --> BL & B & BR 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;

Root of the current node are marked in blue.

%%{init: { "flowchart": { "nodeSpacing": 15, "rankSpacing": 30, "curve": "linear", "useMaxWidth": false } } }%% graph TD A(Idle); B(Check); C(Prepare); D(Read); E(Finished); F(Write) ; G(Retry); H(WriteWait); I(ReadWait) A:::mark1 --> B --> C --> F F --> H --> E:::cur B --> G --> B G -.-> A --> C D -.-> A C ---> D --> I --> E -.-> A classDef node fill:#eee,stroke:#777,font-size:smaller; classDef cur fill:#9e9,stroke:#6e6; classDef mark1 fill:#69f,stroke:#37f,color:#eee;

A statemachine graph.

from pyTooling.Graph import Graph

graph = Graph(name="Example Graph")

# Create a standalone vertex A in the graph
rootA = Vertex(value="A", graph=graph)

# Add 2 vertices B,C and add edges from A
edgeAB = rootA.EdgeToNewVertex(vertexValue="B")
edgeAC = rootA.EdgeToNewVertex(vertexValue="C")

# Get vertices B,C
vertexB = edgeAB.Destination
vertexC = edgeAC.Destination

# Add more standalone vertices D,E,F,G
vertexD = Vertex(value="D", graph=graph)
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"))
from pyTooling.Tree import Node

root = Node(id="Root")

dir1 = Node(id="Dir1", parent=root)
dir2 = Node(id="Dir2", parent=root)
file0 = Node(id="File0", parent=root)
dir3 = Node(id="Dir3", parent=root)

file1 = Node(id="File1", parent=dir1)
file2 = Node(id="File2", parent=dir1)
file3 = Node(id="File3", parent=dir1)

file4 = Node(id="File4", parent=dir2)

file5 = Node(id="File5", parent=dir3)
file6 = Node(id="File6", parent=dir3)
from pyTooling.StateMachine import FSM, State