New Contributor FAQ¶
A collection of frequently-asked questions by newcomers to open-source development and first-time contributors to NetworkX.
Q: I’m new to open source and would like to contribute to NetworkX. How do I get started?¶
To contribute to NetworkX, you will need three things:
The source code
A development environment
An idea of what you’d like to contribute
Steps 1 & 2 are covered extensively in Development Workflow. There is no generic answer for step 3. There are many ways that NetworkX can be improved, from adding new algorithms, improving existing algorithms, improving the test suite (e.g. increasing test coverage), and improving the documentation. The “best” way to find a place to start is to follow your own personal interests! That said, a few places to check for ideas on where to get started:
The issue tracker lists known bugs and feature requests. Of particular interest for first-time contributors are issues that have been tagged with the Good First Issue or Sprint labels.
The Algorithms discussion includes a listing of algorithms that users would like to have but that are not yet included in NetworkX.
Q: How do I contribute an example to the Gallery?¶
The example gallery is great place to contribute, particularly if you have an
interesting application or visualization that uses NetworkX.
The gallery is generated using sphinx-gallery
from Python scripts stored in the examples/
directory.
For instance, let’s say I’d like to contribute an example of visualizing a
complete graph
using a
circular layout
.
Assuming you have already followed the procedure for
setting up a development environment, start by
creating a new branch:
git checkout -b complete-graph-circular-layout-example
Note
It’s generally a good idea to give your branch a descriptive name so that it’s easy to remember what you are working on.
Now you can begin work on your example. Sticking with the circular layout idea,
you might create a file in examples/drawing
called plot_circular_layout.py
with the following contents:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.complete_graph(10) # A complete graph with 10 nodes
nx.draw_networkx(G, pos=nx.circular_layout(G))
Note
It may not be clear where exactly an example belongs. Our circular
layout example is very simple, so perhaps it belongs in examples/basic
.
It would also make sense for it to be in examples/drawing
since it deals
with visualization. Don’t worry if you’re not sure: questions like this will
be resolved during the review process.
At this point, your contribution is ready to be reviewed. You can make the
changes on your complete-graph-circular-layout-example
branch visible to
other NetworkX developers by
creating a pull request.
See also
The developer guide has more details on creating pull requests.
Q: I want to work on a specific function. How do I find it in the source code?¶
Assuming you have followed the instructions for setting up the development workflow, there are several ways of determining where the in the source code a particular function or class is defined.
For example, let’s say you are interested in making a change to the
kamada_kawai_layout
function, so you need to know
where it is defined. In an IPython terminal, you can use ?
— the source file is
listed in the File:
field:
In [1]: import networkx as nx
In [2]: nx.kamada_kawai_layout?
Signature: <clipped for brevity>
Docstring: <clipped for brevity>
File: ~/networkx/networkx/drawing/layout.py
Type: function
Command line utilities like grep
or git grep
are also very useful.
For example, from the NetworkX source directory:
$ grep -r "def kamada_kawai_layout" .
./networkx/drawing/layout.py:def kamada_kawai_layout(