I think u didn’t go through the link contain correct explaination why the time complexity of dfs and bfs is O(v+e) hope this help

DFS(analysis):

*Setting/getting a vertex/edge label takes O(1) time

*Each vertex is labeled twice

->once as UNEXPLORED

->once as VISITED

*Each edge is labeled twice

->once as UNEXPLORED

->once as DISCOVERY or BACK

*Method incidentEdges is called once for each vertex

*DFS runs in O(n + m) time provided the graph is represented by the adjacency list structure

*Recall that Σv deg(v) = 2m

BFS(analysis):

*Setting/getting a vertex/edge label takes O(1) time

*Each vertex is labeled twice

–>once as UNEXPLORED

–>once as VISITED

*Each edge is labeled twice

–>once as UNEXPLORED

–>once as DISCOVERY or CROSS

*Each vertex is inserted once into a sequence Li

*Method incidentEdges is called once for each vertex

*BFS runs in O(n + m) time provided the graph is represented by the adjacency list structure

*Recall that Σv deg(v) = 2m