Commit cab630fb authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Small documentation fixes

parent 8f0b827d
......@@ -202,7 +202,7 @@ type*, which must be chosen from the predefined set:
.. table::
======================= ================
Type name Aliases
Type name Alias
======================= ================
``bool`` ``uint8_t``
``int32_t`` ``int``
......@@ -308,7 +308,7 @@ struct export_python_interface
using namespace boost::python;
class_<PythonEdge<Graph> >
("Edge", "This class represents an edge in a graph", no_init)
("Edge", no_init)
.def("source", &PythonEdge<Graph>::GetSource,
"Return the source vertex")
.def("target", &PythonEdge<Graph>::GetTarget,
......@@ -388,7 +388,7 @@ void export_python_interface()
using namespace boost::python;
("Vertex", "This class represents a vertex in a graph", no_init)
("Vertex", no_init)
.def("in_degree", &PythonVertex::GetInDegree,
"Return the in-degree")
.def("out_degree", &PythonVertex::GetOutDegree,
......@@ -19,10 +19,11 @@
# along with this program. If not, see <>.
``graph_tool`` - a general graph manipulation python module
``graph_tool`` - an efficient python module for graph analysis and manipulation
This module provides:
1. A Graph object for graph representation and manipulation
2. Property maps for Vertex, Edge or Graph.
3. Fast algorithms implemented in C++.
......@@ -111,7 +111,33 @@ def show_config():
class PropertyMap(object):
"""Property map class."""
"""Property map class.
This class provides a mapping from vertices, edges or whole graphs to
arbitrary properties.
The possible property types are listed below.
.. table::
======================= ================
Type name Alias
======================= ================
``bool`` ``uint8_t``
``int32_t`` ``int``
``int64_t`` ``long``
``double`` ``float``
``long double``
``vector<bool>`` ``vector<uint8_t>``
``vector<int32_t>`` ``vector<int>``
``vector<int64_t>`` ``vector<long>``
``vector<double>`` ``vector<float>``
``vector<long double>``
``python::object`` ``object``
======================= ================
def __init__(self, pmap, g, key_type, key_trans=None):
self.__map = pmap
self.__g = weakref.ref(g)
......@@ -242,14 +268,12 @@ def _check_prop_vector(prop, name=None, scalar=True, floating=False):
(" floating" if floating else "")))
def group_vector_property(g, props, value_type=None, vprop=None, pos=None):
def group_vector_property(props, value_type=None, vprop=None, pos=None):
"""Group list of properties ``props`` into a vector property map of the same
g : :class:`~graph_tool.Graph`
Graph to which the property maps belong.
props : list of :class:`~graph_tool.PropertyMap`
Properties to be grouped.
value_type : string (optional, default: None)
......@@ -398,12 +422,20 @@ from libgraph_tool_core import Vertex, Edge, Vector_bool, Vector_int32_t, \
class Graph(object):
"""This class encapsulates either a directed multigraph (default or if
"""Generic multigraph class.
This class encapsulates either a directed multigraph (default or if
``directed=True``) or an undirected multigraph (if ``directed=False``), with
optional internal edge, vertex or graph properties.
It is implemented as an adjacency list, where both vertex and edge lists are
C++ STL vectors.
If ``g`` is specified, the graph (and its internal properties) will be
The graph is implemented as an `adjacency list`_, where both vertex and edge
lists are C++ STL vectors.
.. _adjacency list:
def __init__(self, g=None, directed=True):
......@@ -1041,6 +1073,10 @@ def value_types():
# =====================
from libgraph_tool_core import Vertex, Edge
Vertex.__doc__ = """Vertex descriptor.
This class represents a vertex in a :class:`~graph_tool.Graph`."""
def _out_neighbours(self):
"""Return an iterator over the out-neighbours."""
......@@ -1080,6 +1116,10 @@ def _vertex_repr(self):
return "<Vertex object with index '%d' at 0x%x>" % (int(self), id(self))
Vertex.__repr__ = _vertex_repr
_edge_doc = """Edge descriptor.
This class represents an edge in a :class:`~graph_tool.Graph`."""
def _edge_iter(self):
"""Iterate over the source and target"""
......@@ -1117,6 +1157,7 @@ def init_edge_classes():
e = g.edges().next()
e.__class__.__repr__ = _edge_repr
e.__class__.__iter__ = _edge_iter
e.__class__.__doc__ = _edge_doc
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment