Thanx!
Moderator: Board moderators
Bilash wrote:Is finding cactus related to finding articulation points in a directed graph anyway? i think in a cactus, the simple cycles are connected to each other only through articulation vertices. i tried in this way, but still WA![]()
Can anybody tell me the correct approach to solving this problem?

horape wrote:Bilash wrote:Is finding cactus related to finding articulation points in a directed graph anyway? i think in a cactus, the simple cycles are connected to each other only through articulation vertices. i tried in this way, but still WA![]()
Can anybody tell me the correct approach to solving this problem?
This is what I did... DFS, checking that there is exactly one back edge from any node that isn't root, no cross/forward edges (and that for each tree edge, dfsmin of the other end of the edge is the current node.
Saludos,
HoraPe
junbin wrote:horape wrote:Bilash wrote:Is finding cactus related to finding articulation points in a directed graph anyway? i think in a cactus, the simple cycles are connected to each other only through articulation vertices. i tried in this way, but still WA![]()
Can anybody tell me the correct approach to solving this problem?
This is what I did... DFS, checking that there is exactly one back edge from any node that isn't root, no cross/forward edges (and that for each tree edge, dfsmin of the other end of the edge is the current node)
I'm not very good at graph theory... what do you mean by cross/forward edge?

3
6
7
0 1
3 0
1 2
2 3
1 3
4 5
2 4
1
1
0 0
5
7
0 1
1 2
2 3
3 0
0 2
2 4
4 0
Examiner wrote:
- Code: Select all
3
6
7
0 1
3 0
1 2
2 3
1 3
4 5
2 4
1
1
0 0
5
7
0 1
1 2
2 3
3 0
0 2
2 4
4 0
marian wrote:Second possible solution can be repeatedly remove simple directed cycles. If graph contains some edges, but does not contain a cycle, it is not a cactus. If we successfully remove all the edges, given graph is a cactus. (because removed cycles had to be edge-disjoint (otherwise we could not remove some cycle)). I think, that by careful implementation, this could be done in O(n+m), too.
1
3
6
0 1
1 0
1 2
2 1
2 0
0 2
Bilash wrote:
At last I got it AC
What i did is check that:
1. The indegree is equal to the out degree for each vertex
2. There is no forward or cross edge in the dfs tree of the graph
3. There is at most one back edge pointing to any particular vertex in the dfs tree.
By the way, i checked strong connectivity using Shorir's algo whose complexity is O(n).

1
4
5
0 1
1 2
2 1
2 3
3 0Navid666 wrote:my code seems to be correct but still gettin WA
please give me some input/output... please !!!
thanks a lot...

1
4
4
0 1
1 0
2 3
3 2
Users browsing this forum: No registered users and 1 guest