better documentation for edge types #996
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We get (automatically generated):
This document was generated automatically from '/home/limerent/GitHub/phd/flowr/src/documentation/print-dataflow-graph-wiki.ts' on 2024-09-19, 20:55:33 UTC presenting an overview of flowR's dataflow graph (version: 2.0.25, samples generated with R version 4.4.1).
This page briefly summarizes flowR's dataflow graph, represented by DataflowGraph in
./src/dataflow/graph/graph.ts
.In case you want to manually build such a graph (e.g., for testing), you can use the builder in
./src/dataflow/graph/dataflowgraph-builder.ts
.This wiki page focuses on explaining what such a dataflow graph looks like!
R Code of the Dataflow Graph
The analysis required 11.22 ms (including parsing and normalization) within the generation environment.
Mermaid Code (without markings)
The above dataflow graph showcases the general gist. We define a dataflow graph as a directed graph$G = (V, E)$ , differentiating between 5 types of vertices $V$ and$E$ allowing each vertex to have a single, and each edge to have multiple distinct types.
18 types of edges
Vertex Types
The following vertices types exist:
Value
Use
FunctionCall
VariableDefinition
FunctionDefinition
Edge Types
The following edges types exist, internally we use bitmasks to represent multiple types in a compact form:
Reads
($1$)DefinedBy
($2$)Calls
($4$)Returns
($8$)DefinesOnCall
($16$)DefinedByOnCall
($32$)Argument
($64$)SideEffectOnCall
($128$)NonStandardEvaluation
($256$)From an implementation perspective all of these types are represented by respective interfaces, see
./src/dataflow/graph/vertex.ts
and./src/dataflow/graph/edge.ts
.The following sections present details on the different types of vertices and edges, including examples and explanations.
Vertices
1) Value Vertex
Type:
value
R Code of the Dataflow Graph
The analysis required 1.48 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
42
Mermaid Code (without markings)
Describes a constant value (numbers, logicals, strings, ...)
2) Use Vertex
Type:
use
R Code of the Dataflow Graph
The analysis required 1.20 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
x
Mermaid Code (without markings)
Describes symbol/variable references
3) Function Call Vertex
Type:
function-call
R Code of the Dataflow Graph
The analysis required 1.49 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 1.
Mermaid Code (without markings)
Describes any kind of function call, these can happen implicitly as well! (see the notable cases)
Interesting Case
Built-In Function Call
R Code of the Dataflow Graph
The analysis required 1.51 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3.
Mermaid Code (without markings)
Control structures like
if
are desugared into function calls (we omit the arguments ofif
(TRUE, 1) for simplicity).4) Variable Definition Vertex
Type:
variable-definition
R Code of the Dataflow Graph
The analysis required 1.40 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
Mermaid Code (without markings)
Describes a defined variable. Not just
<-
causes this!Interesting Case
Globally Defined Variable
R Code of the Dataflow Graph
The analysis required 1.70 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0.
Mermaid Code (without markings)
Are described similar within the dataflow graph, only the active environment differs.
5) Function Definition Vertex
Type:
function-definition
R Code of the Dataflow Graph
The analysis required 1.15 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 2.
Mermaid Code (without markings)
Describes a function definition. Are always anonymous at first; although they can be bound to a name, the id
0
refers to the1
in the body. The presented subgraph refers to the body of the function, marking exit points and open references.Edges
1) Reads Edge
Type:
1
R Code of the Dataflow Graph
The analysis required 1.46 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 4->0.
Mermaid Code (without markings)
The source vertex is usually a
use
that reads from the respective target definition.Interesting Cases
Reads Edge (Call)
R Code of the Dataflow Graph
The analysis required 1.62 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 7->0.
Mermaid Code (without markings)
Named calls are resolved too, linking to the symbol that holds the anonymous function definition (indirectly or directly)
Reads Edge (Parameter)
R Code of the Dataflow Graph
The analysis required 1.45 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 4->1.
Mermaid Code (without markings)
Parameters can read from each other as well.
2) DefinedBy Edge
Type:
2
R Code of the Dataflow Graph
The analysis required 1.08 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->1, 0->2.
Mermaid Code (without markings)
The source vertex is usually a
define variable
that is defined by the respective target use. However, nested definitions can carry it (in the nested case,x
is defined by the return value of<-
(y, z)). Additionally, we link the assignment.Interesting Cases
DefinedBy Edge (Nested)
R Code of the Dataflow Graph
The analysis required 1.33 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->4, 0->3, 1->3.
Mermaid Code (without markings)
Nested definitions can carry the
defined by
edge as well.DefinedBy Edge (Expression)
R Code of the Dataflow Graph
The analysis required 1.29 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 0->3.
Mermaid Code (without markings)
Here, we define by the result of the
+
expression.3) Calls Edge
Type:
4
R Code of the Dataflow Graph
The analysis required 1.52 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 7->4.
Mermaid Code (without markings)
Link the function call to the (anonymous) function definition.
4) Returns Edge
Type:
8
R Code of the Dataflow Graph
The analysis required 1.63 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 6->1.
Mermaid Code (without markings)
Link the function call to the exit points of the target definition (this may incorporate the call-context).
5) DefinesOnCall Edge
Type:
16
R Code of the Dataflow Graph
The analysis required 1.95 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
Mermaid Code (without markings)
This edge is automatically joined with defined by on call!
Link an Argument to whichever parameter they cause to be defined if the related function call is invoked.
6) DefinedByOnCall Edge
Type:
32
R Code of the Dataflow Graph
The analysis required 1.92 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 11->1, 1->11.
Mermaid Code (without markings)
This edge is automatically joined with defines on call!
This represents the other direction of
defines on call
(i.e., links the parameter to the argument). This is just for completeness.7) Argument Edge
Type:
64
R Code of the Dataflow Graph
The analysis required 1.39 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 5->1, 5->3.
Mermaid Code (without markings)
Links a function call to the entry point of its arguments. If we do not know the target of such a call, we automatically assume that all arguments are read by the call as well!
8) SideEffectOnCall Edge
Type:
128
R Code of the Dataflow Graph
The analysis required 1.98 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3->10.
Mermaid Code (without markings)
Links a global side effect to an affected function call (e.g., a super definition within the function body)
9) NonStandardEvaluation Edge
Type:
256
R Code of the Dataflow Graph
The analysis required 1.34 ms (including parsing and normalization) within the generation environment.
The following marks are used in the graph to highlight sub-parts (uses ids): 3->1.
quote(x)
Mermaid Code (without markings)
Marks cases in which R's non-standard evaluation mechanisms cause the default semantics to deviate