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

Update minmax.py #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Update minmax.py #4

wants to merge 7 commits into from

Conversation

adikele
Copy link

@adikele adikele commented Jul 22, 2018

The function for finding the Minimum Spanning Tree (mst) in the minmax file seems to be in error: one of the edges is displayed twice in the mst.

I have rewritten the function for finding the mst and deleted the earlier one; the edges are now correctly displayed. Additionally, the weight of the mst is also displayed.

The MinSpanningTree branch contains this rewritten function in place of the original mst function. The difference between the output of the functions in the two versions is demonstrated with the help of an example:

g = graph()

g.add_node('A')
g.add_node('B')
g.add_node('C')
g.add_node('D')
g.add_node('E')

g.add_edge(('A', 'C'), 10, 'AC')
g.add_edge(('A', 'D'), 7, 'AD')
g.add_edge(('B', 'D'), 32, 'BD')
g.add_edge(('C', 'D'), 9, 'CD')
g.add_edge(('D', 'E'), 23, 'DE')

using the current function:{'A': 'D', 'C': 'D', 'B': 'D', 'E': 'D', 'D': 'B'}

using the new function in MinSpanningTree branch [('A', 'D'), ('D', 'C'), ('D', 'E'), ('D', 'B'), 71]

The function for finding the Minimum Spanning Tree (mst) in the minmax file seems to be in error: one of the edges is displayed twice in the mst.

I have rewritten the function for finding the mst and deleted the earlier one; the edges are now correctly displayed. Additionally, the weight of the mst is also displayed.

The MinSpanningTree branch contains this rewritten function in place of the original mst function. The difference between the output of the functions in the two versions is demonstrated with the help of an example:

g = graph()

g.add_node('A')
g.add_node('B')
g.add_node('C')
g.add_node('D')
g.add_node('E')

g.add_edge(('A', 'C'), 10, 'AC')
g.add_edge(('A', 'D'), 7, 'AD')
g.add_edge(('B', 'D'), 32, 'BD')
g.add_edge(('C', 'D'), 9, 'CD')
g.add_edge(('D', 'E'), 23, 'DE')


using the current function:{'A': 'D', 'C': 'D', 'B': 'D', 'E': 'D', 'D': 'B'}

using the new function in MinSpanningTree branch [('A', 'D'), ('D', 'C'), ('D', 'E'), ('D', 'B'), 71]
 tree_weight function is rewritten to accept tree as a List of Tuples
@adikele
Copy link
Author

adikele commented Jul 26, 2018

In unittests-minmax.py, I have rewritten the tree_weight function so that it can also accept a list of tuples.
EDIT: unittests-minmax.py has been reverted to its original state.
Instead, in minmax.py, the minimum spanning tree is now returned as a dictionary

@adikele adikele closed this Jul 26, 2018
@adikele adikele reopened this Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant