diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java index 8bd6310..af56ad6 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java @@ -10,6 +10,9 @@ import java.util.Map; import java.util.Set; +/** + * {@link CallGraph} is a directed graph that represents the control flow between resources + */ public class CallGraph extends DirectedGraph { protected Map statefulObjMap; @@ -17,6 +20,11 @@ statefulObjMap = new HashMap<>(); } + /** + * Add a node to the graph. + * + * @param node The node to be added. + */ public void addNode(Node node) { if (node instanceof ResourceNode) { ResourceNode resNode = (ResourceNode) node; @@ -37,12 +45,27 @@ } } + /** + * Add new call edge from {@code srcResNode} to {@code dstResNode} with PUSH / PULL selection. + * + * @param srcResNode The resource node the edge starts from. + * @param dstResNode The resource node the edge ends at. + * @param selectedOption PUSH / PULL + */ public void addEdge(ResourceNode srcResNode, ResourceNode dstResNode, PushPullValue selectedOption) { addNode(srcResNode); addNode(dstResNode); addEdge(new CallEdge(getStatefulObjectNode(srcResNode), getStatefulObjectNode(dstResNode), selectedOption)); } + /** + * Insert an edge into the graph. + * + * @param srcObjNode The source node of the edge to be inserted + * @param dstObjNode The destination node of the edge to be inserted + * @param selectedOption PUSH or PULL + * @param n The calling order of the edge + */ public void insertEdge(ObjectNode srcObjNode, ObjectNode dstObjNode, PushPullValue selectedOption, int n) { CallEdge edge = new CallEdge(srcObjNode, dstObjNode, selectedOption); simpleAddEdge(edge); @@ -59,7 +82,7 @@ public Set getRootNodes() { Set roots = new HashSet<>(getNodes()); for (Node n : getNodes()) { - roots.removeAll(n.getSuccessors()); + roots.removeAll(n.getSuccessors()); // Remove all child nodes of each node in the graph } return roots; }