nodes_or_number(which_args)
With this decorator, the specified argument can be either a number or a container of nodes. If it is a number, the nodes used are :None:None:`range(n)`
. This allows :None:None:`nx.complete_graph(50)`
in place of :None:None:`nx.complete_graph(list(range(50)))`
. And it also allows :None:None:`nx.complete_graph(any_list_of_nodes)`
.
If string, the name of the argument to be treated. If int, the index of the argument to be treated. If more than one node argument is allowed, can be a list of locations.
Function which replaces int args with ranges.
Decorator to allow number of nodes or container of nodes.
@nodes_or_number("nodes") def empty_graph(nodes): # nodes is converted to a list of nodes
@nodes_or_number(0) def empty_graph(nodes): # nodes is converted to a list of nodes
@nodes_or_number(["m1", "m2"]) def grid_2d_graph(m1, m2, periodic=False): # m1 and m2 are each converted to a list of nodes
@nodes_or_number([0, 1]) def grid_2d_graph(m1, m2, periodic=False): # m1 and m2 are each converted to a list of nodes
See :@nodes_or_number(1) def full_rary_tree(r, n) # presumably r is a number. It is not handled by this decorator. # n is converted to a list of nodes
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.utils.decorators.argmap
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