Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from Graph import Graph
- from EdgesPropriety import Edges
- class UI:
- def main_menu(self):
- menu = "1. Show the number of vertices.\n"
- menu += "2. Check if there is an edge between two vertices.\n"
- menu += "3. Show the in and out degree of a vertex.\n"
- menu += "4. Outbound edges of a specified vertex.\n"
- menu += "5. Inbound edges of a specified vertex.\n"
- menu += "6. Retrieve the value attached to an edge.\n"
- menu += "7. Modify the value attached to an edge.\n"
- menu += "8. BONUS: Add an edge.\n"
- menu += "9. BONUS: Remove an edge.\n"
- menu += "10. BONUS: Add a vertex.\n"
- menu += "11. BONUS: Remove a vertex.\n"
- menu += "12. BONUS: Show the initial graph.\n"
- menu += "13. BONUS: Show the initial value map.\n"
- menu += "14. Show graph.\n"
- menu += "15. Show the value map.\n"
- menu += "0. EXIT\n"
- print(menu)
- option = input("Enter option: ").strip()
- return int(option)
- def read_new_vertex(self, msg, keys):
- x = input(msg).strip()
- while x in str(keys) or to_int(x):
- print("That was not a positive integer or vertex already exists!")
- x = input(msg).strip()
- return x
- def read_vertex(self, msg, keys):
- x = input(msg).strip()
- while x not in str(keys):
- print("That vertex does not exist!")
- x = input(msg).strip()
- return x
- def number_vertices(self, nrVertices):
- print("Number of vertices:", str(nrVertices))
- def show(self, obj):
- self.clear()
- print(obj)
- def clear(self):
- if os.name == "nt":
- os.system("cls")
- elif os.name == "posix":
- os.system("clear")
- def to_int(x):
- try:
- x = int(x)
- if x > 0:
- return False
- return True
- except:
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement