Skip to content

Instantly share code, notes, and snippets.

View nvictus's full-sized avatar

Nezar Abdennur nvictus

  • UMass Chan Medical School
  • Greater Boston Area
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / pqdict_dijkstra_example.py
Last active July 5, 2023 03:01
Python: Dijkstra's algorithm using the pqdict module
from pqdict import pqdict
def dijkstra(graph, source, target=None):
dist = {} # lengths of the shortest paths to each node
pred = {} # predecessor node in each shortest path
# Store distance scores in a priority queue dictionary
pq = pqdict.minpq()
for node in graph:
@nvictus
nvictus / gillespie_nrm.py
Last active October 1, 2020 15:35
Next-Reaction Method variant of the Gillespie stochastic simulation algorithm.
from pqdict import pqdict
from numpy import array, zeros, log, seterr
from numpy.random import rand
from collections import Counter
from matplotlib import pyplot as plt
seterr(divide="ignore")
class Reaction(object):