Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Commit 3c5dda3

Browse files
committed
tmp
1 parent a11baa2 commit 3c5dda3

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

‎build/assets/index.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/components/Searchbar/Searchbar.jsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ class Searchbar extends React.Component {
4545

4646
static renderFound(answer, index) {
4747
const color = COLORS[index];
48-
const pathInfo = answer.path.reduce((pthinf, node) => {
48+
const pathInfo = answer.path.reduce((pthinf, node,j) => {
4949
const arr = pthinf;
5050
if (arr.length) {
5151
arr.push(
5252
<i
53+
key={`${j}arrow`}
5354
className="fas fa-arrow-circle-right"
5455
style={{ color: "#9E9E9E" }}
5556
/>,
5657
);
5758
}
58-
arr.push(<span> {node.name} </span>);
59+
arr.push(<spankey={j}> {node.name} </span>);
5960
return arr;
6061
}, []);
6162
return (

‎src/models/DijkstraSearch.js‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default class DijkstraSearch {
1818
}
1919

2020
const beginning = graph.nodes[start];
21+
const end = graph.nodes[finish];
2122

2223
const queue = [];
2324
queue.push(beginning);
@@ -42,16 +43,16 @@ export default class DijkstraSearch {
4243
const link = current.paths[i];
4344
const endPoint = graph.nodes[link.toNodeName];
4445

45-
if (endPoint.name === finish) {
46-
const path = [endPoint];
47-
let last = current;
48-
while (last.name !== start) {
49-
path.unshift(last);
50-
last = distances[last.name].prev;
51-
}
52-
path.unshift(beginning);
53-
return path;
54-
}
46+
// if (endPoint.name === finish) {
47+
// const path = [endPoint];
48+
// let last = current;
49+
// while (last.name !== start) {
50+
// path.unshift(last);
51+
// last = distances[last.name].prev;
52+
// }
53+
// path.unshift(beginning);
54+
// return path;
55+
// }
5556

5657
if (!tested.includes(endPoint)) {
5758
const currentDistance = distances[current.name].dist;
@@ -81,6 +82,17 @@ export default class DijkstraSearch {
8182
}
8283
}
8384

85+
if (distances[finish].dist !== Infinity) {
86+
const path = [end];
87+
let last = end;
88+
while (last.name !== start) {
89+
path.unshift(last);
90+
last = distances[last.name].prev;
91+
}
92+
path.unshift(beginning);
93+
return path;
94+
}
95+
8496
return null;
8597
}
8698

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /