def handle_read_from_file(G: Graph, repr_type: int, file_name: str = ""): """ Reading graph from file. File must be inside the folder where Lab01_console.py is. """ if repr_type == 1 or repr_type == 2 or repr_type == 3: G.create_representation(os.path.dirname( __file__) + "/" + file_name, RepresentationType(repr_type)) else: print("\nInvalid file type have been chosen.")
import os, sys currentdir = os.path.dirname(os.path.realpath(__file__)) parentdir = os.path.dirname(currentdir) sys.path.append(parentdir) from utils.Graph import Graph, RepresentationType from utils.graph_plotter import GraphPlotter if __name__ == "__main__": G = Graph() G.create_representation( os.path.dirname(__file__) + '/inputs/adjmat.txt', RepresentationType.ADJACENCY_MATRIX) GraphPlotter.plot_graph(G) G.create_representation( os.path.dirname(__file__) + '/inputs/incmat.txt', RepresentationType.INCIDENCE_MATRIX) GraphPlotter.plot_graph(G) G.create_representation( os.path.dirname(__file__) + '/inputs/adjlist.txt', RepresentationType.ADJACENCY_LIST) GraphPlotter.plot_graph(G)