1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree

Description

Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.

Find all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.

Note that you can return the indices of the edges in any order.

Example 1:

Example 2:

Constraints:

  • 2 <= n <= 100

  • 1 <= edges.length <= min(200, n * (n - 1) / 2)

  • edges[i].length == 3

  • 0 <= ai < bi < n

  • 1 <= weighti <= 1000

  • All pairs (ai, bi) are distinct.

ac

Last updated

Was this helpful?