![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
A graph with vertices that are Reactors (not ReactorInstances) and edges that denote dependencies between them. More...
Inherits org.lflang.graph.PrecedenceGraph< Reactor >.
Public Member Functions | |
| void | addEdge (T sink, T source) |
| Add a new directed edge to the graph. | |
| void | addEdges (T sink, List< T > sources) |
| Add new directed edges to the graph. | |
| void | addNode (T node) |
| Add the given node to the graph. | |
| void | clear () |
| DirectedGraph< T > | copy () |
| Obtain a copy of this graph by creating an new instance and copying the adjacency maps. | |
| void | detectCycles () |
| Run Tarjan's algorithm for finding strongly connected components. | |
| int | edgeCount () |
| Return the number of directed edges in this graph. | |
| List< Set< T > > | getCycles () |
| Return a list of strongly connected components that exist in this graph. | |
| Set< ReactorDecl > | getDeclarations (final Reactor definition) |
| Return the declarations that point to a given reactor definition. | |
| Set< T > | getDownstreamAdjacentNodes (T node) |
| Return all immediate downstream neighbors of a given node. | |
| Set< Instantiation > | getInstantiations (final Reactor definition) |
| Return the instantiations that point to a given reactor definition. | |
| List< Reactor > | getReactors () |
| Return the reactor definitions referenced by instantiations in this graph ordered topologically. | |
| Set< T > | getUpstreamAdjacentNodes (T node) |
| Return all immediate upstream neighbors of a given node. | |
| void | graphChanged () |
| Invalidate cached analysis due to changes in the graph structure. | |
| boolean | hasCycles () |
| Report whether this graph has any cycles in it. | |
| boolean | hasNode (T node) |
| Return true if this graph has the given node in it. | |
| InstantiationGraph (final Model model, final boolean detectCycles) | |
| Construct an instantiation graph based on the given AST and, if the detectCycles argument is true, run Tarjan's algorithm to detect cyclic dependencies between instantiations. | |
| InstantiationGraph (final Resource resource, final boolean detectCycles) | |
| Construct an instantiation graph based on the given AST and, if the detectCycles argument is true, run Tarjan's algorithm to detect cyclic dependencies between instantiations. | |
| Set< T > | leafNodes () |
| Return the leaf nodes of this graph. | |
| void | merge (DirectedGraph< T > another) |
| Merge another directed graph into this one. | |
| int | nodeCount () |
| Return the number of nodes in this graph. | |
| Set< T > | nodes () |
| Return an unmodifiable set of nodes in this graph. | |
| List< T > | nodesInReverseTopologicalOrder () |
| Return the nodes of this graph in reverse topological order. | |
| List< T > | nodesInTopologicalOrder () |
| Return the nodes of this graph in reverse topological order. | |
| void | removeEdge (T sink, T source) |
| Remove a directed edge from the graph. | |
| void | removeNode (T node) |
| Remove the given node from the graph. | |
| Set< T > | rootNodes () |
| Return the root nodes of this graph. | |
| void | strongConnect (T node) |
| Traverse the graph to visit unvisited dependencies and determine whether they are part of a cycle. | |
| String | toDOT () |
| Return the DOT (GraphViz) representation of the graph. | |
| String | toString () |
| Return a textual list of the nodes. | |
Protected Attributes | |
| List< Set< T > > | cycles |
| After analysis has completed, this list contains all all sets of nodes that are part of the same strongly connected component. | |
| final HashMultimap< Reactor, ReactorDecl > | reactorToDecl = HashMultimap.create() |
| A mapping from reactor classes to their declarations. | |
| final HashMultimap< Reactor, Instantiation > | reactorToInstantiation |
| A mapping from reactors to the sites of their instantiation. | |
A graph with vertices that are Reactors (not ReactorInstances) and edges that denote dependencies between them.
A "dependency" from reactor class A to reactor class B (A depends on B) means that A instantiates within it at least one instance of B. Note that there a potentially confusing and subtle distinction here between an "instantiation" and an "instance". They are not the same thing at all. An "instantiation" is an AST node representing a statement like a = new A();. This can result in many instances of reactor class A (if the containing reactor class is instantiated multiple times).
In addition to the graph, this class keeps track of the instantiations that induce the dependencies. These can be retrieved using the method getInstantiations(Reactor).
| org.lflang.graph.InstantiationGraph.InstantiationGraph | ( | final Resource | resource, |
| final boolean | detectCycles ) |
Construct an instantiation graph based on the given AST and, if the detectCycles argument is true, run Tarjan's algorithm to detect cyclic dependencies between instantiations.
| resource | The resource associated with the AST. |
| detectCycles | Whether or not to detect cycles. |
| org.lflang.graph.InstantiationGraph.InstantiationGraph | ( | final Model | model, |
| final boolean | detectCycles ) |
Construct an instantiation graph based on the given AST and, if the detectCycles argument is true, run Tarjan's algorithm to detect cyclic dependencies between instantiations.
| model | The root of the AST. |
| detectCycles | Whether or not to detect cycles. |
|
inherited |
Add a new directed edge to the graph.
The first argument is the downstream node, the second argument the upstream node. If either argument is null, do nothing.
| sink | The downstream immediate neighbor. |
| source | The upstream immediate neighbor. |
|
inherited |
Add new directed edges to the graph.
The first argument is the downstream node, the second argument a set of upstream nodes.
| sink | The downstream immediate neighbor. |
| sources | The upstream immediate neighbors. |
|
inherited |
Add the given node to the graph.
|
inherited |
|
inherited |
Obtain a copy of this graph by creating an new instance and copying the adjacency maps.
|
inherited |
Run Tarjan's algorithm for finding strongly connected components.
After invoking this method, the detected cycles with be listed in the class variable cycles.
|
inherited |
Return the number of directed edges in this graph.
|
inherited |
Return a list of strongly connected components that exist in this graph.
| Set< ReactorDecl > org.lflang.graph.InstantiationGraph.getDeclarations | ( | final Reactor | definition | ) |
Return the declarations that point to a given reactor definition.
A declaration is either a reactor definition or an import statement.
|
inherited |
Return all immediate downstream neighbors of a given node.
| node | The node to report the immediate downstream neighbors of. |
| Set< Instantiation > org.lflang.graph.InstantiationGraph.getInstantiations | ( | final Reactor | definition | ) |
Return the instantiations that point to a given reactor definition.
If none are known, returns an empty set. * The returned set may be unmodifiable.
| List< Reactor > org.lflang.graph.InstantiationGraph.getReactors | ( | ) |
Return the reactor definitions referenced by instantiations in this graph ordered topologically.
Each reactor in the returned list is preceded by any reactors that it may instantiate.
|
inherited |
Return all immediate upstream neighbors of a given node.
| node | The node to report the immediate upstream neighbors of. |
|
inherited |
Invalidate cached analysis due to changes in the graph structure.
|
inherited |
Report whether this graph has any cycles in it.
|
inherited |
Return true if this graph has the given node in it.
| node | The node to look for. |
|
inherited |
Return the leaf nodes of this graph.
Leaf nodes have no downstream neighbors.
|
inherited |
Merge another directed graph into this one.
| another | The graph to merge into this one. |
|
inherited |
Return the number of nodes in this graph.
|
inherited |
Return an unmodifiable set of nodes in this graph.
|
inherited |
Return the nodes of this graph in reverse topological order.
Each node in the returned list is succeeded by the nodes that it depends on.
|
inherited |
Return the nodes of this graph in reverse topological order.
Each node in the returned list is preceded by the nodes that it depends on.
|
inherited |
Remove a directed edge from the graph.
| sink | The downstream immediate neighbor. |
| source | The upstream immediate neighbor. |
|
inherited |
Remove the given node from the graph.
This also eliminates any edges from upstream and to downstream neighbors of this node.
| node | The node to remove. |
|
inherited |
Return the root nodes of this graph.
Root nodes have no upstream neighbors.
|
inherited |
Traverse the graph to visit unvisited dependencies and determine whether they are part of a cycle.
|
inherited |
Return the DOT (GraphViz) representation of the graph.
|
inherited |
Return a textual list of the nodes.
|
protectedinherited |
After analysis has completed, this list contains all all sets of nodes that are part of the same strongly connected component.
|
protected |
A mapping from reactor classes to their declarations.
|
protected |
A mapping from reactors to the sites of their instantiation.