Skip to content
Dan Schult edited this page Jan 29, 2016 · 24 revisions

Welcome to the NetworkX wiki!

Design Specification - API Sandbox

Developer Notes

  • Configuring your fork with Read the Docs
  • Formatting copyright, authors, "the top of the module"
  • Formatting docstrings to look nice in code and in sphinx.
  • Guidelines for corner cases

  • How we tend to handle None

    When checking a value against None use the if var is None: construction. We also use None (as does Python itself) as a null argument to functions where the default argument must be newly computed at runtime. For example, if you use def f(nlist=[]): the list will be created when the function is defined and it will be the same list for all function calls. If you want a new list for each function call use

    def f(nlist=None): if nlist is None: nlist = []

    In some functions we allow nodes to be specified with a default of processing all nodes. We use None to indicate whether an argument was provided or not. Thus, None is special in that it cannot be a node in our graphs. We state that a node can be any hashable other than None.


  • Explicitly not supporting directed or multigraph in a function:

    Use the decorator in networkx.utils.not_implemented_for to designate that function doesn't accept 'directed', 'undirected', 'multigraph' or 'graph'. You can string together more than one restriction. The function should have its first argument be the graph object to be checked.

    @nx.not_implemented_for('digraph', 'multigraph') def function_for_simple_undirected_graph(G, others): pass


Clone this wiki locally