Пример #1
0
    def __init__(self, graph: DirectedGraph):
        self.matrix = []
        for i in range(len(graph.get_nodes())):
            self.matrix.append([0 for j in range(len(graph.get_nodes()))])

        for edge in graph.get_edges():
            nodes_ids = edge.get_nodes_ids()
            self.matrix[nodes_ids[0].get_id()][nodes_ids[1].get_id()] = 1
    def __init__(self, graph: DirectedGraph) -> None:
        self.list = {key: [] for key in range(len(graph.get_nodes()))}

        for edge in graph.get_edges():
            nodes = edge.get_nodes_ids()
            self.list[nodes[0].get_id()].append(nodes[1].get_id())