コード例 #1
0
def breadth_first_search(nodes, edges):
    for node in nodes:
        root = node
        graph = Graph(root, nodes, edges, False)
        breadth_search = bfs(graph)
        breadth_search.search()
        reset(nodes, edges)
コード例 #2
0
def floyd_warshall(nodes, edges):
    for node in nodes:
        print("root-> {} {}".format(node.get_sequence(), node.get_rotulo()))
        root = node
        graph = Graph(root, nodes, edges, True)
        floyd_warshall = FloydWarshall(graph)
        floyd_warshall.search()
        reset(nodes, edges)
コード例 #3
0
def djikstra(nodes, edges):
    for node in nodes:
        print("root-> {} {}".format(node.get_sequence(), node.get_rotulo()))
        root = node
        graph = Graph(root, nodes, edges, True)
        spf = SPF(graph)
        spf.search_shortest_path()
        reset(nodes, edges)
コード例 #4
0
def eulerian_path_finder(nodes, edges):
    for node in nodes:
        root = node
        graph = Graph(root, nodes, edges, True)
        eulerian_path_search = EulerianPath(graph)
        eulerian_path_search.search()
        reset(nodes, edges)

        print("#####")
コード例 #5
0
    def search(self):
        
        transposed_graph = self.graph.get_transpose_graph()
        self.dfs(transposed_graph)
        reset(self.graph.get_nodes(), self.graph.get_edges())
        self.component      = []
        self.all_components = []
        self.graph.sort_nodes_by_end_time()
        self.dfs(self.graph)

        index = 1
        for component in self.all_components:
            print("component", index)
            for element in component:
                print(element.get_sequence())
            index = index+1