I'm doing a project. I need to calculate the complexity of a recursive method. This method is called recursively and uses methods "incomingEdges" and "opposite". Can someone help me to find the complexity of "FUNCTION" method?
public HashMap<String, Integer[]> FUNCTION() {
HashMap<String, Integer[]> times = new HashMap<>();
Integer[] timesAct = new Integer[5];
boolean[] visited = new boolean[graphPertCpm.numVertices()];
Vertex<Activity, String> current = graphPertCpm.getVertex(0);
timesAct[0] = 0;
timesAct[1] = 0;
times.put(current.getElement().getKeyId(), timesAct);
FUNCTION(current, times, visited);
return times;
}
private void FUNCTION(Vertex<Activity, String> current, HashMap<String, Integer[]> times, boolean[] visited) {
if (times.get(current.getElement().getKeyId()) == null) {
for (Edge<Activity, String> inc : graphPertCpm.incomingEdges(current)) {
Vertex<Activity, String> vAdj = graphPertCpm.opposite(current, inc);
FUNCTION(vAdj, times, visited);
}
}
visited[current.getKey()] = true;
for (Entry<Vertex<Activity, String>, Edge<Activity, String>> outs : current.getOutgoing().entrySet()) {
if (!visited[outs.getKey().getKey()]) {
int maxEF = 0;
Vertex<Activity, String> vAdj = graphPertCpm.opposite(current, outs.getValue());
for (Edge<Activity, String> inc : graphPertCpm.incomingEdges(outs.getKey())) {
Integer[] timesAct = times.get(graphPertCpm.opposite(outs.getKey(), inc).getElement().getKeyId());
if (timesAct == null) {
vAdj = graphPertCpm.opposite(vAdj, inc);
FUNCTION(vAdj, times, visited);
} else {
if (timesAct[1] > maxEF) {
maxEF = timesAct[1];
}
}
}
Integer[] timesAct = new Integer[5];
timesAct[0] = maxEF;
timesAct[1] = timesAct[0] + outs.getKey().getElement().getDuration();
times.put(outs.getKey().getElement().getKeyId(), timesAct);
if (visited[vAdj.getKey()] != true) {
FUNCTION(vAdj, times, visited);
}
}
}
visited[current.getKey()] = false;
}
Opposite Method
public Vertex<V, E> opposite(Vertex<V, E> vert, Edge<V, E> e) {
if (e.getVDest() == vert) {
return e.getVOrig();
} else if (e.getVOrig() == vert) {
return e.getVDest();
}
return null;
}
IncomingEdges Method
public Iterable<Edge<V, E>> incomingEdges(Vertex<V, E> v) {
Edge e;
ArrayList<Edge<V, E>> edges = new ArrayList<>();
for (int i = 0; i < numVert; i++) {
for (int j = 0; j < numVert; j++) {
e = getEdge(getVertex(i), getVertex(j));
if (e != null && e.getVDest() == v) {
edges.add(e);
}
}
}
return edges;
}

