Skip to content

Commit 381048b

Browse files
committed
create road module
1 parent 2fb8715 commit 381048b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

chapter_eight_road_module.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const buildGraph = require('./chapter_seven_robot_project');
2+
3+
const roads = [
4+
"Alice's House-Bob's House", "Alice's House-Cabin",
5+
"Alice's House-Post Office", "Bob's House-Town Hall",
6+
"Daria's House-Ernie's House", "Daria's House-Town Hall",
7+
"Ernie's House-Grete's House", "Grete's House-Farm",
8+
"Grete's House-Shop", "Marketplace-Farm",
9+
"Marketplace-Post Office", "Marketplace-Shop",
10+
"Marketplace-Town Hall", "Shop-Town Hall"
11+
];
12+
13+
const roadGraph = buildGraph(roads);
14+
15+
module.exports = roadGraph;

chapter_seven_robot_project.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const roads = [
1111
"Marketplace-Town Hall", "Shop-Town Hall"
1212
];
1313

14-
function buildGraph(from, to) {
14+
const buildGraph = function(from, to) {
1515
let graph = Object.create(null);
1616
function addEdge(from, to) {
1717
if (!graph[from]) {
@@ -185,4 +185,6 @@ console.log(b.has("b"));
185185
console.log(a.has("b"));
186186
// → false
187187
console.log(b.has("a"));
188-
// → false
188+
// → false
189+
190+
module.exports = buildGraph;

0 commit comments

Comments
 (0)