1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
.. _classes:
***********
Graph types
***********
NetworkX provides data structures and methods for storing graphs.
All NetworkX graph classes allow (hashable) Python objects as nodes
and any Python object can be assigned as an edge attribute.
The choice of graph class depends on the structure of the
graph you want to represent.
Which graph class should I use?
===============================
+----------------+------------+--------------------+------------------------+
| Networkx Class | Type | Self-loops allowed | Parallel edges allowed |
+================+============+====================+========================+
| Graph | undirected | Yes | No |
+----------------+------------+--------------------+------------------------+
| DiGraph | directed | Yes | No |
+----------------+------------+--------------------+------------------------+
| MultiGraph | undirected | Yes | Yes |
+----------------+------------+--------------------+------------------------+
| MultiDiGraph | directed | Yes | Yes |
+----------------+------------+--------------------+------------------------+
Basic graph types
=================
.. toctree::
:maxdepth: 2
graph
digraph
multigraph
multidigraph
ordered
.. note:: NetworkX uses `dicts` to store the nodes and neighbors in a graph.
So the reporting of nodes and edges for the base graph classes will not
necessarily be consistent across versions and platforms. If you need the
order of nodes and edges to be consistent (e.g., when writing automated
tests), please see :class:`~networkx.OrderedGraph`,
:class:`~networkx.OrderedDiGraph`, :class:`~networkx.OrderedMultiGraph`,
or :class:`~networkx.OrderedMultiDiGraph`, which behave like the base
graph classes but give a consistent order for reporting of nodes and edges.
Graph Views
===========
.. automodule:: networkx.classes.graphviews
.. autosummary::
:toctree: generated/
generic_graph_view
subgraph_view
reverse_view
Filters
=======
.. note:: Filters can be used with views to restrict the view (or expand it).
They can filter nodes or filter edges. These examples are intended to help
you build new ones. They may instead contain all the filters you ever need.
.. automodule:: networkx.classes.filters
.. autosummary::
:toctree: generated/
no_filter
hide_nodes
hide_edges
hide_diedges
hide_multidiedges
hide_multiedges
show_nodes
show_edges
show_diedges
show_multidiedges
show_multiedges
|