Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:31:27+00:00 2026-06-15T08:31:27+00:00

I have a graph represented with adjacency lists and his MST represented by parent

  • 0

I have a graph represented with adjacency lists and his MST represented by parent array.

My problem is that I need to delete an edge from the graph and update parent array.

I’ve already manage to do the cases when:

  1. the edge doesn’t exist;
  2. the edge is in graph but not in MST (MST doesn’t change);
  3. and the edge is the only path from two nodes(in this case I return null, because the
    graph is not connected).

What can I do when the edge is in MST and the edge in graph is in a cycle? I need to do this in O(n+m) complexity.

I write the costs of edges with red color.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:31:28+00:00Added an answer on June 15, 2026 at 8:31 am

    Just search the minimum-distance path of
    the now-disconnected tree portion
    to the rest of the tree and
    add that path in between– which is a single edge.

    Say your original tree is T. With the removal
    of the edge, it is now split into trees T1 and T2.

    Take one of these– say T2.
    Every edge incident to a node on T2 is either
    on T2 or is one connecting T2 to T1. Among these
    edges incident to a node on T2, pick the one which
    ( (has its other end at a T1 node) and
    (has the minimum cost among all such edges) ).
    Search for this edge, say e=(u,v), takes O(|E|) time. O(|N|) if the separated portion is a leaf.

    if there were a tree, say T’, with less cost than T1 \union T2 \union {e},
    then the node sets N1 and N2 of T1 and T2 would have more inter-connections than just one edge,

    i.e., there would be two or more more edges on T’ that begin at a node in N1 and end at a node in N2.
    Otherwise, ( (T1 and T2 are minimum spanning trees resply. over N1 and N2) and (e is the least costly
    connection between T1 and T2) ) would be false. But then, any go-between T1 and T2 is costlier than e=(u,v)– contradicts.

    Skipped some proof details. hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an undirected graph represented by an adjacency matrix. I need a high
I have a dependency graph that I have represented as a Map<Node, Collection<Node>> (in
I have an undirected graph represented as an adjacency matrix of Euclidean weights. I'm
Suppose I have two columns in a table that represents a graph, the first
I have a graph representing users and some articles they wrote. I need to
I have a graph that contains nodes (groups) composed by inner nodes and when
I have a graph with n nodes as an adjacency matrix . Is it
I have currently the following setup: An object graph of all requests read from
I have next code that represents graph edges and nodes (simplified for question): public
I am using adjacency lists to represent a directed weighted graph and based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.