# Tag Info

0

I'm assuming that the problem is as follows. You're given the (ordered) list of edges in the input file and you read them one at a time and add them to the graph. You must stop as soon as the graph you've built is connected. In that case, a simple $O(n^2)$ solution is to label each vertex with an integer that indicates what component it's in. Initially, the ...

1

I think an even better approach is the solution on C# which I developed for similar problem - https://github.com/kostadinmarinov/scc dfs(verticies, getNeighbours): visited <- {} return recursiveSelect( filter(verticies, (vertex): visited does not contain vertex), (vertex): dfsNext(vertex, visited, getNeighbours)) dfsNext(vertex, ...

2

You can have a look on DFS-B in http://web.cs.unlv.edu/larmore/Courses/CSC477/bfsDfs.pdf DFS-A can have multiple copies on the stack at the same time. However, the total number of iterations of the innermost loop of DFS-A cannot exceed the number of edges of G, and thus the size of S cannot exceed m. The running time of DFS-A is O(n + m). It is ...

0

Assuming the graph has no cycles in it, the graph is hence a tree. Since in a tree, there is a unique path between two vertices, we will never encounter a visited vertex and hence our algorithm will not detect a cycle. Now assuming there is at least one cycle in the graph. Consider the set $S$ of vertices, that belong to a cycle and have the least possible ...

-1

I personally, do not see why this is left as unanswered. Finding something in complement graph and finding that same thing in the graph is essentially have the same time complexity (up to constant factor). Since swapping between edge $(u,v)$ and non-edge $(u,v)$ is just $O(1)$-time operation. We do not have to transform or convert anything just negate ...

Top 50 recent answers are included