Contribution’s guideline: Methods

Thank you very much for considering contributing to the methods collection of NetworkCommons! For methods, it is especially important that inputs and outputs are compatible with the rest of the package, the purpose is stated and the assumptions of the method are clear.

1. Documentation

In the ./docs/src/methods.rst file, contributors should add:

  • The description of the method

  • A figure showcasing the basics (if possible)

  • Input/output definition

  • Link to publication and repository (if available)

For example:

Shortest path
-------------

The shortest path is an algorithm for finding one or multiple paths that minimize the distance from a set of starting nodes to a set of destination nodes in a weighted graph (https://doi.org/10.1007/BF01386390).

.. raw:: html

   <object type="image/svg+xml" data="_static/nc_sp.svg" width="1000px"></object>

   
**Input:** Set of source and target nodes, (weighted) network graph

**Node weights:** w(v) = 1

**Edge weights:** 0 ≤ w(e) ≤ 1

**Functions:** See API documentation for :ref:`Topological methods <api-topological>`.

Functions should be documented using Google style Python docstrings.

In ./docs/src/api.rst file, contributors should add a new documentation module that contains the new classes/functions implemented:

Topological methods
~~~~~~~~~~~~~~~~~~~
.. module::networkcommons.methods
.. currentmodule:: networkcommons

.. autosummary::
    :toctree: api
    :recursive:

    methods.run_shortest_paths
    methods.run_sign_consistency
    methods.run_reachability_filter
    methods.run_all_paths
    methods.compute_all_paths

2. API

  • Every new method should be implemented in a separate file (e.g _moon.py) inside /networkcommons/methods/.

  • Contributors can then implement their own set of functionalities and expose those necessary to the public API via the __all__ variable (see other files for examples).

  • The input of the overall pipeline must be at least a Network object, and its overall output should return at least a Network object containing the contextualised network.

This does not apply to intermediate functions (e.g Network –function 1–> pd.DataFrame –function 2–> Network) in case of a pipeline containing several functions, such as MOON.