Fix when len is not used
This commit is contained in:
parent
b09465e8a5
commit
4d3f63e00f
|
@ -371,7 +371,14 @@ class Graphs {
|
|||
var dt = splitted.split(sep.dotToLength);
|
||||
if (dt.length == 2) {
|
||||
dot.add(int.parse(dt[0]));
|
||||
len.add(int.parse(dt[1]));
|
||||
if (_useLength) {
|
||||
len.add(int.parse(dt[1]));
|
||||
} else {
|
||||
len.add(0);
|
||||
}
|
||||
} else if (dt.length == 1) {
|
||||
dot.add(int.parse(splitted));
|
||||
len.add(0);
|
||||
}
|
||||
}
|
||||
_dots.add(Dot.fromTwoLists(name, dot, len));
|
||||
|
@ -478,8 +485,8 @@ class Graphs {
|
|||
path = path.reversed.toList();
|
||||
|
||||
//print("Shortest path between vertices ${startDot+1} and ${goalDot+1} is: $path");
|
||||
if (path[0] == (startDot+1) &&
|
||||
path[1] == (goalDot+1) &&
|
||||
if (path[0] == (startDot + 1) &&
|
||||
path[1] == (goalDot + 1) &&
|
||||
!_dots[startDot].hasConnection(goalDot + 1)) return null;
|
||||
return path;
|
||||
}
|
||||
|
@ -497,11 +504,35 @@ class Graphs {
|
|||
if (!label[v]) {
|
||||
label[v] = true;
|
||||
for (int i in _dots[v].getL().keys) {
|
||||
stack.add(i-1);
|
||||
stack.add(i - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
void dijkstra(int source) {
|
||||
/*
|
||||
create vertex set Q;
|
||||
|
||||
for each vertex v in Graph{
|
||||
dist[v] ← INFINITY ;
|
||||
prev[v] ← UNDEFINED ;
|
||||
add v to Q;}
|
||||
dist[source] ← 0;
|
||||
|
||||
while Q is not empty{
|
||||
u ← vertex in Q with min dist[u]
|
||||
|
||||
remove u from Q
|
||||
|
||||
for each neighbor v of u still in Q{
|
||||
alt ← dist[u] + length(u, v);
|
||||
if alt < dist[v]: {
|
||||
dist[v] ← alt;
|
||||
prev[v] ← u;}
|
||||
}}
|
||||
return dist[], prev[]*/
|
||||
}
|
||||
//************Алгоритмы************
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue