-
Notifications
You must be signed in to change notification settings - Fork 69
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
Minimum Spanning Tree for labelled graphs #187
Comments
After thinking about the simple typesafe representation. Even given that property, we need to stop the user of the API to try and Maybe just trying to compute a MST with as much edges as possible would be best then. |
@TheChouzanOne I think it's useful to have both the MST algorithm returning mst :: (Ord a, Ord e) => AdjacencyMap e a -> Maybe (Tree a)
mst x = case msf x of
[t] -> Just t
_ -> Nothing
msf :: (Ord a, Ord e) => AdjacencyMap e a -> Forest a
msf = ... One aspect which is not clear to me is how to capture edge labels in the resulting trees and forests. Perhaps, we need custom data types for labelled trees and forests, i.e. |
@snowleopard I totally forgot about the lack of labels for The first idea that comes to my mind is to slightly change the structure of
where I am not sure how difficult it would be to mimic |
Update: I implemented a simple starting kruskall algorithm which can handle connected and unconnected graphs. The thing is that it just returns an The current API for the function is
It takes a function to determine how to choose edges and an If you want to take a closer look, here's the code. |
@TheChouzanOne Yes, I think we'll need to add a module like I don't understand why you ask both for dictionary |
I will start thinking about that concern then.
This function is just a starting point and might help to build the actual |
I want to start thinking how to generate a Minimum Spanning Tree. However, a big problem is stopping me.
Both Kruskall and Prim assume that the graph is connected, however, it doesn't seem to be a way to know if that condition holds, or a type safe representation of connected graphs.
I believe that a simple typesafe representation could be implemented for connected labelled graphs by tweaking the way
connect zero x y
works, as ifvertexSet x
∩vertexSet y
=Ø, then the resulting graph WILL be disconnected, but ifx
andy
share at least 1 vertex (assumingx
andy
are connected), then the graph will still be connected.On the other hand, MST algorithm could just try to add as much edges as possible to connect the vertices, but could generate a disconnected graph (a
Forest
).What is the optimal path to tackle this problem?
The text was updated successfully, but these errors were encountered: