HThinh's blog

By HThinh, history, 3 hours ago, In English

given a directed graph with n nodes and m edges. find all edges that are present in every cycle of the graph

constraints: n<=1000 m<=20000 TL: 0.9s

  • Vote: I like it
  • -2
  • Vote: I do not like it

»
69 minutes ago, # |
  Vote: I like it +6 Vote: I do not like it

Given the low n, we should be considering O(nm) solutions

Find any cycle (if there isn't any then the answer is an empty set). The number of edges in this cycle is not greater than n. Then, for each edge in the cycle, remove it and try to find another cycle. If you don't find one, then that edge was present in every cycle.