Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook on minimum spanning tree using Prim's algorithm #74

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

NikitaSharma1
Copy link

No description provided.

@NikitaSharma1
Copy link
Author

@MridulS @rossbar can you please have a look at this notebook ? Also, should I add Kruskal's algorithm in this notebook only or make a separate notebook for it?

@NikitaSharma1
Copy link
Author

It was passing the checks before but now It's throwing error... idk why

@MridulS
Copy link
Member

MridulS commented Apr 29, 2022

No worries, this is broken because of #76
Should be fixed once that is merged in.

@NikitaSharma1
Copy link
Author

@MridulS Thank you!!

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @NikitaSharma1 , this is a very nice notebook and IMO the minimum spanning tree is an excellent application to highlight. I really like the motivating example too, i.e. optimal route planning between cities.

While reading through the example though, I did have one high-level question - for the given application, wouldn't you want to start with the complete graph with an edge between each city weighted by the linear distance between the two cities? I realize this isn't a necessary condition for finding the minimum spanning tree, but for the application of finding the optimal road layout between 5 cities, you'd definitely want to consider the possible routes between each pair of cities. Does this sound right?

@NikitaSharma1
Copy link
Author

@rossbar I totally agree with your point. I was thinking of making it as simple as possible with all situations covered, so, maybe that's why it slipped out of my mind. Would you suggest improvising the example and replacing the optimal route problem with a generalized example, like points A, B, C, D, and E instead of cities, or adding more edges to the example to make it a complete graph?

@dschult
Copy link
Member

dschult commented Jun 18, 2022

The route finding problem is the “traveling salesman problem”. And it shouldn’t be a tree. It finds the best path. A tree is rarely a path. But here’s a better setting that makes sense from a spanning tree perspective. Suppose you are trying to lay out the pipes for a gas distribution system. You can connect each city to other cities, but you want to find the tree that minimizes the total pipe length. So, unlike our traveler who has to continue from wherever their last position was, the tree can be extended from any point on the already built portion of the tree.

There must be other settings for the spanning trees — and I’m sure some of them do not start with a complete graph. But this gas pipeline tree setting does still have that complete graph information. I just wanted to separate the “best route” problem from the “best tree” problem.

Can someone come up with a setting that doesn’t start with a complete graph?

@dschult
Copy link
Member

dschult commented Jun 18, 2022

Wikipedia gives some examples that might help.
suppose you are laying down a new electric grid for a town. It is only feasible to build the route along existing roads, so you start with a road network. Then you want to build the least expensive tree of wires that serves all the customers. Of course in reality, you’d like redundancy to avoid outages. But the minimum spanning tree is a good starting place for laying down wire. And the restriction that you only put wire along roads means you start with a network rather than a complete graph.
;)

@PurviChaurasia
Copy link

Hi, I opened a issue regarding this #101 I will take into account all suggestions given here and will be constructing the notebook, thanks!

@rossbar
Copy link
Contributor

rossbar commented Apr 9, 2023

@NikitaSharma1 are you still planning to work on this? If so, I think the place to (re)start would be by updating the motivating example per feedback from the previous review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants