Skip to content
← All questions

Why is edge B-E skipped even though it has weight 3?

Edge B-E is skipped because both of its endpoints (B and E) are already in the visited set (MST). Prim's algorithm only considers edges that connect a visited vertex to an unvisited vertex to avoid creating cycles.

Conditions

  • Both endpoints of the edge are already marked as visited.
  • The algorithm strictly follows the rule of adding only crossing edges.

Reasoning, step by step

  1. Check the status of both endpoints of edge B-E.
  2. Observe that both B and E are in the 'visited' list.
  3. Conclude that adding B-E would create a cycle within the current tree.
  4. Discard B-E and look for the next smallest edge connecting to an unvisited node.

Example

The narrator explains, "Notice at this point, the edge BE with a weight of 3 is the smallest edge. But both vertices are already in the MST, so we do not pick it."

Common misconceptions

  • Thinking that the smallest available edge is always chosen, regardless of endpoint status.
  • Believing that skipping internal edges is optional.
  • Confusing Prim's algorithm with Kruskal's, which sorts all edges globally.

Watch the explanation

Connected concepts

Explore next

Related questions

Meet the concept

↗
Meet the concept

↗

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.