networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturns
_inner_bellman_ford(G, sources, weight, pred, dist=None, heuristic=True)

This is an implementation of the SPFA variant. See https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm

Parameters

G : NetworkX graph
source: list :

List of source nodes. The shortest path from any of the source nodes will be found if multiple sources are provided.

weight : function

The weight of an edge is the value returned by the function. The function must accept exactly three positional arguments: the two endpoints of an edge and the dictionary of edge attributes for that edge. The function must return a number.

pred: dict of lists :

dict to store a list of predecessors keyed by that node

dist: dict, optional (default=None) :

dict to store distance from source to the keyed node If None, returned dist dict contents default to 0 for every node in the source list

heuristic : bool

Determines whether to use a heuristic to early detect negative cycles at a hopefully negligible cost.

Raises

NodeNotFound

If any of :None:None:`source` is not in G.

Returns

node or None

Return a node :None:None:`v` where processing discovered a negative cycle. If no negative cycle found, return None.

Inner Relaxation loop for Bellman–Ford algorithm.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/shortest_paths/weighted.py#1332
type: <class 'function'>
Commit: