Julia graphs, dijkstra_shortest_paths -
i have expandable graph, being able add vertices , edges, , run dijkstra_shortest_paths
algo. not able find right way define graph dijkstra_shortest_paths
work. below attempt.
using graphs g1= graph(exvertex[], exedge{exvertex}[], is_directed=false) dist_key = "dist" v1 = add_vertex!(g1, "a") v2 = add_vertex!(g1, "b") v3 = add_vertex!(g1, "c") e12 = add_edge!(g1, v1, v2) e12.attributes[dist_key]=1.0 e13 = add_edge!(g1, v1, v3) e13.attributes[dist_key]=1.0 e23 = add_edge!(g1, v2, v3) e23.attributes[dist_key]=1.0 epi = attributeedgepropertyinspector{float64}(dist_key) dijkstra_shortest_paths(g1, epi, ["a"])
error message:
dijkstra_shortest_paths has no method matching dijkstra_shortest_paths(::genericgraph{exvertex,exedge{exvertex},array{exvertex,1},array{exedge{exvertex},1},array{array{exedge{exvertex},1},1}}, ::attributeedgepropertyinspector{float64}, ::array{asciistring,1})
i think problem ["a"]
- have refer actual vertex "manually", i.e.
julia> sp = dijkstra_shortest_paths(g1, epi, [v1]) julia> sp.parents 3-element array{exvertex,1}: vertex [1] "a" vertex [1] "a" vertex [1] "a" julia> sp.dists 3-element array{float64,1}: 0.0 1.0 1.0
works me.
Comments
Post a Comment