networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturns
_weight_function(G, weight)

The returned function is specifically suitable for input to functions _dijkstra and _bellman_ford_relaxation .

Parameters

G : NetworkX graph.
weight : string or function

If it is callable, :None:None:`weight` itself is returned. If it is a string, it is assumed to be the name of the edge attribute that represents the weight of an edge. In that case, a function is returned that gets the edge weight according to the specified edge attribute.

Returns

function

This function returns a callable that accepts exactly three inputs: a node, an node adjacent to the first one, and the edge attribute dictionary for the eedge joining those nodes. That function returns a number representing the weight of an edge.

If `G` is a multigraph, and `weight` is not callable, the
minimum edge weight over all parallel edges is returned. If any edge
does not have an attribute with key `weight`, it is assumed to
have weight one.

Returns a function that returns the weight of an edge.

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#41
type: <class 'function'>
Commit: