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.
Dijkstra is a commonly used algorithm for finding the shortest path/distance between two items in an interconnected collection of items (such as a graph or network).
DijkstraFast::Graph
by adding edges to
it.shortest_path
and shortest_distance
methods to an
existing class by including the DijkstraFast::ShortestPath
module.DijkstraFast::ShortestPath.shortest_path
or
DijkstraFast::ShortestPath.shortest_distance
directly when the source
and
dest
objects know how to find "connected" items via some method.gem install dijkstra_fast
DijkstraFast::Graph
graph = DijkstraFast::Graph.new
graph.add("A", "B", distance: 5)
graph.add("A", "C", distance: 8)
graph.add("B", "C", distance: 2)
distance, path = graph.shortest_path("A", "C")
path
=> ["A", "B", "C"]
distance
=> 7
DijkstraFast::ShortestPath
class MyNetwork
include DijkstraFast::ShortestPath
def connections(source)
case source
when "A"
yield "B", 3
yield "C", 8
when "B"
yield "C" # Default distance 1
end
end
end
distance, path = MyNetwork.new.shortest_path("A", "C")
path
=> ["A", "B", "C"]
distance
=> 4
DijkstraFast.shortest_path
or DijkstraFast.shortest_distance
Node = Struct.new(:label) do
def connections
case label
when "A"
yield Node.new("B"), 5
yield Node.new("C"), 8
when "B"
yield Node.new("C"), 2
end
end
end
a = Node.new("A")
b = Node.new("B")
c = Node.new("C")
distance, path = DijkstraFast.shortest_path(a, c)
path.map(&:label)
=> ["A", "B", "C"]
distance
=> 7
shortest_path
and shortest_distance
methods provide an optional
progress
named argument which (when set to anything truthy) will provide
progress as the algorithm proceeds. The default implementation uses the
progressbar gem, but this
is not required.unsigned long
which is compiler dependent. On many
machines this can be 18,446,744,073,709,551,615 (2^64 – 1). A
RuntimeError will be
thrown if this is surpassed; if so, congratulations on being bad ass!MIT. See the LICENSE
file.
Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001). "Section 24.3: Dijkstra's algorithm". Introduction to Algorithms (Second ed.). MIT Press and McGraw–Hill. pp. 595–601. ISBN 0-262-03293-7.
Knuth, D.E. (1977). "A Generalization of Dijkstra's Algorithm". Information Processing Letters. 6 (1): 1–5. doi:10.1016/0020-0190(77)90002-3.
FAQs
Unknown package
We found that dijkstra_fast 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.