Skip to content

Instantly share code, notes, and snippets.

@elisedeux
Last active April 4, 2017 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elisedeux/4405d53ce05dbdc86963d060bd2ed5ea to your computer and use it in GitHub Desktop.
Save elisedeux/4405d53ce05dbdc86963d060bd2ed5ea to your computer and use it in GitHub Desktop.
A query to find and display the shortest path between two nodes using Linkurious REST API.
// Use the REST API to get the shortest path between two customers and render in Ogma
function shortestPath(customer1, customer2) {
// Configure and send the Ajax query asynchronously.
$.ajax({
type: "GET",
// Define the authentication information.
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + btoa('root@root.com:6160b54b872459ce1c06c1a8ccdd9019')
},
// REST method url
url: "http://localhost:3000/api/1cf9e65b/graph/shortestPaths",
// Message parameters
dataType: 'json',
data: {
startNode: `${customer1}`,
endNode: `${customer2}`
}
}).fail( () => {
// On error, display an alert.
alert( "Error" );
}).done(data => {
// When the response arrives, update the graph.
updateGraph(data);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment