[Python-modules-commits] [python-igraph] 01/08: Import python-igraph_0.7.1.post6.orig.tar.gz

Takaki Taniguchi takaki at moszumanska.debian.org
Wed Nov 25 04:54:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

takaki pushed a commit to branch master
in repository python-igraph.

commit c15dfb37b030541e166a9b6d52e7937bb6bfc718
Author: TANIGUCHI Takaki <takaki at asis.media-as.org>
Date:   Wed Nov 25 12:47:57 2015 +0900

    Import python-igraph_0.7.1.post6.orig.tar.gz
---
 MANIFEST.in                        |    6 -
 PKG-INFO                           |    8 +-
 debian/changelog.in                |    5 -
 debian/compat                      |    1 -
 debian/control.in                  |   34 -
 debian/copyright.in                |   28 -
 debian/prepare                     |   15 -
 debian/rules                       |  105 ---
 igraph/__init__.py                 |  549 +++++++++----
 igraph/app/shell.py                |   24 +-
 igraph/clustering.py               |  121 +--
 igraph/compat.py                   |   14 +-
 igraph/configuration.py            |   73 +-
 igraph/drawing/__init__.py         |   68 +-
 igraph/drawing/colors.py           |    7 +-
 igraph/drawing/edge.py             |  220 ++++-
 igraph/drawing/graph.py            |  260 +++---
 igraph/drawing/text.py             |   45 +-
 igraph/drawing/utils.py            |   41 +-
 igraph/drawing/vertex.py           |   98 +++
 igraph/layout.py                   |   20 +-
 igraph/{ => remote}/nexus.py       |   14 +-
 igraph/statistics.py               |   26 +-
 igraph/summary.py                  |   10 +-
 igraph/test/__init__.py            |   56 +-
 igraph/test/attributes.py          |  141 ++--
 igraph/test/basic.py               |  306 +++----
 igraph/test/bipartite.py           |  111 +--
 igraph/test/cliques.py             |   48 +-
 igraph/test/colortests.py          |   26 +-
 igraph/test/conversion.py          |   42 +-
 igraph/test/decomposition.py       |  166 ++--
 igraph/test/edgeseq.py             |  229 ++++--
 igraph/test/flow.py                |  201 +++--
 igraph/test/foreign.py             |   93 +--
 igraph/test/games.py               |  108 ++-
 igraph/test/generators.py          |   80 +-
 igraph/test/indexing.py            |   26 +-
 igraph/test/isomorphism.py         |  165 +++-
 igraph/test/iterators.py           |    4 +-
 igraph/test/layouts.py             |  118 ++-
 igraph/test/operators.py           |  105 ++-
 igraph/test/rng.py                 |    6 +-
 igraph/test/separators.py          |   32 +-
 igraph/test/spectral.py            |   12 +-
 igraph/test/structural.py          |  325 ++++----
 igraph/test/utils.py               |   67 ++
 igraph/test/vertexseq.py           |  215 +++--
 igraph/utils.py                    |   37 +-
 python_igraph.egg-info/PKG-INFO    |    8 +-
 python_igraph.egg-info/SOURCES.txt |   11 +-
 scripts/epydoc-patched             |    2 +
 scripts/epydoc.cfg                 |    4 +-
 scripts/mkdoc.sh                   |    2 +-
 setup.cfg                          |    4 -
 setup.py                           |  876 ++++++++++++++++++--
 src/attributes.c                   |  173 +++-
 src/attributes.h                   |   11 +
 src/common.h                       |    8 +
 src/convert.c                      |  751 +++++++++++------
 src/convert.h                      |   16 +-
 src/edgeobject.c                   |  170 +++-
 src/edgeobject.h                   |    5 +
 src/edgeseqobject.c                |   19 +-
 src/filehandle.c                   |   50 +-
 src/filehandle.h                   |    1 +
 src/graphobject.c                  | 1571 +++++++++++++++++++++++++++---------
 src/graphobject.h                  |    5 +
 src/igraphmodule.c                 |   16 +-
 src/py2compat.c                    |   38 +
 src/py2compat.h                    |   13 +-
 src/vertexobject.c                 |  169 +++-
 src/vertexobject.h                 |    5 +
 src/vertexseqobject.c              |   20 +-
 test/doctests.py                   |    2 +-
 75 files changed, 6033 insertions(+), 2428 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index cedd9ce..cfccd91 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -2,12 +2,6 @@ include setup.cfg
 include src/*.h
 include MANIFEST.in
 include COPYING
-include debian/changelog.in
-include debian/control.in
-include debian/copyright.in
-include debian/compat
-include debian/rules
-include debian/prepare
 include scripts/mkdoc.sh
 include scripts/epydoc-patched
 include scripts/epydoc.cfg
diff --git a/PKG-INFO b/PKG-INFO
index 5d7edc9..dbc23f0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,8 +1,8 @@
 Metadata-Version: 1.1
 Name: python-igraph
-Version: 0.6.5
+Version: 0.7.1.post6
 Summary: High performance graph data structures and algorithms
-Home-page: UNKNOWN
+Home-page: http://pypi.python.org/pypi/python-igraph
 Author: Tamas Nepusz
 Author-email: tamas at cs.rhul.ac.uk
 License: GNU General Public License (GPL)
@@ -19,9 +19,9 @@ Description: Python interface to the igraph high performance graph
         in the Python distribution - you must compile and install the C core
         separately. Windows installers already contain a compiled igraph DLL,
         so they should work out of the box. Linux users should refer to the
-        `igraph homepage <http://igraph.sourceforge.net>`_ for
+        `igraph homepage <http://igraph.org>`_ for
         compilation instructions (but check your distribution first, maybe
-        there are pre-compiled packages available). OS X Snow Leopard users may
+        there are pre-compiled packages available). OS X users may
         benefit from the disk images in the Python Package Index.
         
         Unofficial installers for 64-bit Windows machines and/or different Python
diff --git a/debian/changelog.in b/debian/changelog.in
deleted file mode 100644
index 2fac0ca..0000000
--- a/debian/changelog.in
+++ /dev/null
@@ -1,5 +0,0 @@
-python-igraph (@VERSION@) unstable; urgency=low
-
-  * Initial Release.
-
- -- Tamas Nepusz <ntamas at gmail.com>  @DATE@ 
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7f8f011..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/debian/control.in b/debian/control.in
deleted file mode 100644
index 7c68454..0000000
--- a/debian/control.in
+++ /dev/null
@@ -1,34 +0,0 @@
-Source: python-igraph
-Section: python
-Priority: optional
-Maintainer: Tamas Nepusz <ntamas at gmail.com>
-Build-Depends: debhelper (>= 7), python-all-dev (>= 2.3.5-11), libxml2-dev, libigraph0-dev (>= @VERSION@), python-epydoc, python-central
-Standards-Version: 3.9.3
-XS-Python-Version: >= 2.4
-Homepage: http://igraph.sourceforge.net
-
-Package: python-igraph
-Architecture: any
-Depends: ${python:Depends}, ${misc:Depends}, libigraph0 (>= @VERSION@)
-Suggests: python-igraph-doc, python-cairo
-Provides: ${python:Provides}
-XB-Python-Version: ${python:Versions}
-Description: Python interface for the igraph library
- igraph is a library for creating and manipulating graphs.
- It is intended to be as powerful (ie. fast) as possible to enable the
- analysis of large graphs.
- .
- This package contains the Python interface of igraph.
-
-Package: python-igraph-doc
-Architecture: all
-Section: doc
-Suggests: python-igraph, python-doc
-Depends: ${misc:Depends}
-Description: Documentation of the Python interface of the igraph library
- igraph is a library for creating and manipulating graphs.
- It is intended to be as powerful (ie. fast) as possible to enable the
- analysis of large graphs.
- .
- This package contains the API documentation of the Python interface of
- the igraph library.
diff --git a/debian/copyright.in b/debian/copyright.in
deleted file mode 100644
index 097362b..0000000
--- a/debian/copyright.in
+++ /dev/null
@@ -1,28 +0,0 @@
-This package was debianized by Tamas Nepusz <ntamas at gmail.com> on Tue, 10 Oct 2005 23:13:01 +0100.
-
-It was downloaded from http://pypi.python.org/packages/source/p/python-igraph/python-igraph-@VERSION@.tar.gz
-
-Upstream Authors: Gabor Csardi, Tamas Nepusz
-
-Copyright:
-
-Copyright (C) 2005-2009 Gabor Csardi, Tamas Nepusz
-
-License:
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License with
-the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
-if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-Suite 330, Boston, MA  02111-1307  USA
-
-On Debian systems, the complete text of the GNU General Public
-License, version 2, can be found in /usr/share/common-licenses/GPL-2.
diff --git a/debian/prepare b/debian/prepare
deleted file mode 100755
index f2a1c9d..0000000
--- a/debian/prepare
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-DATE=`date -R`
-VER=`sed -n -e "s/^[ \t]*version *= *'\\(.*\\)', *$/\1/p" setup.py`
-
-if [ x$1 = xbzr -o x$1 = x--bzr ]; then
-  VER="${VER}~bzr"`date +%Y%m%d`
-fi
-
-for i in copyright.in changelog.in control.in; do
-  cat debian/$i | sed -e "s/@VERSION@/$VER/g" | sed -e "s/@DATE@/$DATE/g" >debian/`basename $i .in`
-done
-
-echo "Prepared Debian package files for version $VER."
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 26dbcae..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/make -f
-
-# Uncomment this to turn on verbose mode.
-export DH_VERBOSE=1
-
-# This is to mark that the public modules installed differ between
-# Python version and they can't be shared
-export DH_PYCENTRAL=nomove
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-	CFLAGS += -O0
-else
-	CFLAGS += -O2
-endif
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
-	INSTALL_PROGRAM += -s
-endif
-
-# Get Python version information
-PYDEF=$(shell pyversions -d)
-PYVERS=$(shell pyversions -r)
-
-configure: configure-stamp
-configure-stamp:
-	dh_testdir
-	touch configure-stamp
-
-build: configure-stamp build-arch build-indep
-build-arch: build-stamp
-build-indep: build-stamp
-build-stamp:
-	dh_testdir
-	set -e; \
-	for python in $(PYVERS); do \
-	  python=$$(echo $$python | sed "s/$(PYDEF)/python/"); \
-	  $$python setup.py build --build-platlib=$(CURDIR)/build/lib; \
-	done
-	scripts/mkdoc.sh build/lib
-	touch build-stamp
-
-clean:
-	dh_testdir
-	dh_testroot
-	rm -rf doc/api/html/
-	for python in $(PYVERS); do \
-	  python=$$(echo $$python | sed "s/$(PYDEF)/python/"); \
-	  $$python setup.py clean; \
-	done
-	rm -f build-stamp configure-stamp
-	rm -rf build
-	dh_clean
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_prep
-	dh_installdirs
-	set -e; \
-	for python in $(PYVERS); do \
-	  python=$$(echo $$python | sed "s/$(PYDEF)/python/"); \
-	  $$python setup.py install --root=$(CURDIR)/debian/python-igraph --install-layout=deb; \
-	done
-	dh_installdocs -ppython-igraph-doc doc/api/html/*
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-#	dh_installdebconf	
-	dh_installdocs
-	dh_installexamples
-#	dh_installmenu
-#	dh_installlogrotate
-#	dh_installemacsen
-#	dh_installpam
-#	dh_installmime
-#	dh_installinit
-#	dh_installcron
-	dh_installman
-	dh_installinfo
-#	dh_installchangelogs ChangeLog
-	dh_link
-	dh_strip
-	dh_compress
-	dh_fixperms
-	dh_makeshlibs
-	dh_shlibdeps
-#	dh_python
-	dh_pycentral
-	dh_gencontrol
-	dh_installdeb
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/igraph/__init__.py b/igraph/__init__.py
index 7524b4d..147ce1e 100644
--- a/igraph/__init__.py
+++ b/igraph/__init__.py
@@ -25,7 +25,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA 
+Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA
 02110-1301 USA
 """
 
@@ -42,8 +42,7 @@ from igraph.datatypes import *
 from igraph.formula import *
 from igraph.layout import *
 from igraph.matching import *
-from igraph.nexus import *
-from igraph.remote import *
+from igraph.remote.nexus import *
 from igraph.statistics import *
 from igraph.summary import *
 from igraph.utils import *
@@ -56,6 +55,7 @@ import operator
 
 from collections import defaultdict
 from itertools import izip
+from shutil import copyfileobj
 from tempfile import mkstemp
 from warnings import warn
 
@@ -67,7 +67,7 @@ def deprecated(message):
 # pylint: disable-msg=E1101
 class Graph(GraphBase):
     """Generic graph.
-    
+
     This class is built on top of L{GraphBase}, so the order of the
     methods in the Epydoc documentation is a little bit obscure:
     inherited methods come after the ones implemented directly in the
@@ -105,7 +105,7 @@ class Graph(GraphBase):
       >>> g["A", "B"] = 0
       >>> g.ecount()
       2
-    
+
     Assigning values different from zero or one to the adjacency matrix will
     be translated to one, unless the graph is weighted, in which case the
     numbers will be treated as weights:
@@ -142,16 +142,18 @@ class Graph(GraphBase):
     subgraph = GraphBase.induced_subgraph
 
     def __init__(self, *args, **kwds):
-        """__init__(n=None, edges=None, directed=None, graph_attrs=None,
+        """__init__(n=0, edges=None, directed=False, graph_attrs=None,
         vertex_attrs=None, edge_attrs=None)
-        
+
         Constructs a graph from scratch.
 
         @keyword n: the number of vertices. Can be omitted, the default is
-          zero.
+          zero. Note that if the edge list contains vertices with indexes
+          larger than or equal to M{m}, then the number of vertices will
+          be adjusted accordingly.
         @keyword edges: the edge list where every list item is a pair of
           integers. If any of the integers is larger than M{n-1}, the number
-          of vertices is adjusted accordingly.
+          of vertices is adjusted accordingly. C{None} means no edges.
         @keyword directed: whether the graph should be directed
         @keyword graph_attrs: the attributes of the graph as a dictionary.
         @keyword vertex_attrs: the attributes of the vertices as a dictionary.
@@ -165,23 +167,45 @@ class Graph(GraphBase):
         kwd_order = ["n", "edges", "directed", "graph_attrs", "vertex_attrs", \
                 "edge_attrs"]
         params = [0, [], False, {}, {}, {}]
+
+        # Is there any keyword argument in kwds that we don't know? If so,
+        # freak out.
+        unknown_kwds = set(kwds.keys())
+        unknown_kwds.difference_update(kwd_order)
+        if unknown_kwds:
+            raise TypeError("{0}.__init__ got an unexpected keyword argument {1!r}".format(
+                self.__class__.__name__, unknown_kwds.pop()
+            ))
+
         # If the first argument is a list, assume that the number of vertices
         # were omitted
         args = list(args)
         if len(args) > 0:
             if isinstance(args[0], list) or isinstance(args[0], tuple):
                 args.insert(0, params[0])
+
         # Override default parameters from args
         params[:len(args)] = args
+
         # Override default parameters from keywords
         for idx, k in enumerate(kwd_order):
             if k in kwds:
                 params[idx] = kwds[k]
+
         # Now, translate the params list to argument names
         nverts, edges, directed, graph_attrs, vertex_attrs, edge_attrs = params
 
+        # When the number of vertices is None, assume that the user meant zero
+        if nverts is None:
+            nverts = 0
+
+        # When 'edges' is None, assume that the user meant an empty list
+        if edges is None:
+            edges = []
+
         # Initialize the graph
         GraphBase.__init__(self, nverts, edges, directed)
+
         # Set the graph attributes
         for key, value in graph_attrs.iteritems():
             if isinstance(key, (int, long)):
@@ -226,20 +250,8 @@ class Graph(GraphBase):
 
         @param es: the list of edges to be added. Every edge is represented
           with a tuple containing the vertex IDs or names of the two
-          endpoints. Vertices are enumerated from zero. It is allowed to
-          use a single tuple containing two vertex IDs here instead of a
-          list, but this is deprecated from igraph 0.6 and will be removed
-          from 0.7.
-
-        @deprecated: this method will not accept a single pair of vertex IDs
-          as an argument from igraph 0.7. Use L{add_edge()} instead to add
-          a single edge.
+          endpoints. Vertices are enumerated from zero.
         """
-        if isinstance(es, tuple) and len(es) == 2:
-            deprecated("Graph.add_edges() will not accept a single integer pair "
-                    "from igraph 0.7. Use Graph.add_edge() instead.")
-
-            return GraphBase.add_edges(self, [es])
         return GraphBase.add_edges(self, es)
 
     def add_vertex(self, name=None, **kwds):
@@ -351,7 +363,7 @@ class Graph(GraphBase):
 
     def indegree(self, *args, **kwds):
         """Returns the in-degrees in a list.
-        
+
         See L{degree} for possible arguments.
         """
         kwds['mode'] = IN
@@ -359,7 +371,7 @@ class Graph(GraphBase):
 
     def outdegree(self, *args, **kwds):
         """Returns the out-degrees in a list.
-        
+
         See L{degree} for possible arguments.
         """
         kwds['mode'] = OUT
@@ -409,7 +421,7 @@ class Graph(GraphBase):
     def biconnected_components(self, return_articulation_points=False):
         """\
         Calculates the biconnected components of the graph.
-        
+
         @param return_articulation_points: whether to return the articulation
           points as well
         @return: a L{VertexCover} object describing the biconnected components,
@@ -509,7 +521,7 @@ class Graph(GraphBase):
           (uses both parts). Ignored for directed graphs.
         @param attribute: if C{None}, returns the ordinary adjacency
           matrix. When the name of a valid edge attribute is given
-          here, the matrix returned will contain the default value 
+          here, the matrix returned will contain the default value
           at the places where there is no edge or the value of the
           given attribute where there is an edge. Multiple edges are
           not supported, the value written in the matrix in this case
@@ -537,7 +549,7 @@ class Graph(GraphBase):
             result -= 1
             return result
 
-        if attribute is None: 
+        if attribute is None:
             return Matrix(GraphBase.get_adjacency(self, type))
 
         if attribute not in self.es.attribute_names():
@@ -610,6 +622,31 @@ class Graph(GraphBase):
         """
         return [self.incident(idx, mode) for idx in xrange(self.vcount())]
 
+    def gomory_hu_tree(self, capacity=None, flow="flow"):
+        """gomory_hu_tree(capacity=None, flow="flow")
+
+        Calculates the Gomory-Hu tree of an undirected graph with optional
+        edge capacities.
+
+        The Gomory-Hu tree is a concise representation of the value of all the
+        maximum flows (or minimum cuts) in a graph. The vertices of the tree
+        correspond exactly to the vertices of the original graph in the same order.
+        Edges of the Gomory-Hu tree are annotated by flow values.  The value of
+        the maximum flow (or minimum cut) between an arbitrary (u,v) vertex
+        pair in the original graph is then given by the minimum flow value (i.e.
+        edge annotation) along the shortest path between u and v in the
+        Gomory-Hu tree.
+
+        @param capacity: the edge capacities (weights). If C{None}, all
+          edges have equal weight. May also be an attribute name.
+        @param flow: the name of the edge attribute in the returned graph
+          in which the flow values will be stored.
+        @return: the Gomory-Hu tree as a L{Graph} object.
+        """
+        graph, flow_values = GraphBase.gomory_hu_tree(self, capacity)
+        graph.es[flow] = flow_values
+        return graph
+
     def is_named(self):
         """is_named()
 
@@ -642,7 +679,7 @@ class Graph(GraphBase):
 
             2. For every vertex except the source and the target, the
                incoming flow is the same as the outgoing flow.
-               
+
         The value of the flow is the incoming flow of the target or the
         outgoing flow of the source (which are equal). The maximum flow
         is the maximum possible such value.
@@ -653,23 +690,57 @@ class Graph(GraphBase):
         """
         return Flow(self, *GraphBase.maxflow(self, source, target, capacity))
 
-    def mincut(self, capacity=None):
-        """mincut(capacity=None)
+    def mincut(self, source=None, target=None, capacity=None):
+        """mincut(source=None, target=None, capacity=None)
+
+        Calculates the minimum cut between the given source and target vertices
+        or within the whole graph.
+
+        The minimum cut is the minimum set of edges that needs to be removed to
+        separate the source and the target (if they are given) or to disconnect the
+        graph (if neither the source nor the target are given). The minimum is
+        calculated using the weights (capacities) of the edges, so the cut with
+        the minimum total capacity is calculated.
 
-        Returns a minimum cut in a graph.
+        For undirected graphs and no source and target, the method uses the
+        Stoer-Wagner algorithm. For a given source and target, the method uses the
+        push-relabel algorithm; see the references below.
 
+        @param source: the source vertex ID. If C{None}, the target must also be
+          C{None} and the calculation will be done for the entire graph (i.e.
+          all possible vertex pairs).
+        @param target: the target vertex ID. If C{None}, the source must also be
+          C{None} and the calculation will be done for the entire graph (i.e.
+          all possible vertex pairs).
         @param capacity: the edge capacities (weights). If C{None}, all
           edges have equal weight. May also be an attribute name.
         @return: a L{Cut} object describing the minimum cut
         """
-        return Cut(self, *GraphBase.mincut(self, capacity))
+        return Cut(self, *GraphBase.mincut(self, source, target, capacity))
+
+    def st_mincut(self, source, target, capacity=None):
+        """st_mincut(source, target, capacity=None)
+
+        Calculates the minimum cut between the source and target vertices in a
+        graph.
+
+        @param source: the source vertex ID
+        @param target: the target vertex ID
+        @param capacity: the capacity of the edges. It must be a list or a valid
+          attribute name or C{None}. In the latter case, every edge will have the
+          same capacity.
+        @return: the value of the minimum cut, the IDs of vertices in the
+          first and second partition, and the IDs of edges in the cut,
+          packed in a 4-tuple
+        """
+        return Cut(self, *GraphBase.st_mincut(self, source, target, capacity))
 
     def modularity(self, membership, weights=None):
         """modularity(membership, weights=None)
 
         Calculates the modularity score of the graph with respect to a given
         clustering.
-        
+
         The modularity of a graph w.r.t. some division measures how good the
         division is, or how separated are the different vertex types from each
         other. It's defined as M{Q=1/(2m)*sum(Aij-ki*kj/(2m)delta(ci,cj),i,j)}.
@@ -678,18 +749,18 @@ class Graph(GraphBase):
         node M{i}, M{kj} is the degree of node M{j}, and M{Ci} and C{cj} are
         the types of the two vertices (M{i} and M{j}). M{delta(x,y)} is one iff
         M{x=y}, 0 otherwise.
-        
+
         If edge weights are given, the definition of modularity is modified as
         follows: M{Aij} becomes the weight of the corresponding edge, M{ki}
         is the total weight of edges adjacent to vertex M{i}, M{kj} is the
         total weight of edges adjacent to vertex M{j} and M{m} is the total
         edge weight in the graph.
-        
+
         @param membership: a membership list or a L{VertexClustering} object
         @param weights: optional edge weights or C{None} if all edges are
           weighed equally. Attribute names are also allowed.
         @return: the modularity score
-        
+
         @newfield ref: Reference
         @ref: MEJ Newman and M Girvan: Finding and evaluating community
           structure in networks. Phys Rev E 69 026113, 2004.
@@ -722,9 +793,10 @@ class Graph(GraphBase):
         return hist
 
     def pagerank(self, vertices=None, directed=True, damping=0.85,
-            weights=None, arpack_options=None):
+                 weights=None, arpack_options=None, implementation="prpack",
+                 niter=1000, eps=0.001):
         """Calculates the Google PageRank values of a graph.
-        
+
         @param vertices: the indices of the vertices being queried.
           C{None} means all of the vertices.
         @param directed: whether to consider directed paths.
@@ -735,13 +807,30 @@ class Graph(GraphBase):
           or even an edge attribute name.
         @param arpack_options: an L{ARPACKOptions} object used to fine-tune
           the ARPACK eigenvector calculation. If omitted, the module-level
-          variable called C{arpack_options} is used.
+          variable called C{arpack_options} is used. This argument is
+          ignored if not the ARPACK implementation is used, see the
+          I{implementation} argument.
+        @param implementation: which implementation to use to solve the
+          PageRank eigenproblem. Possible values are:
+            - C{"prpack"}: use the PRPACK library. This is a new
+              implementation in igraph 0.7
+            - C{"arpack"}: use the ARPACK library. This implementation
+              was used from version 0.5, until version 0.7.
+            - C{"power"}: use a simple power method. This is the
+              implementation that was used before igraph version 0.5.
+        @param niter: The number of iterations to use in the power method
+          implementation. It is ignored in the other implementations
+        @param eps: The power method implementation will consider the
+          calculation as complete if the difference of PageRank values between
+          iterations change less than this value for every node. It is
+          ignored by the other implementations.
         @return: a list with the Google PageRank values of the specified
           vertices."""
         if arpack_options is None:
             arpack_options = _igraph.arpack_options
-        return self.personalized_pagerank(vertices, directed, damping, None, \
-                None, weights, arpack_options)
+        return self.personalized_pagerank(vertices, directed, damping, None,\
+                                          None, weights, arpack_options, \
+                                          implementation, niter, eps)
 
     def spanning_tree(self, weights=None, return_tree=True):
         """Calculates a minimum spanning tree for a graph.
@@ -789,7 +878,7 @@ class Graph(GraphBase):
           will be excluded from the average.
         @param weights: edge weights to be used. Can be a sequence or iterable
           or even an edge attribute name.
-        
+
         @see: L{transitivity_undirected()}, L{transitivity_local_undirected()}
         @newfield ref: Reference
         @ref: Watts DJ and Strogatz S: I{Collective dynamics of small-world
@@ -822,11 +911,11 @@ class Graph(GraphBase):
     def count_automorphisms_vf2(self, color=None, edge_color=None,
             node_compat_fn=None, edge_compat_fn=None):
         """Returns the number of automorphisms of the graph.
-        
+
         This function simply calls C{count_isomorphisms_vf2} with the graph
         itself. See C{count_isomorphisms_vf2} for an explanation of the
         parameters.
-        
+
         @return: the number of automorphisms of the graph
         @see: Graph.count_isomorphisms_vf2
         """
@@ -837,11 +926,11 @@ class Graph(GraphBase):
     def get_automorphisms_vf2(self, color=None, edge_color=None,
             node_compat_fn=None, edge_compat_fn=None):
         """Returns all the automorphisms of the graph
-        
+
         This function simply calls C{get_isomorphisms_vf2} with the graph
         itself. See C{get_isomorphisms_vf2} for an explanation of the
         parameters.
-        
+
         @return: a list of lists, each item containing a possible mapping
           of the graph vertices to itself according to the automorphism
         @see: Graph.get_isomorphisms_vf2
@@ -886,7 +975,7 @@ class Graph(GraphBase):
     def community_infomap(self, edge_weights=None, vertex_weights=None, trials=10):
         """Finds the community structure of the network according to the Infomap
         method of Martin Rosvall and Carl T. Bergstrom.
-        
+
         @param edge_weights: name of an edge attribute or a list containing
           edge weights.
         @param vertex_weights: name of an vertex attribute or a list containing
@@ -895,7 +984,7 @@ class Graph(GraphBase):
         @return: an appropriate L{VertexClustering} object with an extra attribute
           called C{codelength} that stores the code length determined by the
           algorithm.
-        
+
         @newfield ref: Reference
         @ref: M. Rosvall and C. T. Bergstrom: Maps of information flow reveal
           community structure in complex networks, PNAS 105, 1118 (2008).
@@ -934,7 +1023,7 @@ class Graph(GraphBase):
           dendrogram instead of a single clustering.
         @return: an appropriate L{VertexClustering} or L{VertexDendrogram}
           object.
-        
+
         @newfield ref: Reference
         @ref: MEJ Newman: Finding community structure in networks using the
         eigenvectors of matrices, arXiv:physics/0605087"""
@@ -948,27 +1037,39 @@ class Graph(GraphBase):
             return VertexDendrogram(self, merges, safemax(cl)+1)
 
 
-    def community_leading_eigenvector(self, clusters=None):
-        """community_leading_eigenvector(clusters=None)
-        
+    def community_leading_eigenvector(self, clusters=None, weights=None, \
+            arpack_options=None):
+        """community_leading_eigenvector(clusters=None, weights=None,
+          arpack_options=None)
+
         Newman's leading eigenvector method for detecting community structure.
         This is the proper implementation of the recursive, divisive algorithm:
         each split is done by maximizing the modularity regarding the
         original network.
-        
+
         @param clusters: the desired number of communities. If C{None}, the
           algorithm tries to do as many splits as possible. Note that the
           algorithm won't split a community further if the signs of the leading
           eigenvector are all the same, so the actual number of discovered
           communities can be less than the desired one.
+        @param weights: name of an edge attribute or a list containing
+          edge weights.
+        @param arpack_options: an L{ARPACKOptions} object used to fine-tune
+          the ARPACK eigenvector calculation. If omitted, the module-level
+          variable called C{arpack_options} is used.
         @return: an appropriate L{VertexClustering} object.
-        
+
         @newfield ref: Reference
         @ref: MEJ Newman: Finding community structure in networks using the
         eigenvectors of matrices, arXiv:physics/0605087"""
         if clusters is None:
             clusters = -1
-        membership, _, q = GraphBase.community_leading_eigenvector(self, clusters)
+
+        kwds = dict(weights=weights)
+        if arpack_options is not None:
+            kwds["arpack_options"] = arpack_options
+
+        membership, _, q = GraphBase.community_leading_eigenvector(self, clusters, **kwds)
         return VertexClustering(self, membership, modularity = q)
 
 
@@ -1017,7 +1118,7 @@ class Graph(GraphBase):
     def community_multilevel(self, weights=None, return_levels=False):
         """Community structure based on the multilevel algorithm of
         Blondel et al.
-        
+
         This is a bottom-up algorithm: initially every vertex belongs to a
         separate community, and vertices are moved between communities
         iteratively in a way that maximizes the vertices' local contribution
@@ -1172,18 +1273,18 @@ class Graph(GraphBase):
     def community_walktrap(self, weights=None, steps=4):
         """Community detection algorithm of Latapy & Pons, based on random
         walks.
-        
+
         The basic idea of the algorithm is that short random walks tend to stay
         in the same community. The result of the clustering will be represented
         as a dendrogram.
-        
+
         @param weights: name of an edge attribute or a list containing
           edge weights
         @param steps: length of random walks to perform
-        
+
         @return: a L{VertexDendrogram} object, initially cut at the maximum
           modularity.
-          
+
         @newfield ref: Reference
         @ref: Pascal Pons, Matthieu Latapy: Computing communities in large
           networks using random walks, U{http://arxiv.org/abs/physics/0512106}.
@@ -1246,6 +1347,8 @@ class Graph(GraphBase):
           - C{auto}, C{automatic}: automatic layout
             (see L{Graph.layout_auto})
 
+          - C{bipartite}: bipartite layout (see L{Graph.layout_bipartite})
+
           - C{circle}, C{circular}: circular layout
             (see L{Graph.layout_circle})
 
@@ -1260,16 +1363,12 @@ class Graph(GraphBase):
           - C{fr_3d}, C{fr3d}, C{fruchterman_reingold_3d}: 3D Fruchterman-
             Reingold layout (see L{Graph.layout_fruchterman_reingold}).
 
-          - C{grid}: regular grid layout in 2D (see L{Graph.layout_grid}) 
+          - C{grid}: regular grid layout in 2D (see L{Graph.layout_grid})
 
           - C{grid_3d}: regular grid layout in 3D (see L{Graph.layout_grid_3d})
 
           - C{graphopt}: the graphopt algorithm (see L{Graph.layout_graphopt})
 
-          - C{gfr}, C{grid_fr}, C{grid_fruchterman_reingold}: grid-based
-            Fruchterman-Reingold layout
-            (see L{Graph.layout_grid_fruchterman_reingold})
-
           - C{kk}, C{kamada_kawai}: Kamada-Kawai layout
             (see L{Graph.layout_kamada_kawai})
 
@@ -1392,6 +1491,19 @@ class Graph(GraphBase):
             algo = "drl"
         return self.layout(algo, *args, **kwds)
 
+    def layout_grid_fruchterman_reingold(self, *args, **kwds):
+        """layout_grid_fruchterman_reingold(*args, **kwds)
+
+        Compatibility alias to the Fruchterman-Reingold layout with the grid
+        option turned on.
+
+        @see: Graph.layout_fruchterman_reingold()
+        """
+        deprecated("Graph.layout_grid_fruchterman_reingold() is deprecated since "\
+            "igraph 0.8, please use Graph.layout_fruchterman_reingold(grid=True) instead")
+        kwds["grid"] = True
+        return self.layout_fruchterman_reingold(*args, **kwds)
+
     def layout_sugiyama(self, layers=None, weights=None, hgap=1, vgap=1,
             maxiter=100, return_extended_graph=False):
         """layout_sugiyama(layers=None, weights=None, hgap=1, vgap=1, maxiter=100,
@@ -1461,11 +1573,11 @@ class Graph(GraphBase):
 
     def maximum_bipartite_matching(self, types="type", weights=None, eps=None):
         """Finds a maximum matching in a bipartite graph.
-        
+
         A maximum matching is a set of edges such that each vertex is incident on
         at most one matched edge and the number (or weight) of such edges in the
         set is as large as possible.
-        
+
         @param types: vertex types in a list or the name of a vertex attribute
           holding vertex types. Types should be denoted by zeros and ones (or
           C{False} and C{True}) for the two sides of the bipartite graph.
@@ -1529,7 +1641,7 @@ class Graph(GraphBase):
         @return: the created graph"""
         if isinstance(f, basestring):
             f = open(f)
-        matrix, ri, weights = [], 0, {} 
+        matrix, ri, weights = [], 0, {}
         for line in f:
             line = line.strip()
             if len(line) == 0: continue
@@ -1587,11 +1699,10 @@ class Graph(GraphBase):
           produces the least compression, and 9 is slowest and produces
           the most compression."""
         from igraph.utils import named_temporary_file
-        with named_temporary_file(text=True) as tmpfile:
+        with named_temporary_file() as tmpfile:
             self.write_graphml(tmpfile)
             outf = gzip.GzipFile(f, "wb", compresslevel)
-            for line in open(tmpfile):
-                outf.write(line)
+            copyfileobj(open(tmpfile, "rb"), outf)
             outf.close()
 
     @classmethod
@@ -1640,10 +1751,9 @@ class Graph(GraphBase):
           specify 0 here.
         @return: the loaded graph object"""
         from igraph.utils import named_temporary_file
-        with named_temporary_file(text=True) as tmpfile:
-            outf = open(tmpfile, "wt")
-            for line in gzip.GzipFile(f, "rb"):
-                outf.write(line)
+        with named_temporary_file() as tmpfile:
+            outf = open(tmpfile, "wb")
+            copyfileobj(gzip.GzipFile(f, "rb"), outf)
             outf.close()
             return cls.Read_GraphML(tmpfile)
 
@@ -1771,13 +1881,14 @@ class Graph(GraphBase):
     def write_svg(self, fname, layout="auto", width=None, height=None, \
                   labels="label", colors="color", shapes="shape", \
                   vertex_size=10, edge_colors="color", \
+                  edge_stroke_widths="width", \
                   font_size=16, *args, **kwds):
         """Saves the graph as an SVG (Scalable Vector Graphics) file
-        
+
         The file will be Inkscape (http://inkscape.org) compatible.
         In Inkscape, as nodes are rearranged, the edges auto-update.
-        
-        @param fname: the name of the file
+
+        @param fname: the name of the file or a Python file handle
         @param layout: the layout of the graph. Can be either an
           explicitly specified layout (using a list of coordinate
           pairs) or the name of a layout algorithm (which should
@@ -1802,6 +1913,10 @@ class Graph(GraphBase):
           of an edge attribute to use, or a list explicitly specifying
           the colors. A color can be anything acceptable in an SVG
           file.
+        @param edge_stroke_widths: the stroke widths of the edges. Either
+          it is the name of an edge attribute to use, or a list explicitly
+          specifying the stroke widths. The stroke width can be anything
+          acceptable in an SVG file.
         @param font_size: font size. If it is a string, it is written into
           the SVG file as-is (so you can specify anything which is valid
           as the value of the C{font-size} style). If it is a number, it
@@ -1815,7 +1930,7 @@ class Graph(GraphBase):
             width = height
         elif height is None:
             height = width
-                
+
         if width <= 0 or height <= 0:
             raise ValueError("width and height must be positive")
 
@@ -1834,19 +1949,25 @@ class Graph(GraphBase):
             try:
                 colors = self.vs.get_attribute_values(colors)
             except KeyError:
-                colors = ["red" for x in xrange(self.vcount())]
+                colors = ["red"] * self.vcount()
 
         if isinstance(shapes, str):
             try:
                 shapes = self.vs.get_attribute_values(shapes)
             except KeyError:
                 shapes = [1] * self.vcount()
-        
... 13577 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-igraph.git



More information about the Python-modules-commits mailing list