def dijkstra(self, src, paths_cnt=False, mod=None):
    dist = {v: inf for v in self.nodes}
    dist[src] = 0
    visited = set()
    paths = {v: 0 for v in self.nodes}
    paths[src] = 1
    q = [(0, src)]
    while q:
        (d, u) = heappop(q)
        if (u in visited):
            continue
        visited.add(u)
        for (v, e) in self.edges[u].items():
            dv = (d + e['weight'])
            if (dv > dist[v]):
                continue
            elif (dv == dist[v]):
                paths[v] += paths[u]
                if mod:
                    paths[v] %= mod
                continue
            paths[v] = paths[u]
            dist[v] = dv
            heappush(q, (dv, v))
    if paths_cnt:
        return (dist, paths)
    else:
        return dist
def dijkstra(self, src, paths_cnt=False, mod=None):
    dist = {v: inf for v in self.nodes}
    dist[src] = 0
    visited = set()
    paths = {v: 0 for v in self.nodes}
    paths[src] = 1
    q = [(0, src)]
    while q:
        (d, u) = heappop(q)
        if (u in visited):
            continue
        visited.add(u)
        for (v, e) in self.edges[u].items():
            dv = (d + e['weight'])
            if (dv > dist[v]):
                continue
            elif (dv == dist[v]):
                paths[v] += paths[u]
                if mod:
                    paths[v] %= mod
                continue
            paths[v] = paths[u]
            dist[v] = dv
            heappush(q, (dv, v))
    if paths_cnt:
        return (dist, paths)
    else:
        return dist