Skip to content

Commit

Permalink
allow to call dijkstra on a subset of vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
bdcht committed Jan 10, 2023
1 parent aaed484 commit 9193368
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion grandalf/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def path(self, x, y, f_io=0, hook=None):
p.insert(0, v[p[0]])
return p

def dijkstra(self, x, f_io=0, hook=None):
def dijkstra(self, x, f_io=0, hook=None, subset=None):
from collections import defaultdict
from heapq import heappop, heappush

Expand All @@ -500,6 +500,9 @@ def dijkstra(self, x, f_io=0, hook=None):
l, u = heappop(L)
for e in u.e_dir(f_io):
v = e.v[0] if (u is e.v[1]) else e.v[1]
if subset is not None:
if v not in subset:
continue
Dv = l + e.w
if D[v] != None:
# check if heap/D needs updating:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='grandalf',
version='0.7',
version='0.8',

description='Graph and drawing algorithms framework',
long_description=long_descr,
Expand Down

0 comments on commit 9193368

Please sign in to comment.