Critcal structues GYM question

Revision en13, by L_lawliet27, 2020-12-20 13:05:30

Me and my teammate maverick16 were doing the Problem I.Critical Structures, in this Problem set and this is the CF Problem page.

In this problem, we are given a connected graph G and the following terminologies are defined:- 1. Critical node: a node in G whose removal disconnects G. 2. Critical link: an edge in G whose removal disconnects G. 3. Critical component: a maximal set of edges in G such that any two edges in the set lie on a common cycle (A cycle is a set of nodes ⟨v0, v1, . . . , v k−1 ⟩, where k ≥ 4, such that any two consecutive vi−1 and vi for 1 ≤ i ≤ k − 1 have an edge, v0 = vk−1 and vi for 0 ≤ i ≤ k −2 are all distinct. 4. Largest critical component: a critical component with the maximum number of edges.

We are asked to find the number of critical nodes, critical link, p and q, where p/q is of irreducible form and p and q are defined as:- - p is the number of critical components in the graph - q is the number of edges in the largest critical component

Our approach to this problem is :

find all the bridges and cut vertices first, remove all the bridges. now apply dfs through individual component and count the edges in that component, we divided this into two cases from here:-

  1. there a single cut vertex in the component remove it and count both components (components separated by cut vertex) as different
  2. else take the complete component as a single critical component

p will be the number of components counted with this dfs + bridges and q will be max edges in a component.

But, this approach should fail, when the graph looks like this, however it passed all tests, can anyone help with this?

Expected Output
Our Output
Our implementation

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en19 English L_lawliet27 2020-12-20 14:45:19 1 (published)
en18 English L_lawliet27 2020-12-20 14:12:13 880 Tiny change: '6.png)\n\n' -> '6.png)\n\n<spoiler summary="try">\ngandu</spoiler>'
en17 English L_lawliet27 2020-12-20 13:22:02 6316 Reverted to en15
en16 English L_lawliet27 2020-12-20 13:21:27 6316 Tiny change: '6.png)\n\n' -> '6.png)\n\n<spoiler summary="Expected Output">\n...\n</spoiler>\n'
en15 English L_lawliet27 2020-12-20 13:07:24 871 Reverted to en12
en14 English L_lawliet27 2020-12-20 13:06:26 6
en13 English L_lawliet27 2020-12-20 13:05:30 865 (saved to drafts)
en12 English L_lawliet27 2020-12-20 10:19:07 0 (published)
en11 English L_lawliet27 2020-12-20 09:55:32 17 Tiny change: ' bridges\nq will b' -> ' bridges\n\nq will b'
en10 English L_lawliet27 2020-12-20 09:52:54 115
en9 English L_lawliet27 2020-12-20 09:30:09 121 Tiny change: 'this algo must fail according to us, when the' -> 'this algo should fail, when the'
en8 English L_lawliet27 2020-12-20 09:23:36 3765
en7 English L_lawliet27 2020-12-20 09:16:50 36
en6 English L_lawliet27 2020-12-20 09:16:11 3754 Tiny change: 'n">\n...\n</spoiler>\nsadfsdf\n' -> 'n">\n...\n...\n</spoiler>\n'
en5 English L_lawliet27 2020-12-19 21:35:16 22
en4 English L_lawliet27 2020-12-19 21:33:20 10 Tiny change: 'n">\n...\n\n~~~~~\n#' -> 'n">\n...\n~~~~~\n#'
en3 English L_lawliet27 2020-12-19 21:27:57 22
en2 English L_lawliet27 2020-12-19 21:05:13 12
en1 English L_lawliet27 2020-12-19 20:51:52 4835 Initial revision (saved to drafts)