diff --git a/server.js b/server.js
index ba73aa9a..fc94c37c 100644
--- a/server.js
+++ b/server.js
@@ -2,7 +2,7 @@
// [START app]
const express = require('express');
-const { Graph, addEdge, AllPaths } = require('./utils/directed_graph.js');
+const { Graph, addEdge, AllPaths, AllVicinity } = require('./utils/directed_graph.js');
const app = express();
@@ -32,13 +32,20 @@ app.get('/', (req, res) => {
addEdge(1, 3);
// arbitrary source
- let s = 2;
+ let s = 3;
// arbitrary destination
- let d = 3;
+ let d = 1;
const all_paths = AllPaths(s, d);
+ const all_vicinity = AllVicinity();
+
+ console.log('Paths from '+s+' to '+d+' :');
+ console.log(all_paths);
+ console.log('Reachibility: ');
+ console.log(all_vicinity);
+
let text_ = "Graph image: Graph paths original post " + "
";
text_ = text_ + "Following are all different paths from " + s + " to " + d + "
";
for (let i=0; i< all_paths.length; i++) {
diff --git a/utils/directed_graph.js b/utils/directed_graph.js
index 4bd6e312..5bf04702 100644
--- a/utils/directed_graph.js
+++ b/utils/directed_graph.js
@@ -25,7 +25,29 @@ function initAdjList(){
// add edge from u to v
function addEdge(u,v){
// Add v to u's list.
- adjList[u].push(v);
+ adjList[u].push(v);
+}
+
+function AllVicinity(s, d){
+ let paths = {};
+
+ // Initialization
+ for(let i=0; i Graph(num_vertices),
addEdge: (source, destination) => addEdge(source, destination),
- AllPaths: (source, destination) => AllPaths(source, destination)
+ AllPaths: (source, destination) => AllPaths(source, destination),
+ AllVicinity: () => AllVicinity()
};