コード例 #1
0
from random_generation.graph_generators import generate_connected_graph
from visualization.nx_graph import display_weighted_nx_graph

if __name__ == "__main__":
    G = generate_connected_graph(50, 60)

    display_weighted_nx_graph(G)
コード例 #2
0
ファイル: Task_3_2.py プロジェクト: dannyxn/Graphs-Toolbox
from algorithms.dijkstras_algorithm import DijkstraAlgorithm, generate_adjacency_matrix
from random_generation.graph_generators import generate_connected_graph
from visualization.nx_graph import display_weighted_nx_graph

import networkx as nx

if __name__ == "__main__":
    G = generate_connected_graph(6, 7)

    adj_matrix_with_distances = nx.to_numpy_array(G)
    adj_matrix_with_distances = adj_matrix_with_distances.tolist()
    adj_matrix = generate_adjacency_matrix(adj_matrix_with_distances)

    dijkstra = DijkstraAlgorithm(adj_matrix_with_distances, adj_matrix)
    dijkstra.all_shortest_paths(1)

    display_weighted_nx_graph(G)
コード例 #3
0
from random_generation.graph_generators import generate_connected_graph
from visualization.nx_graph import display_weighted_nx_graph
from algorithms.minimum_spanning_tree import find_minimum_spanning_tree

if __name__ == "__main__":
    graph = generate_connected_graph(6, 12)
    display_weighted_nx_graph(graph, filename="input_graph.png")
    minimum_spanning_tree = find_minimum_spanning_tree(graph)
    display_weighted_nx_graph(minimum_spanning_tree, filename="mse.png")