Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@vila91/graph
Advanced tools
Directed and Undirected graph implementation based on the following node structure
Directed and Undirected graph implementation based on the following node structure. Nodes can be added using at construction or by using the .set(x, y, cost) method with cost defaulting to 1.
let nodes = {x: {y: 2}, y: {z: 3}},
graph = Directed(nodes).set(z, x)
console.log(graph)
// Directed {x: {y: 2}, y: {z: 3}, z: {x: 1}}
The .routes(x, y, limit) method returns the shortest routes from x to y, same-cost routes are sorted by number of nodes ascending, limit defaults to Infinity, for performance purposes it is recommended to set it to exactly the number needed.
graph.set("B", "C").set("C", "D").set("B", "D").set("A", "D", 3)
console.log(graph.routes("A", "D"))
/* [
{cost: 2, nodes: ["A", "B", "D"]},
{cost: 3, nodes: ["A", "D"]},
{cost: 3, nodes: ["A", "B", "C", "D"]}
] */
console.log(graph.routes("A", "D", 1))
// [{cost: 2, nodes: ["A", "B", "D"]}]
The .route(x, ...y) method returns the cheapest route going from x through all ...y nodes. It is based on calls to .routes with limit = 1.
let route = graph.route("A", "B", "D")
console.log(route)
// {cost: 2, nodes: ["A", "B", "D"]}
FAQs
Directed and Undirected graph implementation based on the following node structure
We found that @vila91/graph demonstrated a not healthy version release cadence and project activity because the last version was released 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.