Graphs (Help! Really challenging assignment. Would appreciate any bit of help!)
Family tree’s and genealogy software has become more and more prevalent in recent years. From the name you might expect that a family tree would be easily represented by a tree structure, but that is not the case! A more appropriate data structure to represent a family tree would be a type of graph. Using the description of the family that accompanies this assignment, you must represent this family using a graph structure. The graph needs to be a weighted graph. The weights will constitute the types of relationships, I recommend using some kind mapping between numbers and strings to represent the relationships. When adding family members to the graph, this can be done programmatically for the provided family members within the description file. Additionally, I also want there to be an interface in which a user can create a new family member and add them to the tree. This can be a simple CLI where the user provides a name, gender, and age to create a person. Then another simple CLI where they select which member of the family they want the original relationship to be with and what kind of relationship it should be. Finally, they can edit the family member using another CLI and selecting the family member they wish to edit, the operation they wish to perform (edit name, edit age, edit relationship), and then add new relationship between family members which can call a function that you create in order to add the original relationship. Remember the DRY philosophy, where code can be modularized or made into a function, it should be if you plan on using the logic again.
Finally, I want you to make data assertions within the FamilyTree class that enforce certain “rules” that exist in a typical human family. An example would be a person should not have any kind of relationship to itself (a person can not marry themselves, a person can not be their own brother, sister, father, mother, etc.). There should be at least 3 data assertions. These should exists as part of the family tree, not as part of the graph.
As a hint, for a successful design: I would recommend using layers of abstraction. Your graph class is the backing structure to the family tree class. Your family tree should implement methods that interface with the graph class, i.e. add_family_member() should call the constructor to create a node and then call a function within the graph class to add a node to the graph. Then using the relationships function parameter, you can add edges to the graph between the new nodes and the existing nodes. The family tree should be what enforces what relationships can exist through the data assertions, the graph does not care about what relationships are made between family members. Your functions that the user would interface with would be greatly reduced compared to the total number of methods within the classes themselves. The user should be able to add, remove, and modify family members and that’s about it. Therefore those should be your function calls.
Submission Goals
(120 pts.) Create a FamilyTree class that will represent a family tree for a given family.
The class should contain several types of relationships that commonly happen within a family (siblings, marriage, offspring, etc.)
(40 pts.) Programmatically add the family members to the graph as described by the accompanying family description file.
(40 pts.) Give data assertions to the FamilyTree class to enforce restrictions for basic family structure (at least 3); i.e A person can not marry themselves.
(40 pts.) Provide a simple CLI the enables users to add, remove, and edit family members.
graph.py
graph = dict()
graph[‘A’] = [‘B’, ‘C’]
graph[‘B’] = [‘E’,’C’, ‘A’]
graph[‘C’] = [‘A’, ‘B’, ‘E’,’F’]
graph[‘E’] = [‘B’, ‘C’]
graph[‘F’] = [‘C’]
matrix_elements = sorted(graph.keys())
cols = rows = len(matrix_elements)
adjacency_matrix = [[0 for x in range(rows)] for y in range(cols)]
edges_list = []
for key in matrix_elements:
for neighbor in graph[key]:
edges_list.append((key,neighbor))
print(edges_list)
for edge in edges_list:
index_of_first_vertex = matrix_elements.index(edge[0])
index_of_second_vertex = matrix_elements.index(edge[1])
adjacency_matrix[index_of_first_vertex][index_of_second_vertex] = 1
println(adjacency_matrix)
WutherHeightsFamilyTree.docx
The Extended Families of Wuther Heights (Modified):
Family 1
Patrick Earnshaw (M) {id: 001}
Hannah Earnshaw (F) {id: 002}
Relationship: Married
Children:
Catherine Earnshaw (F) {id: 003}
Hindley Earnshaw (M) {id: 004}
Family 2
Andrew Linton (M) {id: 005}
Dolores Linton (F) {id: 006}
Relationship: Divorced
Children:
Isabella Linton (F) {id: 007}
Edgar Linton (M) {id: 008}
Heathcliff Linton (M) [Adopted] {id: 009}
Family 3
Hindley Earnshaw (M) {id: 004}
Frances Byler (M) {id: 010}
Relationship: Married
Children:
Hareton Earnshaw (M) [Adopted] {id: 011}
Family 4
Catherine Earnshaw (F) {id: 003}
Edgar Linton (M) {id: 008}
Relationship: Married
Children:
Cathy Linton (F) {id: 012}
Family 5
Isabella Linton (F) {id: 007}
Children:
Linton Heathcliff (M) {id: 013}
Family 6
Heathcliff Linton (M) {id: 009}
Children:
Linton Heathcliff (M) {id: 013}
Family 7
Hareton Earnshaw (M) {id: 011}
Cathy Linton (F) {id: 012}
Relationship: Married
Family 8
Cathy Linton (F) {id: 012}
Linton Heathcliff (M) {id: 013}
Relationship: Divorced
Why Choose Us
Quality Papers
We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.
Professional Academic Writers
Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.
Affordable Prices
Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.
On-Time delivery
We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.
100% Originality
At Buy An Essay, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.
Customer Support 24/7
Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email: support@acmehomework.com.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
Buy An Essay has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.
Essays
At Buy An Essay, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.
Admissions
Admission and Business Papers
Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.
Editing
Editing and Proofreading
Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.
Coursework
Technical papers
We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.