
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
graphology-shortest-path
Advanced tools
Shortest path functions for graphology
.
npm install graphology-shortest-path
Returns the shortest path in the graph between source & target or null
if such a path does not exist (same as bidirectional).
If you only pass the source & omit the target, will return a map of every shortest path between the source & all the nodes of the graph (same as singleSource).
import shortestPath from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import shortestPath from 'graphology-shortest-path/unweighted';
// Returning the shortest path between source & target
const path = shortestPath(graph, source, target);
// Returning every shortest path between source & every node of the graph
const paths = shortestPath(graph, source);
Arguments
graphology
instance.Returns the shortest path in the graph between source & target or null
if such a path does not exist.
import {bidirectional} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import {bidirectional} from 'graphology-shortest-path/unweighted';
// Returning the shortest path between source & target
const path = bidirectional(graph, source, target);
Arguments
graphology
instance.Return a map of every shortest path between the given source & all the nodes of the graph.
import {singleSource} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import {singleSource} from 'graphology-shortest-path/unweighted';
// Returning every shortest path between source & every node of the graph
const paths = singleSource(graph, source);
Arguments
graphology
instance.Apply Ulrik Brandes' method to collect single source shortest paths from the given node. This is mostly used to compute betweenness centrality.
import {brandes} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import {brandes} from 'graphology-shortest-path/unweighted';
// Returning S, P & sigma
const [S, P, sigma] = brandes(graph, source);
Arguments
graphology
instance.Returns the shortest path in the weighted graph between source & target or null
if such a path does not exist.
import {dijkstra} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import dijkstra from 'graphology-shortest-path/dijkstra';
// Returning the shortest path between source & target
const path = dijkstra.bidirectional(graph, source, target);
// If you store edges' weight in custom attribute
const paths = dijkstra.bidirectional(graph, source, target, 'customWeight');
Arguments
graphology
instance.weight
]: name of the weight attribute.Return a map of every shortest path between the given source & all the nodes of the weighted graph.
import {dijkstra} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import dijkstra from 'graphology-shortest-path/dijkstra';
// Returning every shortest path between source & every node of the graph
const paths = dijkstra.singleSource(graph, source);
// If you store edges' weight in custom attribute
const paths = dijkstra.singleSource(graph, source, 'customWeight');
Arguments
graphology
instance.weight
]: name of the weight attribute.Apply Ulrik Brandes' method to collect single source shortest paths from the given node. This is mostly used to compute betweenness centrality.
import {dijkstra} from 'graphology-shortest-path';
// Alternatively, if you want to load only the relevant code
import dijkstra from 'graphology-shortest-path/dijkstra';
// Returning S, P & sigma
const [S, P, sigma] = dijkstra.brandes(graph, source);
// If you store edges' weight in custom attribute
const [S, P, sigma] = dijkstra.brandes(graph, source, 'customWeight');
Arguments
graphology
instance.weight
]: name of the weight attribute.FAQs
Shortest path functions for graphology.
We found that graphology-shortest-path demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.