Skip to content

Commit

Permalink
[docs] updated to current content
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Aug 3, 2017
1 parent 1d04f2d commit ffcf4d0
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 56 deletions.
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ If you are comfortable using :py:class:`list`, :py:class:`dict` or other types,

.. code::
from graphi.types.adjacency_graph import AdjacencyGraph
# create a graph with initial nodes
airports = Graph("New York", "Rio", "Tokyo")
airports = AdjacencyGraph("New York", "Rio", "Tokyo")
# add connections between nodes
airports["New York":"Rio"] = timedelta(hours=9, minutes=50)
airports["New York":"Tokyo"] = timedelta(hours=13, minutes=55)
Expand All @@ -41,7 +42,7 @@ For example, creating a multigraph is as simple as using multiple edge values:

.. code::
# add multiple connections between nodes
# add multiple connections between nodes -> Multigraph
airports["Rio":"Tokyo"] = timedelta(days=1, hours=2), timedelta(days=1, hours=3)
With its general-purpose design, ``GraphI`` makes no assumptions about your data.
Expand Down
7 changes: 0 additions & 7 deletions docs/source/api/graphi.compatibility.python2.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/api/graphi.compatibility.python3.rst

This file was deleted.

16 changes: 0 additions & 16 deletions docs/source/api/graphi.compatibility.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/api/graphi.graph_io.csv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
graphi\.graph\_io\.csv module
=============================

.. automodule:: graphi.graph_io.csv
:members:
:undoc-members:
:show-inheritance:
15 changes: 15 additions & 0 deletions docs/source/api/graphi.graph_io.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
graphi\.graph\_io package
=========================

.. automodule:: graphi.graph_io
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::

graphi.graph_io.csv

7 changes: 7 additions & 0 deletions docs/source/api/graphi.operators.interface.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
graphi\.operators\.interface module
===================================

.. automodule:: graphi.operators.interface
:members:
:undoc-members:
:show-inheritance:
15 changes: 15 additions & 0 deletions docs/source/api/graphi.operators.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
graphi\.operators package
=========================

.. automodule:: graphi.operators
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::

graphi.operators.interface

3 changes: 2 additions & 1 deletion docs/source/api/graphi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Subpackages

.. toctree::

graphi.compatibility
graphi.graph_io
graphi.operators
graphi.types

Submodules
Expand Down
14 changes: 14 additions & 0 deletions docs/source/common_ops.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
+++++++++++++++++++++++
Common Graph Operations
+++++++++++++++++++++++

Many common graph operations map to simple operators in :py:mod:`graphi`.
Unless parameters are needed, builtin operations usually suffice.
For example, the outdegree of a node is simply

.. code::
len(graph[node])
in a directed graph.
Since :py:mod:`graphi` makes heavy use of data views (instead of copies), this has optimal performance.
5 changes: 0 additions & 5 deletions docs/source/template.rst

This file was deleted.

16 changes: 8 additions & 8 deletions graphi/graph_io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class DistanceMatrixLiteral(csv.Dialect):
"""
CSV dialect for a Graph Matrix Literal, suitable for numeric data and string literals
```
a b c
0 2 1.3
2 0 .5
16 .5 1
```
A graph with alphabetic node names and numeric values would look like this::
a b c
0 2 1.3
2 0 .5
16 .5 1
"""
#: no explicit delimeters required
#: no explicit delimeter between fields
delimiter = ' '
#: string literals can be written as "foo"
#: string values are written as "foo", multi-values as '1,2,3'
quotechar = "'"
doublequote = False
#: use regular escaping
Expand Down
21 changes: 11 additions & 10 deletions graphi/types/adjacency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
import six


class AdjacencyListTypeError(TypeError):
"""AdjacencyList was set to incorrect type"""
def __init__(self, edge):
TypeError.__init__("AdjacencyList must be None, its node or a mapping, not %r" %
edge.__class__)


class AdjacencyGraph(abc.Graph):
"""
Graph storing edge distances via adjacency lists.
r"""
Graph storing edge distances via adjacency lists
:param source: adjacency information
:param undirected: whether the graph enforces symmetry
This graph provides optimal performance for random, direct access to nodes
and edges. As it stores individual nodes and edges, it is optimal in both
space and time for sparse graphs.
However, ordering of :py:meth:`nodes`, :py:meth:`edges` and :py:meth:`values`
is arbitrary. The expected complexity for searches is the worst case of O(len(:py:meth:`nodes`) = n)
and O(len(:py:meth:`edges`) -> n\ :sup:`2`\ ), respectively.
"""
def __init__(self, *source, undirected=False, max_distance=None):
self.undirected = undirected
Expand Down Expand Up @@ -123,7 +124,7 @@ def __setitem__(self, item, value):
self._adjacency[node_to][item] = value[node_to]
self._adjacency[item] = value.copy()
else:
raise AdjacencyListTypeError(value)
raise abc.AdjacencyListTypeError(value)

def __delitem__(self, item):
if isinstance(item, slice):
Expand Down

0 comments on commit ffcf4d0

Please sign in to comment.