def test_dijkstra_vs_networkx_single_source_all_lenghts_and_paths(): """ Test Dijkstra: Rion's implementation vs Networkx implementation > Single Source """ # NX Version G = nx.from_edgelist(edgelist_james) nx.set_edge_attributes(G, 'weight', edgelist_james) nx_lenghts = nx.single_source_dijkstra_path_length(G, source='s', weight='weight') nx_paths = nx.single_source_dijkstra_path(G, source='s', weight='weight') # My Version d = Dijkstra() d.from_edgelist(edgelist_james, directed=False) dc_lenghts, dc_paths = d.single_source_shortest_paths('s', kind='metric') assert (nx_lenghts == dc_lenghts) assert (nx_paths == dc_paths)
def test_dijkstra_sssp_from_edgelist(): """ Test Dijkstra: Single Source Shortest Path (SSSP) from Edgelist """ dij = Dijkstra(verbose=True) dij.from_edgelist(edgelist_james) dij.single_source_shortest_paths(source='s', kind='metric')
def test_dijkstra_sssp_from_numpy(): """ Test Dijkstra: Single Source Shortest Path (SSSP) from Numpy """ dij = Dijkstra(verbose=True) dij.from_numpy_matrix(D) dij.single_source_shortest_paths(source=0, kind='metric')