- branching_weight(G, attr='weight', default=1)#
Returns the total weight of a branching.
You must access this function through the networkx.algorithms.tree module.
The directed graph.
The attribute to use as weights. If None, then each edge will be treated equally with a weight of 1.
attris not None, then if an edge does not have that attribute,
defaultspecifies what value it should take.
- weight: int or float
The total weight of the branching.
>>> G = nx.DiGraph() >>> G.add_weighted_edges_from([(0, 1, 2), (1, 2, 4), (2, 3, 3), (3, 4, 2)]) >>> nx.tree.branching_weight(G) 11