pygraphviz-1.3.1/0000755000175000017500000000000012573042274013603 5ustar aricaric00000000000000pygraphviz-1.3.1/setup.cfg0000644000175000017500000000060712573042274015427 0ustar aricaric00000000000000[bdist_rpm] release = 1 packager = Aric Hagberg doc_files = README doc/Readme.txt provides = python-pygraphviz requires = python graphviz build-requires = python-dev graphviz-dev [nosetests] verbosity = 2 detailed-errors = 1 with-doctest = 1 with-id = 1 doctest-extension = txt with-doctest-ignore-unicode = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pygraphviz-1.3.1/pygraphviz.egg-info/0000755000175000017500000000000012573042274017500 5ustar aricaric00000000000000pygraphviz-1.3.1/pygraphviz.egg-info/PKG-INFO0000644000175000017500000000267212573042274020604 0ustar aricaric00000000000000Metadata-Version: 1.1 Name: pygraphviz Version: 1.3.1 Summary: Python interface to Graphviz Home-page: http://pygraphviz.github.io Author: Aric Hagberg Author-email: aric.hagberg@gmail.com License: BSD Download-URL: https://pypi.python.org/pypi/pygraphviz Description: PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms. PyGraphviz provides a similar programming interface to NetworkX (http://networkx.github.io). Keywords: Networks,Graph Visualization,network,graph,graph drawing Platform: Linux Platform: Mac OSX Platform: Microsoft :: Windows Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: C Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Scientific/Engineering :: Information Analysis Classifier: Topic :: Scientific/Engineering :: Mathematics Classifier: Topic :: Scientific/Engineering :: Visualization pygraphviz-1.3.1/pygraphviz.egg-info/SOURCES.txt0000644000175000017500000000343012573042274021364 0ustar aricaric00000000000000INSTALL.txt LICENSE MANIFEST.in Makefile README.rst pystrings.swg setup.cfg setup.py setup_commands.py setup_extra.py tox.ini doc/Makefile doc/gh-pages.py doc/source/conf.py doc/source/download.rst doc/source/examples.rst doc/source/index.rst doc/source/install.rst doc/source/tutorial.rst doc/source/reference/agraph.rst doc/source/reference/api_notes.rst doc/source/reference/credits.rst doc/source/reference/faq.rst doc/source/reference/history.rst doc/source/reference/index.rst doc/source/reference/legal.rst doc/source/reference/news.rst doc/source/reference/related.rst doc/source/static/contents.png doc/source/static/empty.txt doc/source/static/navigation.png doc/source/static/sphinxdoc.css doc/source/templates/index.html doc/source/templates/indexsidebar.html doc/source/templates/layout.html doc/sphinxext/only_directives.py examples/attributes.py examples/django_simple.py examples/miles.py examples/miles_dat.txt.gz examples/simple.py examples/star.py examples/subgraph.py examples/utf8_encoding.py pygraphviz/__init__.py pygraphviz/agraph.py pygraphviz/graphviz.i pygraphviz/graphviz.py pygraphviz/graphviz_wrap.c pygraphviz/release.py pygraphviz/version.py pygraphviz.egg-info/PKG-INFO pygraphviz.egg-info/SOURCES.txt pygraphviz.egg-info/dependency_links.txt pygraphviz.egg-info/top_level.txt pygraphviz/tests/__init__.py pygraphviz/tests/test.py pygraphviz/tests/test_attribute_defaults.py pygraphviz/tests/test_attributes.py pygraphviz/tests/test_clear.py pygraphviz/tests/test_drawing.py pygraphviz/tests/test_edge_attributes.py pygraphviz/tests/test_graph.py pygraphviz/tests/test_html.py pygraphviz/tests/test_layout.py pygraphviz/tests/test_node_attributes.py pygraphviz/tests/test_readwrite.py pygraphviz/tests/test_string.py pygraphviz/tests/test_subgraph.py pygraphviz/tests/test_unicode.pypygraphviz-1.3.1/pygraphviz.egg-info/dependency_links.txt0000644000175000017500000000000112573042274023546 0ustar aricaric00000000000000 pygraphviz-1.3.1/pygraphviz.egg-info/top_level.txt0000644000175000017500000000001312573042274022224 0ustar aricaric00000000000000pygraphviz pygraphviz-1.3.1/PKG-INFO0000644000175000017500000000267212573042274014707 0ustar aricaric00000000000000Metadata-Version: 1.1 Name: pygraphviz Version: 1.3.1 Summary: Python interface to Graphviz Home-page: http://pygraphviz.github.io Author: Aric Hagberg Author-email: aric.hagberg@gmail.com License: BSD Download-URL: https://pypi.python.org/pypi/pygraphviz Description: PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms. PyGraphviz provides a similar programming interface to NetworkX (http://networkx.github.io). Keywords: Networks,Graph Visualization,network,graph,graph drawing Platform: Linux Platform: Mac OSX Platform: Microsoft :: Windows Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: C Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Scientific/Engineering :: Information Analysis Classifier: Topic :: Scientific/Engineering :: Mathematics Classifier: Topic :: Scientific/Engineering :: Visualization pygraphviz-1.3.1/setup_commands.py0000644000175000017500000000440112573042175017175 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Setup commands for PyGraphviz. """ # Copyright (C) 2006-2014 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. # # Derived from http://www.niteoweb.com/blog/setuptools-run-custom-code-during-install # Author: Maksym Markov from setuptools.command.develop import develop from setuptools.command.install import install from setup_extra import get_graphviz_dirs def add_extensions(command_subclass): """A decorator for classes subclassing one of the setuptools commands. It modifies the run() method so that it prints a friendly greeting. """ orig_init = command_subclass.__init__ orig_initialize_options = command_subclass.initialize_options orig_run = command_subclass.run command_subclass.user_options.extend([('include-path=', None, 'path to graphviz include files.'), ('library-path=', None, 'path to graphviz library files.')]) def __init__(self, *args, **kws): orig_init(self, *args, **kws) def modified_initialize_options(self): self.include_path = None self.library_path = None orig_initialize_options(self) def modified_run(self): # Add extension here # if there is no library_path and include_path passed form command line then try identify them if (not self.include_path) or (not self.library_path): self.include_path, self.library_path = get_graphviz_dirs() if self.distribution and self.distribution.ext_modules: for m in self.distribution.ext_modules: if m.name == 'pygraphviz._graphviz': m.include_dirs.append(self.include_path) m.library_dirs.append(self.library_path) orig_run(self) command_subclass.__init__ = __init__ command_subclass.initialize_options = modified_initialize_options command_subclass.run = modified_run return command_subclass @add_extensions class AddExtensionDevelopCommand(develop): pass @add_extensions class AddExtensionInstallCommand(install): passpygraphviz-1.3.1/pygraphviz/0000755000175000017500000000000012573042274016006 5ustar aricaric00000000000000pygraphviz-1.3.1/pygraphviz/release.py0000644000175000017500000000750512573042175020007 0ustar aricaric00000000000000# -*- coding: utf-8 -*- """Release data for PyGraphviz.""" # Copyright (C) 2006-2013 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. import os import re def write_versionfile(): """Creates a file containing version information.""" base = os.path.split(__file__)[0] versionfile = os.path.join(base, 'version.py') if revision is None and os.path.isfile(versionfile): # Unable to get revision info, so probably not in an SVN directory # If a version.py already exists, let's not overwrite it. # Useful mostly for nightly tarballs. return fh = open(versionfile, 'w') text = '''""" Version information for PyGraphviz, created during installation. Do not add this file to the repository. """ __version__ = '%(version)s' __revision__ = %(revision)s __date__ = '%(date)s' ''' if revision is not None: rev = "'%s'" % (revision,) else: rev = revision subs = {'version': version, 'revision': rev, 'date': date} fh.write(text % subs) fh.close() def get_svn_revision(): rev = None base = os.path.split(__file__)[0] entries_path = os.path.join(base, '.svn', 'entries') if os.path.isfile(entries_path): entries = open(entries_path, 'r').read() # Versions >= 7 of the entries file are flat text. The first line is # the version number. The next set of digits after 'dir' is the revision. if re.match('(\d+)', entries): rev_match = re.search('\d+\s+dir\s+(\d+)', entries) if rev_match: rev = rev_match.groups()[0] if rev: return rev else: return None name = 'pygraphviz' version = '1.3.1' # Declare current release as a development release. # Change to False before tagging a release; then change back. dev = False revision = None if dev: version += '.dev' revision = get_svn_revision() if revision is not None: version += "%s" % revision description = "Python interface to Graphviz" long_description = """\ PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms. PyGraphviz provides a similar programming interface to NetworkX (http://networkx.github.io). """ license = 'BSD' authors = {'Hagberg' : ('Aric Hagberg','aric.hagberg@gmail.com'), 'Schult' : ('Dan Schult','dschult@colgate.edu'), 'Renieris' : ('Manos Renieris','') } url = 'http://pygraphviz.github.io' download_url="https://pypi.python.org/pypi/pygraphviz" platforms = ['Linux','Mac OSX','Microsoft :: Windows'] keywords = ['Networks', 'Graph Visualization', 'network', 'graph', 'graph drawing'] classifiers = [ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: BSD License', 'Programming Language :: C', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Scientific/Engineering :: Visualization', ] # Get date dynamically import time date = time.asctime() del time if __name__ == '__main__': # Write versionfile for nightly snapshots. write_versionfile() pygraphviz-1.3.1/pygraphviz/__init__.py0000644000175000017500000000336412573042175020125 0ustar aricaric00000000000000""" A Python wrapper for the graphviz Agraph data structure. Quick example:: >>> from pygraphviz import * >>> G=AGraph() >>> G.add_node('a') >>> G.add_edge('b','c') >>> print G # doctest: +SKIP strict graph { a; b -- c; } See pygraphviz.AGraph for detailed documentation. """ # Copyright (C) 2004-2010 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import absolute_import from __future__ import print_function from __future__ import division # Release data from . import release if release.revision is None: # we probably not running in an svn directory try: # use release data stored at installatation time. from . import version __version__ = version.__version__ __revision__ = version.__revision__ __date__ = version.__date__ except ImportError: # version.py was not created or no longer exists __version__ = release.version __revision__ = release.revision __date__ = release.date else: # use dynamic values, even if version.py exists __version__ = release.version __revision__ = release.revision __date__ = release.date __author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \ ( release.authors['Hagberg'] + release.authors['Schult'] + \ release.authors['Renieris'] ) __license__ = release.license from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError __all__=[ 'AGraph', 'Node', 'Edge', 'Attribute', 'ItemAttribute', 'DotError' ] from pygraphviz.tests.test import run as test pygraphviz-1.3.1/pygraphviz/graphviz.py0000644000175000017500000001713212573042175020216 0ustar aricaric00000000000000# This file was automatically generated by SWIG (http://www.swig.org). # Version 3.0.2 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info if version_info >= (2,6,0): def swig_import_helper(): from os.path import dirname import imp fp = None try: fp, pathname, description = imp.find_module('_graphviz', [dirname(__file__)]) except ImportError: import _graphviz return _graphviz if fp is not None: try: _mod = imp.load_module('_graphviz', fp, pathname, description) finally: fp.close() return _mod _graphviz = swig_import_helper() del swig_import_helper else: import _graphviz del version_info try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0) def _swig_getattr(self,class_type,name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError(name) def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) try: _object = object _newclass = 1 except AttributeError: class _object : pass _newclass = 0 def agopen(*args): return _graphviz.agopen(*args) agopen = _graphviz.agopen def agraphnew(name,strict=False,directed=False): if strict: if directed: return _graphviz.agopen(name,cvar.Agstrictdirected,None) else: return _graphviz.agopen(name,cvar.Agstrictundirected,None) else: if directed: return _graphviz.agopen(name,cvar.Agdirected,None) else: return _graphviz.agopen(name,cvar.Agundirected,None) def agclose(*args): return _graphviz.agclose(*args) agclose = _graphviz.agclose def agread(*args): return _graphviz.agread(*args) agread = _graphviz.agread def agwrite(*args): return _graphviz.agwrite(*args) agwrite = _graphviz.agwrite def agisundirected(*args): return _graphviz.agisundirected(*args) agisundirected = _graphviz.agisundirected def agisdirected(*args): return _graphviz.agisdirected(*args) agisdirected = _graphviz.agisdirected def agisstrict(*args): return _graphviz.agisstrict(*args) agisstrict = _graphviz.agisstrict def agnode(*args): return _graphviz.agnode(*args) agnode = _graphviz.agnode def agidnode(*args): return _graphviz.agidnode(*args) agidnode = _graphviz.agidnode def agsubnode(*args): return _graphviz.agsubnode(*args) agsubnode = _graphviz.agsubnode def agfstnode(*args): return _graphviz.agfstnode(*args) agfstnode = _graphviz.agfstnode def agnxtnode(*args): return _graphviz.agnxtnode(*args) agnxtnode = _graphviz.agnxtnode def aglstnode(*args): return _graphviz.aglstnode(*args) aglstnode = _graphviz.aglstnode def agprvnode(*args): return _graphviz.agprvnode(*args) agprvnode = _graphviz.agprvnode def agedge(*args): return _graphviz.agedge(*args) agedge = _graphviz.agedge def agidedge(*args): return _graphviz.agidedge(*args) agidedge = _graphviz.agidedge def agsubedge(*args): return _graphviz.agsubedge(*args) agsubedge = _graphviz.agsubedge def agfstin(*args): return _graphviz.agfstin(*args) agfstin = _graphviz.agfstin def agnxtin(*args): return _graphviz.agnxtin(*args) agnxtin = _graphviz.agnxtin def agfstout(*args): return _graphviz.agfstout(*args) agfstout = _graphviz.agfstout def agnxtout(*args): return _graphviz.agnxtout(*args) agnxtout = _graphviz.agnxtout def agfstedge(*args): return _graphviz.agfstedge(*args) agfstedge = _graphviz.agfstedge def agnxtedge(*args): return _graphviz.agnxtedge(*args) agnxtedge = _graphviz.agnxtedge def aghead(*args): return _graphviz.aghead(*args) aghead = _graphviz.aghead def agtail(*args): return _graphviz.agtail(*args) agtail = _graphviz.agtail def agattr(*args): return _graphviz.agattr(*args) agattr = _graphviz.agattr def agattrsym(*args): return _graphviz.agattrsym(*args) agattrsym = _graphviz.agattrsym def agnxtattr(*args): return _graphviz.agnxtattr(*args) agnxtattr = _graphviz.agnxtattr def agget(*args): return _graphviz.agget(*args) agget = _graphviz.agget def agxget(*args): return _graphviz.agxget(*args) agxget = _graphviz.agxget def agset(*args): return _graphviz.agset(*args) agset = _graphviz.agset def agxset(*args): return _graphviz.agxset(*args) agxset = _graphviz.agxset def agsafeset(*args): return _graphviz.agsafeset(*args) agsafeset = _graphviz.agsafeset def agattrname(*args): return _graphviz.agattrname(*args) agattrname = _graphviz.agattrname def agattrdefval(*args): return _graphviz.agattrdefval(*args) agattrdefval = _graphviz.agattrdefval def agsafeset_label(*args): return _graphviz.agsafeset_label(*args) agsafeset_label = _graphviz.agsafeset_label def agattr_label(*args): return _graphviz.agattr_label(*args) agattr_label = _graphviz.agattr_label def agsubg(*args): return _graphviz.agsubg(*args) agsubg = _graphviz.agsubg def agfstsubg(*args): return _graphviz.agfstsubg(*args) agfstsubg = _graphviz.agfstsubg def agnxtsubg(*args): return _graphviz.agnxtsubg(*args) agnxtsubg = _graphviz.agnxtsubg def agparent(*args): return _graphviz.agparent(*args) agparent = _graphviz.agparent def agroot(*args): return _graphviz.agroot(*args) agroot = _graphviz.agroot def agdelsubg(*args): return _graphviz.agdelsubg(*args) agdelsubg = _graphviz.agdelsubg def agnnodes(*args): return _graphviz.agnnodes(*args) agnnodes = _graphviz.agnnodes def agnedges(*args): return _graphviz.agnedges(*args) agnedges = _graphviz.agnedges def agdegree(*args): return _graphviz.agdegree(*args) agdegree = _graphviz.agdegree def agraphof(*args): return _graphviz.agraphof(*args) agraphof = _graphviz.agraphof def agnameof(*args): return _graphviz.agnameof(*args) agnameof = _graphviz.agnameof def agdelnode(*args): return _graphviz.agdelnode(*args) agdelnode = _graphviz.agdelnode def agdeledge(*args): return _graphviz.agdeledge(*args) agdeledge = _graphviz.agdeledge def agnameof(handle): name=_graphviz.agnameof(handle) if name is None: return None if name==b'' or name.startswith(b'%'): return None else: return name AGRAPH = _graphviz.AGRAPH AGNODE = _graphviz.AGNODE AGOUTEDGE = _graphviz.AGOUTEDGE AGINEDGE = _graphviz.AGINEDGE AGEDGE = _graphviz.AGEDGE # This file is compatible with both classic and new-style classes. cvar = _graphviz.cvar Agdirected = cvar.Agdirected Agstrictdirected = cvar.Agstrictdirected Agundirected = cvar.Agundirected Agstrictundirected = cvar.Agstrictundirected pygraphviz-1.3.1/pygraphviz/graphviz.i0000644000175000017500000001703412573042175020017 0ustar aricaric00000000000000# Copyright (C) 2004-2006 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. %module graphviz %{ #include "graphviz/cgraph.h" %} %{ #if PY_VERSION_HEX >= 0x03000000 extern PyTypeObject PyIOBase_Type; #endif %} %typemap(in) FILE* (int fd, PyObject *mode_obj, PyObject *mode_byte_obj, char *mode) { %#if PY_VERSION_HEX >= 0x03000000 if (!PyObject_IsInstance($input, (PyObject *)&PyIOBase_Type)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } // work around to get hold of FILE* fd = PyObject_AsFileDescriptor($input); mode_obj = PyObject_GetAttrString($input, "mode"); mode_byte_obj = PyUnicode_AsUTF8String(mode_obj); mode = PyBytes_AsString(mode_byte_obj); $1 = fdopen(fd, mode); Py_XDECREF(mode_obj); Py_XDECREF(mode_byte_obj); %#else if (!PyFile_Check($input)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } $1 = PyFile_AsFile($input); %#endif } %exception agnode { $action if (!result) { PyErr_SetString(PyExc_KeyError,"agnode: no key"); return NULL; } } %exception agedge { $action if (!result) { PyErr_SetString(PyExc_KeyError,"agedge: no key"); return NULL; } } /* agset returns -1 on error */ %exception agset { $action if (result==-1) { PyErr_SetString(PyExc_KeyError,"agset: no key"); return NULL; } } /* agsetsafeset_label returns -1 on error */ %exception agsafeset_label { $action if (result==-1) { PyErr_SetString(PyExc_KeyError,"agsafeset_label: Error"); return NULL; } } /* agdelnode returns -1 on error */ %exception agdelnode { $action if (result==-1) { PyErr_SetString(PyExc_KeyError,"agdelnode: no key"); return NULL; } } %exception agnxtattr { $action if (!result) { PyErr_SetString(PyExc_StopIteration,"agnxtattr"); return NULL; } } %exception agattr { $action if (!result) { PyErr_SetString(PyExc_KeyError,"agattr: no key"); return NULL; } } %exception agattr_label { $action if (!result) { PyErr_SetString(PyExc_KeyError,"agattr_label: no key"); return NULL; } } %exception agread { $action if (!result) { PyErr_SetString(PyExc_ValueError,"agread: bad input data"); return NULL; } } /* graphs */ Agraph_t *agopen(char *name, Agdesc_t kind, Agdisc_t *disc); /* some helpers to avoid using cvar in python modules */ %pythoncode %{ def agraphnew(name,strict=False,directed=False): if strict: if directed: return _graphviz.agopen(name,cvar.Agstrictdirected,None) else: return _graphviz.agopen(name,cvar.Agstrictundirected,None) else: if directed: return _graphviz.agopen(name,cvar.Agdirected,None) else: return _graphviz.agopen(name,cvar.Agundirected,None) %} int agclose(Agraph_t *g); Agraph_t *agread(FILE *file, Agdisc_t *); int agwrite(Agraph_t *g, FILE *file); int agisundirected(Agraph_t * g); int agisdirected(Agraph_t * g); int agisstrict(Agraph_t * g); /* void agclean(Agraph_t *g, int kind, int *rec) */ /* Agraph_t *agconcat(Agraph_t *g, FILE *file, Agdisc_t *disc); */ /* nodes */ Agnode_t *agnode(Agraph_t *g, char *name, int createflag); Agnode_t *agidnode(Agraph_t * g, unsigned long id, int createflag); Agnode_t *agsubnode(Agraph_t *g, Agnode_t *n, int createflag); Agnode_t *agfstnode(Agraph_t *g); Agnode_t *agnxtnode(Agraph_t *g, Agnode_t *n); Agnode_t *aglstnode(Agraph_t * g); Agnode_t *agprvnode(Agraph_t * g, Agnode_t * n); /* Agsubnode_t *agsubrep(Agraph_t * g, Agnode_t * n); */ /* edges */ Agedge_t *agedge(Agraph_t * g, Agnode_t * t, Agnode_t * h, char *name, int createflag); Agedge_t *agidedge(Agraph_t * g, Agnode_t * t, Agnode_t * h, unsigned long id, int createflag); Agedge_t *agsubedge(Agraph_t * g, Agedge_t * e, int createflag); Agedge_t *agfstin(Agraph_t * g, Agnode_t * n); Agedge_t *agnxtin(Agraph_t * g, Agedge_t * e); Agedge_t *agfstout(Agraph_t * g, Agnode_t * n); Agedge_t *agnxtout(Agraph_t * g, Agedge_t * e); Agedge_t *agfstedge(Agraph_t * g, Agnode_t * n); Agedge_t *agnxtedge(Agraph_t * g, Agedge_t * e, Agnode_t * n); Agnode_t *aghead(Agedge_t *e); Agnode_t *agtail(Agedge_t *e); /* attributes */ Agsym_t *agattr(Agraph_t *g, int kind, char *name, char *value); Agsym_t *agattrsym(void *obj, char *name); Agsym_t *agnxtattr(Agraph_t *g, int kind, Agsym_t *attr); char *agget(void *obj, char *name); char *agxget(void *obj, Agsym_t *sym); int agset(void *obj, char *name, char *value); int agxset(void *obj, Agsym_t *sym, char *value); int agsafeset(void *obj, char *name, char *value, char *def); %inline %{ char *agattrname(Agsym_t *atsym) { return atsym->name; } %} %inline %{ char *agattrdefval(Agsym_t *atsym) { return atsym->defval; } %} /* styled from gv.cpp in Graphviz to handle <> html data in label */ %inline %{ int agsafeset_label(Agraph_t *g, void *obj, char *name, char *val, char *def) { int len; char *hs; if (val[0] == '<' && (strcmp(name, "label") == 0 || strcmp(name, "xlabel") == 0)) { len = strlen(val); if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; val = agstrdup_html(g,hs); free(hs); } } return agsafeset(obj, name, val,def); } %} /* styled from gv.cpp in Graphviz to handle <> html data in label */ %inline %{ int agattr_label(Agraph_t *g, int kind, char *name, char *val) { int len; char *hs; if (val[0] == '<' && (strcmp(name, "label") == 0 || strcmp(name, "xlabel") == 0)) { len = strlen(val); if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; val = agstrdup_html(g,hs); free(hs); } } return agattr(g, kind, name, val); } %} /* subgraphs */ Agraph_t *agsubg(Agraph_t *g, char *name, int createflag); Agraph_t *agfstsubg(Agraph_t *g); Agraph_t *agnxtsubg(Agraph_t *subg); Agraph_t *agparent(Agraph_t *g); Agraph_t *agroot(Agraph_t *g); /* Agedge_t *agsubedge(Agraph_t *g, Agedge_t *e, int createflag); */ long agdelsubg(Agraph_t *g, Agraph_t *sub); /* cardinality */ int agnnodes(Agraph_t * g); int agnedges(Agraph_t * g); int agdegree(Agraph_t * g, Agnode_t * n, int in, int out); /* generic */ Agraph_t *agraphof(void*); char *agnameof(void*); int agdelnode(Agraph_t * g, Agnode_t * arg_n); int agdeledge(Agraph_t * g, Agedge_t * arg_e); /* This pretty code finds anonymous items (start with %) or items with no label and returns None. Useful for anonymous edges . */ %pythoncode %{ def agnameof(handle): name=_graphviz.agnameof(handle) if name is None: return None if name==b'' or name.startswith(b'%'): return None else: return name %} /* Agdesc_t Agdirected, Agstrictdirected, Agundirected, Agstrictundirected; */ /* constants are safer */ /* directed, strict, noloops, maingraph */ const Agdesc_t Agdirected = { 1, 0, 0, 1 }; const Agdesc_t Agstrictdirected = { 1, 1, 0, 1 }; const Agdesc_t Agundirected = { 0, 0, 0, 1 }; const Agdesc_t Agstrictundirected = { 0, 1, 0, 1 }; #define AGRAPH 0 /* can't exceed 2 bits. see Agtag_t. */ #define AGNODE 1 #define AGOUTEDGE 2 #define AGINEDGE 3 /* (1 << 1) indicates an edge tag. */ #define AGEDGE AGOUTEDGE /* synonym in object kind args */ pygraphviz-1.3.1/pygraphviz/tests/0000755000175000017500000000000012573042274017150 5ustar aricaric00000000000000pygraphviz-1.3.1/pygraphviz/tests/test_edge_attributes.py0000644000175000017500000000404212573042175023733 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals from nose.tools import * import pygraphviz as pgv from os import linesep def test_edge_attributes(): A = pgv.AGraph() A.add_edge(1,2,label='test',spam='eggs') assert_equal(A.string().expandtabs(2), """strict graph { 1 -- 2 [label=test, spam=eggs]; } """.replace('\n', linesep) ) def test_edge_attributes2(): A = pgv.AGraph() A.add_edge(1,2) one = A.get_edge(1,2) one.attr['label'] = 'test' one.attr['spam'] = 'eggs' assert_true('label' in one.attr) assert_equal(one.attr['label'], 'test') assert_equal(sorted(one.attr.keys()), ['label', 'spam']) assert_equal(A.string().expandtabs(2), """strict graph { 1 -- 2 [label=test, spam=eggs]; } """.replace('\n', linesep) ) one.attr['label'] = '' one.attr['spam'] = '' assert_equal(A.string().expandtabs(2), """strict graph { 1 -- 2; } """.replace('\n', linesep) ) one.attr['label'] = 'test' del one.attr['label'] assert_equal(A.string().expandtabs(2), """strict graph { 1 -- 2; } """.replace('\n', linesep) ) def _test_anonymous_edges(): """graph test {\n a -- b [label="edge1"];\n a -- b [label="edge2"];\n }""" import os,tempfile fd, fname = tempfile.mkstemp() #os.write(d) #os.close(fd) #A = AGraph(fname) assert_equal(A.string().expandtabs(2), """graph test { a -- b [label=edge1]; a -- b [label=edge2]; } """.replace('\n', linesep)) os.unlink(fname) def test_edge_attribute_update(): A = pgv.AGraph(strict=True) A.add_edge(1,2,label='test',spam='eggs') A.add_edge(1,2,label='update',spam='') assert_equal(A.string().expandtabs(2), """strict graph { 1 -- 2 [label=update]; } """.replace('\n', linesep) ) def test_edge_attribute_update_nonstrict(): A = pgv.AGraph(strict=False) A.add_edge(1,2,label='test',spam='eggs',key='one') A.add_edge(1,2,label='update',spam='',key='one') assert_equal(A.string().expandtabs(2), """graph { 1 -- 2 [key=one, label=update]; } """.replace('\n', linesep) ) pygraphviz-1.3.1/pygraphviz/tests/test_string.py0000644000175000017500000000206412573042175022071 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import assert_equal, raises import pygraphviz as pgv from os import linesep def test_name(): A = pgv.AGraph(name='') assert_equal(A.string(), """strict graph { } """.replace('\n', linesep)) assert_equal(A.string().expandtabs(), """strict graph { } """.replace('\n', linesep)) assert_equal( A.__repr__()[0:7],'World>]; sa; } a; } """.replace('\n', linesep)) def test_subgraph_cluster_attribute(): G = pgv.AGraph() s = G.subgraph(name='cluster_a') s.node_attr['foo']='bar' G.add_node('a') G.node_attr['foo']='baz' assert_equal(G.string().expandtabs(2), """strict graph { node [foo=baz]; subgraph cluster_a { graph [foo=bar]; } a; } """.replace('\n', linesep)) pygraphviz-1.3.1/pygraphviz/tests/test_readwrite.py0000644000175000017500000000060712573042175022552 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv def test_readwrite(): A = pgv.AGraph(name='test graph') A.add_path([1,2,3,4,5,6,7,8,9,10]) #FIXME # >>> (fd,fname)=tempfile.mkstemp() # A.write(fname) # A.read(fname) # assert_equal(B, AGraph(fname)) # assert_true(B == A) # assert_false(B is A) # >>> os.close(fd) # >>> os.unlink(fname) pygraphviz-1.3.1/pygraphviz/tests/test_clear.py0000644000175000017500000000165012573042175021651 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv def test_del(): A = pgv.AGraph() A.add_node(1,foo='bar') # For some reasons after porting to Python 3 clear often cause infinite loop A.delete_node('1') assert_equal(len(A), 0) def test_clear_node_with_attributes(): A = pgv.AGraph() A.add_node(1,foo='bar') # For some reasons after porting to Python 3 clear often cause infinite loop A.clear() assert_equal(len(A), 0) assert_equal(A.nodes(), []) assert_equal(A.node_attr.keys(), []) def test_clear_graph_attributes(): A = pgv.AGraph() A.add_node(1,foo='bar') A.graph_attr.update(landscape='true',ranksep='0.1') # For some reasons after porting to Python 3 clear often cause infinite loop A.clear() assert_equal(len(A), 0) assert_equal(A.nodes(), []) assert_equal(A.node_attr.keys(), []) assert_equal(A.graph_attr.keys(), [])pygraphviz-1.3.1/pygraphviz/tests/test_attribute_defaults.py0000644000175000017500000000555712573042175024467 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals from nose.tools import * import pygraphviz as pgv from os import linesep def test_default_attributes(): A = pgv.AGraph() A.graph_attr['label'] = 'test' A.graph_attr['spam'] = 'eggs' assert_true('label' in A.graph_attr) assert_equal(A.graph_attr['label'], 'test') assert_equal(A.graph_attr.keys(), ['label', 'spam']) assert_equal(sorted(list(A.graph_attr.iteritems())), [('label', 'test'), ('spam', 'eggs')]) assert_equal(A.string().expandtabs(2), """strict graph { graph [label=test, spam=eggs ]; } """.replace('\n', linesep)) A.graph_attr['label'] = '' A.graph_attr['spam'] = '' assert_equal(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep)) A.graph_attr['label'] = 'test' del A.graph_attr['label'] assert_equal(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep) ) def test_graph_defaults(): A = pgv. AGraph(rankdir='LR',pack='true') assert_equal(A.string().expandtabs(2), """strict graph { graph [pack=true, rankdir=LR ]; } """.replace('\n', linesep)) def test_node_defaults(): A = pgv.AGraph() A.node_attr['label']='test' assert_true('label' in A.node_attr) assert_equal(A.node_attr['label'], 'test') assert_equal(A.node_attr.keys(), ['label']) assert_equal(A.node_attr, {'label': 'test'}) assert_equal(list(A.node_attr.iteritems()), [('label', 'test')]) assert_equal(A.string().expandtabs(2), """strict graph { node [label=test]; } """.replace('\n', linesep) ) A.node_attr['label'] = '' assert_true(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep) ) A.node_attr['label'] = 'test' del A.node_attr['label'] assert_true(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep) ) A.graph_attr['fontname'] = 'graph font' A.node_attr['fontname'] = 'node font' A.edge_attr['fontname'] = 'edge font' assert_equal(A.string().expandtabs(2), """strict graph { graph [fontname="graph font"]; node [fontname="node font"]; edge [fontname="edge font"]; } """.replace('\n', linesep) ) def test_edge_defaults(): A = pgv.AGraph() A.edge_attr['label'] = 'test' assert_true('label' in A.edge_attr) assert_equal(A.edge_attr['label'], 'test') assert_equal(A.edge_attr.keys(), ['label']) assert_equal(A.edge_attr, {'label': 'test'}) assert_equal(list(A.edge_attr.iteritems()), [('label', 'test')]) assert_equal(A.string().expandtabs(2), """strict graph { edge [label=test]; } """.replace('\n', linesep) ) A.edge_attr['label'] = '' assert_equal(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep) ) A.edge_attr['label'] = 'test' del A.edge_attr['label'] assert_true(A.string().expandtabs(2), """strict graph { } """.replace('\n', linesep) ) pygraphviz-1.3.1/pygraphviz/tests/test_attributes.py0000644000175000017500000000011212573042175022741 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv pygraphviz-1.3.1/pygraphviz/tests/test_node_attributes.py0000644000175000017500000000335412573042175023761 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals from nose.tools import * import pygraphviz as pgv from os import linesep def test_node_attribute(): A = pgv.AGraph() A.add_node(1,label='test',spam='eggs') assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1 [label=test, spam=eggs]; } """.replace('\n', linesep)) def test_node_attributes2(): A = pgv.AGraph() A.add_node(1) one = A.get_node(1) one.attr['label'] = 'test' one.attr['spam'] = 'eggs' assert_true('label' in one.attr) assert_equal(one.attr['label'],'test') assert_equal(sorted(one.attr.keys()), ['label', 'spam']) assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1 [label=test, spam=eggs]; } """.replace('\n', linesep) ) one.attr['label'] = '' one.attr['spam'] = '' assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1 [label=""]; } """.replace('\n', linesep)) one.attr['label'] = 'test' del one.attr['label'] assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1 [label=""]; } """.replace('\n', linesep)) def test_node_attribute_update(): A = pgv.AGraph() A.add_node(1,label='test',spam='eggs') A.add_node(1,label='updated') assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1 [label=updated, spam=eggs]; } """.replace('\n', linesep)) def test_node_attribute_remove(): A = pgv.AGraph() A.add_node(1,label='test',spam='eggs') A.add_node(1,label=r'\N',spam='') # use \N to signify null label, otherwise '' assert_equal(A.string().expandtabs(2), """strict graph { node [label="\\N"]; 1; } """.replace('\n', linesep)) pygraphviz-1.3.1/pygraphviz/tests/test_layout.py0000644000175000017500000000037612573042175022104 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv def test_layout(): A = pgv.AGraph(name='test graph') A.add_path([1,2,3,4]) A.layout() assert_equal(['pos' in n.attr for n in A.nodes()], [True, True, True, True]) pygraphviz-1.3.1/pygraphviz/tests/test_graph.py0000644000175000017500000002635312573042175021673 0ustar aricaric00000000000000from __future__ import unicode_literals from nose.tools import * import pygraphviz as pgv from os import linesep class TestGraph: def setUp(self): self.null = pgv.AGraph() self.K1 = pgv.AGraph() self.K1.add_node(1) self.K3 = pgv.AGraph() self.K3.add_edges_from([(1,2),(1,3),(2,3)]) self.K5 = pgv.AGraph() self.K5.add_edges_from([(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)]) self.P3 = pgv.AGraph() self.P3.add_path([1,2,3]) self.P5 = pgv.AGraph() self.P5.add_path([1,2,3,4,5]) def test_strict(self): A =pgv.AGraph() # empty assert_true(A.is_strict()) assert_equal(A.nodes(), []) def test_data(self): d = {'a':'b','b':'c'} A = pgv.AGraph(data=d) # with data assert_equal(sorted(A.nodes()), ['a', 'b', 'c']) assert_equal(sorted(A.edges()), [('a', 'b'), ('b', 'c')]) def test_str(self): A = pgv.AGraph(name="test") assert_equal(A.string(), """strict graph test { } """.replace('\n', linesep) ) A = pgv.AGraph() assert_equal(A.string(), """strict graph { } """.replace('\n', linesep) ) def test_repr(self): A = pgv.AGraph() assert_equal(A.__repr__()[0:7], ' 2; 2 -> 3; } """.replace('\n', linesep) ) assert_equal(A.reverse().string().expandtabs(0), """strict digraph { 2 -> 1; 3 -> 2; } """.replace('\n', linesep) ) def test_name(self): A = pgv.AGraph(name='test') assert_equal(A.name, 'test') B = A.reverse() assert_equal(B.name, 'test') pygraphviz-1.3.1/pygraphviz/tests/test.py0000644000175000017500000000212112573042175020475 0ustar aricaric00000000000000#!/usr/bin/env python import sys from os import path,getcwd def run(verbosity=1,doctest=False,numpy=True): """Run PyGraphviz tests. Parameters ---------- verbosity: integer, optional Level of detail in test reports. Higher numbers provide more detail. doctest: bool, optional True to run doctests in code modules """ try: import nose except ImportError: raise ImportError(\ "The nose package is needed to run the tests.") sys.stderr.write("Running PyGraphiz tests:") nx_install_dir=path.join(path.dirname(__file__), path.pardir) # stop if running from source directory if getcwd() == path.abspath(path.join(nx_install_dir,path.pardir)): raise RuntimeError("Can't run tests from source directory.\n" "Run 'nosetests' from the command line.") argv=[' ','--verbosity=%d'%verbosity, '-w',nx_install_dir, '-exe'] if doctest: argv.extend(['--with-doctest','--doctest-extension=txt']) nose.run(argv=argv) if __name__=="__main__": run() pygraphviz-1.3.1/pygraphviz/tests/__init__.py0000644000175000017500000000000012573042175021247 0ustar aricaric00000000000000pygraphviz-1.3.1/pygraphviz/tests/test_unicode.py0000644000175000017500000000214212573042175022206 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from __future__ import unicode_literals from nose.tools import * import pygraphviz as pgv import sys _PY2 = sys.version_info[0] == 2 _TEXT_TYPE = unicode if _PY2 else str def test_name_unicode(): A = pgv.AGraph(name='unicode') assert_equal(A.name,'unicode') def test_node_encoding(): A = pgv.AGraph(encoding='UTF-8') hello='Здравствуйте!' A.add_node(hello) n=A.get_node(hello) assert_equal(n.name, hello) n.attr['goodbye']="До свидания" assert_equal(n.attr['goodbye'],"До свидания") def test_edge_encoding(): A = pgv.AGraph(encoding='UTF-8') hello="שלום" A.add_edge(hello,hello,key=1) # self loop e=A.get_edge(hello,hello) assert_equal(e.name,'1') assert_equal(e,(hello,hello)) e.attr['hello']=hello assert_equal(e.attr['hello'], hello) def test_from_string(): # test unicode in from_string() t = '测试' G =pgv.AGraph() G.add_node(t) ug = _TEXT_TYPE(G) sg = str(G) G1 = pgv.AGraph(ug) G2 = pgv.AGraph(sg) assert_equal(_TEXT_TYPE(G1),_TEXT_TYPE(G2)) pygraphviz-1.3.1/pygraphviz/tests/test_html.py0000644000175000017500000000125512573042175021530 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv from os import linesep def test_html(): G = pgv.AGraph(label='Graph>') G.add_node('a', label='Node>') s = G.add_subgraph('b', label='Subgraph>') s.add_node('sa', label='Subgraph Node b>') G.add_edge('a','b', label='Edge>') assert_equal(G.string().expandtabs(2), """strict graph { graph [label=Graph>]; node [label="\\N"]; { graph [label=Subgraph>]; sa [label=Subgraph Node b>]; } a [label=Node>]; a -- b [label=Edge>]; } """.replace('\n', linesep)) pygraphviz-1.3.1/pygraphviz/tests/test_drawing.py0000644000175000017500000000121512573042175022213 0ustar aricaric00000000000000# -*- coding: utf-8 -*- from nose.tools import * import pygraphviz as pgv @raises(AttributeError) def test_drawing_error(): A = pgv.AGraph(name='test graph') A.add_path([1,2,3,4]) d = A.draw() # this is not a very good way to test... #def test_drawing(): # A = pgv.AGraph(name='test graph') # A.add_path([1,2,3,4]) # d = A.draw(prog='neato') # assert_equal(len(d.splitlines()),19) # FIXME # smoke test # >>> (fd,fname)=tempfile.mkstemp() # >>> A.draw(fname,format='ps',prog='neato') # >>> A.draw(fname,prog='neato') @raises(ValueError) def test_name_error(): A = pgv.AGraph(name='test graph') A.draw('foo',prog='foo') pygraphviz-1.3.1/pygraphviz/graphviz_wrap.c0000644000175000017500000055653012573042175021053 0ustar aricaric00000000000000/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #define SWIG_PYTHON_DIRECTOR_NO_VTABLE /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include # define _DEBUG #else # include #endif /* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic C API SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } which is the same really, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as int SWIG_ConvertPtr(obj, ptr,...) { if () { if () { *ptr = ; return SWIG_NEWOBJ; } else { *ptr = ; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the SWIG errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like ||... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCmp(const char *nb, const char *tb) { int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like ||... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (strcmp(iter->type->name, c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { if (iter->type == from) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ iter->prev->next = iter->next; if (iter->next) iter->next->prev = iter->prev; iter->next = ty->cast; iter->prev = 0; if (ty->cast) ty->cast->prev = iter; ty->cast = iter; return iter; } iter = iter->next; } } return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { size_t l = 0; size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; const unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif /* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 /* Compatibility macros for Python 3 */ #if PY_VERSION_HEX >= 0x03000000 #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyInt_FromSize_t(x) PyLong_FromSize_t(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) #define PyString_AsString(str) PyBytes_AsString(str) #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE #define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif #ifndef Py_TYPE # define Py_TYPE(op) ((op)->ob_type) #endif /* SWIG APIs for compatibility of both Python 2 & 3 */ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_FromFormat PyUnicode_FromFormat #else # define SWIG_Python_str_FromFormat PyString_FromFormat #endif /* Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 char *cstr; char *newstr; Py_ssize_t len; str = PyUnicode_AsUTF8String(str); PyBytes_AsStringAndSize(str, &cstr, &len); newstr = (char *) malloc(len+1); memcpy(newstr, cstr, len+1); Py_XDECREF(str); return newstr; #else return PyString_AsString(str); #endif } #if PY_VERSION_HEX >= 0x03000000 # define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #else # define SWIG_Python_str_DelForPy3(x) #endif SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN typedef inquiry lenfunc; typedef intargfunc ssizeargfunc; typedef intintargfunc ssizessizeargfunc; typedef intobjargproc ssizeobjargproc; typedef intintobjargproc ssizessizeobjargproc; typedef getreadbufferproc readbufferproc; typedef getwritebufferproc writebufferproc; typedef getsegcountproc segcountproc; typedef getcharbufferproc charbufferproc; static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) { long result = 0; PyObject *i = PyNumber_Int(x); if (i) { result = PyInt_AsLong(i); Py_DECREF(i); } return result; } #endif #if PY_VERSION_HEX < 0x02050000 #define PyInt_FromSize_t(x) PyInt_FromLong((long)x) #endif #if PY_VERSION_HEX < 0x02040000 #define Py_VISIT(op) \ do { \ if (op) { \ int vret = visit((op), arg); \ if (vret) \ return vret; \ } \ } while (0) #endif #if PY_VERSION_HEX < 0x02030000 typedef struct { PyTypeObject type; PyNumberMethods as_number; PyMappingMethods as_mapping; PySequenceMethods as_sequence; PyBufferProcs as_buffer; PyObject *name, *slots; } PyHeapTypeObject; #endif #if PY_VERSION_HEX < 0x02030000 typedef destructor freefunc; #endif #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE # define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #endif /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif /* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ #if PY_VERSION_HEX >= 0x03000000 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { return PyInstanceMethod_New(func); } #else SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) { return NULL; } #endif #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #ifdef SWIGPYTHON_BUILTIN #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) #else #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #endif #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ #if defined(SWIGPYTHON_BUILTIN) SWIGINTERN void SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { PyObject *s = PyString_InternFromString(key); PyList_Append(seq, s); Py_DECREF(s); } SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { #if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); #else PyDict_SetItemString(d, name, obj); #endif Py_DECREF(obj); } #endif /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN int SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { int i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; } return 2; } PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) #ifdef __cplusplus extern "C" { #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* SwigPyClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; PyTypeObject *pytype; } SwigPyClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME SwigPyClientData * SwigPyClientData_New(PyObject* obj) { if (!obj) { return 0; } else { SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; data->pytype = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData *data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; #ifdef SWIGPYTHON_BUILTIN PyObject *dict; #endif } SwigPyObject; SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * SwigPyObject_format(const char* fmt, SwigPyObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 res = PyUnicode_Format(ofmt,args); #else res = PyString_Format(ofmt,args); #endif Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * SwigPyObject_oct(SwigPyObject *v) { return SwigPyObject_format("%o",v); } SWIGRUNTIME PyObject * SwigPyObject_hex(SwigPyObject *v) { return SwigPyObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) #else SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { # ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); # else PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); # endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); Py_DecRef(nrep); repr = joined; # else PyString_ConcatAndDel(&repr,nrep); # endif } return repr; } SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } /* Added for Python 3.x, would it also be useful for Python 2.x? */ SWIGRUNTIME PyObject* SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) { PyObject* res; if( op != Py_EQ && op != Py_NE ) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); return res; } SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; assert(cd); assert(cd->pytype); return cd->pytype; } #else SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); return type; } #endif SWIGRUNTIMEINLINE int SwigPyObject_Check(PyObject *op) { #ifdef SWIGPYTHON_BUILTIN PyTypeObject *target_tp = SwigPyObject_type(); if (PyType_IsSubtype(op->ob_type, target_tp)) return 1; return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); #else return (Py_TYPE(op) == SwigPyObject_type()) || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); #endif } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void SwigPyObject_dealloc(PyObject *v) { SwigPyObject *sobj = (SwigPyObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!SwigPyObject_Check(next)) { return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS SwigPyObject_next(PyObject* v) #else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_disown(PyObject *v) #else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS SwigPyObject_acquire(PyObject *v) #else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #elif (PY_VERSION_HEX < 0x02050000) if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #else if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) #endif { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v); } else { SwigPyObject_disown(v); } #else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * SwigPyObject_getattr(SwigPyObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods SwigPyObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ /* nb_divide removed in Python 3 */ #if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ #endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif (unaryfunc)SwigPyObject_long, /*nb_int*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_long, /*nb_long*/ #else 0, /*nb_reserved*/ #endif (unaryfunc)0, /*nb_float*/ #if PY_VERSION_HEX < 0x03000000 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif #if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ #else (cmpfunc)SwigPyObject_compare, /* tp_compare */ #endif (reprfunc)SwigPyObject_repr, /* tp_repr */ &SwigPyObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpyobject_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; #endif } return &swigpyobject_type; } SWIGRUNTIME PyObject * SwigPyObject_New(void *ptr, swig_type_info *ty, int own) { SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } SwigPyPacked; SWIGRUNTIME int SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { return SWIG_Python_str_FromFormat("", v->ty->name); } } SWIGRUNTIME PyObject * SwigPyPacked_str(SwigPyPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { return SWIG_Python_str_FromChar(v->ty->name); } } SWIGRUNTIME int SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); return type; } SWIGRUNTIMEINLINE int SwigPyPacked_Check(PyObject *op) { return ((op)->ob_type == SwigPyPacked_TypeOnce()) || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); } SWIGRUNTIME void SwigPyPacked_dealloc(PyObject *v) { if (SwigPyPacked_Check(v)) { SwigPyPacked *sobj = (SwigPyPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject swigpypacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ (printfunc)SwigPyPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 0, /* tp_reserved in 3.0.1 */ #else (cmpfunc)SwigPyPacked_compare, /* tp_compare */ #endif (reprfunc)SwigPyPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)SwigPyPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 swigpypacked_type.ob_type = &PyType_Type; #else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; #endif } return &swigpypacked_type; } SWIGRUNTIME PyObject * SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) { SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (SwigPyPacked_Check(obj)) { SwigPyPacked *sobj = (SwigPyPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return SWIG_Python_str_FromChar("this"); } static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { if (swig_this == NULL) swig_this = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ /* TODO: I don't know how to implement the fast getset in Python 3 right now */ #if PY_VERSION_HEX>=0x03000000 #define SWIG_PYTHON_SLOW_GETSET_THIS #endif SWIGRUNTIME SwigPyObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { PyObject *obj; if (SwigPyObject_Check(pyobj)) return (SwigPyObject *) pyobj; #ifdef SWIGPYTHON_BUILTIN (void)obj; # ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { pyobj = PyWeakref_GET_OBJECT(pyobj); if (pyobj && SwigPyObject_Check(pyobj)) return (SwigPyObject*) pyobj; } # endif return NULL; #else obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !SwigPyObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' SwigPyObject from it */ return SWIG_Python_GetSwigThis(obj); } return (SwigPyObject *)obj; #endif } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; } res = SWIG_ERROR; sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (SwigPyObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } res = SWIG_OK; } else { if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } if (!SWIG_IsOK(res) && obj == Py_None) { if (ptr) *ptr = 0; if (PyErr_Occurred()) PyErr_Clear(); res = SWIG_OK; } } return res; } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, without calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { #if PY_VERSION_HEX >= 0x03000000 inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); if (inst) { PyObject_SetAttr(inst, SWIG_This(), swig_this); Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; } #else PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst = 0; PyObject *dict = PyDict_New(); if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { SwigPyClientData *clientdata; PyObject * robj; int own; if (!ptr) return SWIG_Py_Void(); clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; if (clientdata && clientdata->pytype) { SwigPyObject *newobj; if (flags & SWIG_BUILTIN_TP_INIT) { newobj = (SwigPyObject*) self; if (newobj->ptr) { PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); while (newobj->next) newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif return (PyObject*) newobj; } return SWIG_Py_Void(); } assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); Py_DECREF(robj); robj = inst; } return robj; } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void #ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) #else SWIG_Python_DestroyModule(void *vptr) #endif { #ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); #else swig_module_info *swig_module = (swig_module_info *) vptr; #endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); swig_this = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif #ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #else PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #endif } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { #ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); #else descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); #endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { #ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); #else obj = PyCObject_FromVoidPtr(descriptor, NULL); #endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : ""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); #if SWIG_POINTER_EXCEPTION if (flags) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } #endif } return result; } #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; int res = -1; # ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) # else if (!PyString_Check(name)) # endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; } else { Py_INCREF(name); } if (!tp->tp_dict) { if (PyType_Ready(tp) < 0) goto done; } descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) f = descr->ob_type->tp_descr_set; if (!f) { if (PyString_Check(name)) { encoded_name = name; Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); } else { res = f(descr, obj, value); } done: Py_DECREF(name); return res; } #endif #ifdef __cplusplus } #endif #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_Agdesc_t swig_types[0] #define SWIGTYPE_p_Agdisc_t swig_types[1] #define SWIGTYPE_p_Agedge_t swig_types[2] #define SWIGTYPE_p_Agnode_t swig_types[3] #define SWIGTYPE_p_Agraph_t swig_types[4] #define SWIGTYPE_p_Agsym_t swig_types[5] #define SWIGTYPE_p_FILE swig_types[6] #define SWIGTYPE_p_char swig_types[7] static swig_type_info *swig_types[9]; static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) /* -------- TYPES TABLE (END) -------- */ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) # error "This python version requires swig to be run with the '-classic' option" # endif #endif /*----------------------------------------------- @(target):= _graphviz.so ------------------------------------------------*/ #if PY_VERSION_HEX >= 0x03000000 # define SWIG_init PyInit__graphviz #else # define SWIG_init init_graphviz #endif #define SWIG_name "_graphviz" #define SWIGVERSION 0x030002 #define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) (void *)((const void *)(a)) #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "graphviz/cgraph.h" #if PY_VERSION_HEX >= 0x03000000 extern PyTypeObject PyIOBase_Type; #endif SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { #if PY_VERSION_HEX>=0x03000000 if (PyBytes_Check(obj)) #else if (PyString_Check(obj)) #endif { char *cstr; Py_ssize_t len; #if PY_VERSION_HEX>=0x03000000 PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; #else PyString_AsStringAndSize(obj, &cstr, &len); #endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ #if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) #else if (*alloc == SWIG_NEWOBJ) #endif { *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } SWIGINTERNINLINE PyObject* SWIG_From_int (int value) { return PyInt_FromLong((long) value); } #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif SWIGINTERN int SWIG_AsVal_double (PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } #endif return res; } #include #include SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERN int SWIG_AsVal_int (PyObject * obj, int *val) { long v; int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = (int)(v); } } return res; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { #if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else #endif if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); #if PY_VERSION_HEX >= 0x03000000 { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (v < 0) { return SWIG_OverflowError; } } else { PyErr_Clear(); } } #endif } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 return PyBytes_FromStringAndSize(carray, (int)(size)); #else return PyString_FromStringAndSize(carray, (int)(size)); #endif } } else { return SWIG_Py_Void(); } } SWIGINTERNINLINE PyObject * SWIG_FromCharPtr(const char *cptr) { return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); } char *agattrname(Agsym_t *atsym) { return atsym->name; } char *agattrdefval(Agsym_t *atsym) { return atsym->defval; } int agsafeset_label(Agraph_t *g, void *obj, char *name, char *val, char *def) { int len; char *hs; if (val[0] == '<' && (strcmp(name, "label") == 0 || strcmp(name, "xlabel") == 0)) { len = strlen(val); if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; val = agstrdup_html(g,hs); free(hs); } } return agsafeset(obj, name, val,def); } int agattr_label(Agraph_t *g, int kind, char *name, char *val) { int len; char *hs; if (val[0] == '<' && (strcmp(name, "label") == 0 || strcmp(name, "xlabel") == 0)) { len = strlen(val); if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; val = agstrdup_html(g,hs); free(hs); } } return agattr(g, kind, name, val); } #define SWIG_From_long PyLong_FromLong #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_agopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; Agdesc_t arg2 ; Agdisc_t *arg3 = (Agdisc_t *) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; void *argp2 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agopen",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agopen" "', argument " "1"" of type '" "char *""'"); } arg1 = (char *)(buf1); { res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Agdesc_t, 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agopen" "', argument " "2"" of type '" "Agdesc_t""'"); } if (!argp2) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "agopen" "', argument " "2"" of type '" "Agdesc_t""'"); } else { arg2 = *((Agdesc_t *)(argp2)); } } res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_Agdisc_t, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agopen" "', argument " "3"" of type '" "Agdisc_t *""'"); } arg3 = (Agdisc_t *)(argp3); result = (Agraph_t *)agopen(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return NULL; } SWIGINTERN PyObject *_wrap_agclose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agclose",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agclose" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agclose(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agread(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; FILE *arg1 = (FILE *) 0 ; Agdisc_t *arg2 = (Agdisc_t *) 0 ; int fd1 ; PyObject *mode_obj1 ; PyObject *mode_byte_obj1 ; char *mode1 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agread",&obj0,&obj1)) SWIG_fail; { #if PY_VERSION_HEX >= 0x03000000 if (!PyObject_IsInstance(obj0, (PyObject *)&PyIOBase_Type)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } // work around to get hold of FILE* fd1 = PyObject_AsFileDescriptor(obj0); mode_obj1 = PyObject_GetAttrString(obj0, "mode"); mode_byte_obj1 = PyUnicode_AsUTF8String(mode_obj1); mode1 = PyBytes_AsString(mode_byte_obj1); arg1 = fdopen(fd1, mode1); Py_XDECREF(mode_obj1); Py_XDECREF(mode_byte_obj1); #else if (!PyFile_Check(obj0)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } arg1 = PyFile_AsFile(obj0); #endif } res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agdisc_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agread" "', argument " "2"" of type '" "Agdisc_t *""'"); } arg2 = (Agdisc_t *)(argp2); { result = (Agraph_t *)agread(arg1,arg2); if (!result) { PyErr_SetString(PyExc_ValueError,"agread: bad input data"); return NULL; } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agwrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; FILE *arg2 = (FILE *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int fd2 ; PyObject *mode_obj2 ; PyObject *mode_byte_obj2 ; char *mode2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OO:agwrite",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agwrite" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); { #if PY_VERSION_HEX >= 0x03000000 if (!PyObject_IsInstance(obj1, (PyObject *)&PyIOBase_Type)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } // work around to get hold of FILE* fd2 = PyObject_AsFileDescriptor(obj1); mode_obj2 = PyObject_GetAttrString(obj1, "mode"); mode_byte_obj2 = PyUnicode_AsUTF8String(mode_obj2); mode2 = PyBytes_AsString(mode_byte_obj2); arg2 = fdopen(fd2, mode2); Py_XDECREF(mode_obj2); Py_XDECREF(mode_byte_obj2); #else if (!PyFile_Check(obj1)) { PyErr_SetString(PyExc_TypeError, "not a file handle"); return NULL; } arg2 = PyFile_AsFile(obj1); #endif } result = (int)agwrite(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agisundirected(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agisundirected",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agisundirected" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agisundirected(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agisdirected(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agisdirected",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agisdirected" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agisdirected(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agisstrict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agisstrict",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agisstrict" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agisstrict(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; char *arg2 = (char *) 0 ; int arg3 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agnode",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agnode" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agnode" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); { result = (Agnode_t *)agnode(arg1,arg2,arg3); if (!result) { PyErr_SetString(PyExc_KeyError,"agnode: no key"); return NULL; } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } SWIGINTERN PyObject *_wrap_agidnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; unsigned long arg2 ; int arg3 ; void *argp1 = 0 ; int res1 = 0 ; unsigned long val2 ; int ecode2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agidnode",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agidnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "agidnode" "', argument " "2"" of type '" "unsigned long""'"); } arg2 = (unsigned long)(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agidnode" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); result = (Agnode_t *)agidnode(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agsubnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; int arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agsubnode",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agsubnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agsubnode" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agsubnode" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); result = (Agnode_t *)agsubnode(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agfstnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agfstnode",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agfstnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agnode_t *)agfstnode(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnxtnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agnxtnode",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agnxtnode" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); result = (Agnode_t *)agnxtnode(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_aglstnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:aglstnode",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "aglstnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agnode_t *)aglstnode(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agprvnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agprvnode",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agprvnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agprvnode" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); result = (Agnode_t *)agprvnode(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agedge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; Agnode_t *arg3 = (Agnode_t *) 0 ; char *arg4 = (char *) 0 ; int arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOOOO:agedge",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agedge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agedge" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agedge" "', argument " "3"" of type '" "Agnode_t *""'"); } arg3 = (Agnode_t *)(argp3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "agedge" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "agedge" "', argument " "5"" of type '" "int""'"); } arg5 = (int)(val5); { result = (Agedge_t *)agedge(arg1,arg2,arg3,arg4,arg5); if (!result) { PyErr_SetString(PyExc_KeyError,"agedge: no key"); return NULL; } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } SWIGINTERN PyObject *_wrap_agidedge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; Agnode_t *arg3 = (Agnode_t *) 0 ; unsigned long arg4 ; int arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; unsigned long val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOOOO:agidedge",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agidedge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agidedge" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agidedge" "', argument " "3"" of type '" "Agnode_t *""'"); } arg3 = (Agnode_t *)(argp3); ecode4 = SWIG_AsVal_unsigned_SS_long(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "agidedge" "', argument " "4"" of type '" "unsigned long""'"); } arg4 = (unsigned long)(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "agidedge" "', argument " "5"" of type '" "int""'"); } arg5 = (int)(val5); result = (Agedge_t *)agidedge(arg1,arg2,arg3,arg4,arg5); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agsubedge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agedge_t *arg2 = (Agedge_t *) 0 ; int arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agsubedge",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agsubedge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agsubedge" "', argument " "2"" of type '" "Agedge_t *""'"); } arg2 = (Agedge_t *)(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agsubedge" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); result = (Agedge_t *)agsubedge(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agfstin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agfstin",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agfstin" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agfstin" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); result = (Agedge_t *)agfstin(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnxtin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agedge_t *arg2 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agnxtin",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtin" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agnxtin" "', argument " "2"" of type '" "Agedge_t *""'"); } arg2 = (Agedge_t *)(argp2); result = (Agedge_t *)agnxtin(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agfstout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agfstout",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agfstout" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agfstout" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); result = (Agedge_t *)agfstout(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnxtout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agedge_t *arg2 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agnxtout",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtout" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agnxtout" "', argument " "2"" of type '" "Agedge_t *""'"); } arg2 = (Agedge_t *)(argp2); result = (Agedge_t *)agnxtout(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agfstedge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agfstedge",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agfstedge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agfstedge" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); result = (Agedge_t *)agfstedge(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnxtedge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agedge_t *arg2 = (Agedge_t *) 0 ; Agnode_t *arg3 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agedge_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agnxtedge",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtedge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agnxtedge" "', argument " "2"" of type '" "Agedge_t *""'"); } arg2 = (Agedge_t *)(argp2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agnxtedge" "', argument " "3"" of type '" "Agnode_t *""'"); } arg3 = (Agnode_t *)(argp3); result = (Agedge_t *)agnxtedge(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agedge_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_aghead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agedge_t *arg1 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:aghead",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "aghead" "', argument " "1"" of type '" "Agedge_t *""'"); } arg1 = (Agedge_t *)(argp1); result = (Agnode_t *)aghead(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agtail(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agedge_t *arg1 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agnode_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agtail",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agtail" "', argument " "1"" of type '" "Agedge_t *""'"); } arg1 = (Agedge_t *)(argp1); result = (Agnode_t *)agtail(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agnode_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agattr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; Agsym_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOOO:agattr",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agattr" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "agattr" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agattr" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "agattr" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); { result = (Agsym_t *)agattr(arg1,arg2,arg3,arg4); if (!result) { PyErr_SetString(PyExc_KeyError,"agattr: no key"); return NULL; } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agsym_t, 0 | 0 ); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } SWIGINTERN PyObject *_wrap_agattrsym(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int res1 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; Agsym_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agattrsym",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agattrsym" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agattrsym" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); result = (Agsym_t *)agattrsym(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agsym_t, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } SWIGINTERN PyObject *_wrap_agnxtattr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; int arg2 ; Agsym_t *arg3 = (Agsym_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; void *argp3 = 0 ; int res3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agsym_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agnxtattr",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtattr" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "agnxtattr" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_Agsym_t, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agnxtattr" "', argument " "3"" of type '" "Agsym_t *""'"); } arg3 = (Agsym_t *)(argp3); { result = (Agsym_t *)agnxtattr(arg1,arg2,arg3); if (!result) { PyErr_SetString(PyExc_StopIteration,"agnxtattr"); return NULL; } } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agsym_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agget(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; int res1 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agget",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agget" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agget" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); result = (char *)agget(arg1,arg2); resultobj = SWIG_FromCharPtr((const char *)result); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } SWIGINTERN PyObject *_wrap_agxget(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; Agsym_t *arg2 = (Agsym_t *) 0 ; int res1 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:agxget",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agxget" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agsym_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agxget" "', argument " "2"" of type '" "Agsym_t *""'"); } arg2 = (Agsym_t *)(argp2); result = (char *)agxget(arg1,arg2); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; int res1 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOO:agset",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agset" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agset" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agset" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); { result = (int)agset(arg1,arg2,arg3); if (result==-1) { PyErr_SetString(PyExc_KeyError,"agset: no key"); return NULL; } } resultobj = SWIG_From_int((int)(result)); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return NULL; } SWIGINTERN PyObject *_wrap_agxset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; Agsym_t *arg2 = (Agsym_t *) 0 ; char *arg3 = (char *) 0 ; int res1 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOO:agxset",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agxset" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agsym_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agxset" "', argument " "2"" of type '" "Agsym_t *""'"); } arg2 = (Agsym_t *)(argp2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agxset" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); result = (int)agxset(arg1,arg2,arg3); resultobj = SWIG_From_int((int)(result)); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return NULL; } SWIGINTERN PyObject *_wrap_agsafeset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; int res1 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOOO:agsafeset",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agsafeset" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agsafeset" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agsafeset" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "agsafeset" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); result = (int)agsafeset(arg1,arg2,arg3,arg4); resultobj = SWIG_From_int((int)(result)); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } SWIGINTERN PyObject *_wrap_agattrname(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agsym_t *arg1 = (Agsym_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agattrname",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agsym_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agattrname" "', argument " "1"" of type '" "Agsym_t *""'"); } arg1 = (Agsym_t *)(argp1); result = (char *)agattrname(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agattrdefval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agsym_t *arg1 = (Agsym_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agattrdefval",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agsym_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agattrdefval" "', argument " "1"" of type '" "Agsym_t *""'"); } arg1 = (Agsym_t *)(argp1); result = (char *)agattrdefval(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agsafeset_label(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *arg2 = (void *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; char *arg5 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; int res5 ; char *buf5 = 0 ; int alloc5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOOOO:agsafeset_label",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agsafeset_label" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agsafeset_label" "', argument " "2"" of type '" "void *""'"); } res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agsafeset_label" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "agsafeset_label" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "agsafeset_label" "', argument " "5"" of type '" "char *""'"); } arg5 = (char *)(buf5); { result = (int)agsafeset_label(arg1,arg2,arg3,arg4,arg5); if (result==-1) { PyErr_SetString(PyExc_KeyError,"agsafeset_label: Error"); return NULL; } } resultobj = SWIG_From_int((int)(result)); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); return NULL; } SWIGINTERN PyObject *_wrap_agattr_label(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOOO:agattr_label",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agattr_label" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "agattr_label" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "agattr_label" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "agattr_label" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); { result = (int)agattr_label(arg1,arg2,arg3,arg4); if (!result) { PyErr_SetString(PyExc_KeyError,"agattr_label: no key"); return NULL; } } resultobj = SWIG_From_int((int)(result)); if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } SWIGINTERN PyObject *_wrap_agsubg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; char *arg2 = (char *) 0 ; int arg3 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"OOO:agsubg",&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agsubg" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agsubg" "', argument " "2"" of type '" "char *""'"); } arg2 = (char *)(buf2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agsubg" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); result = (Agraph_t *)agsubg(arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return NULL; } SWIGINTERN PyObject *_wrap_agfstsubg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agfstsubg",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agfstsubg" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agraph_t *)agfstsubg(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnxtsubg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agnxtsubg",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnxtsubg" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agraph_t *)agnxtsubg(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agparent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agparent",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agparent" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agraph_t *)agparent(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agroot(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agroot",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agroot" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (Agraph_t *)agroot(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agdelsubg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; long result; if (!PyArg_ParseTuple(args,(char *)"OO:agdelsubg",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agdelsubg" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agdelsubg" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); result = (long)agdelsubg(arg1,arg2); resultobj = SWIG_From_long((long)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnnodes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agnnodes",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnnodes" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agnnodes(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnedges(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"O:agnedges",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnedges" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); result = (int)agnedges(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agdegree(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; int arg3 ; int arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OOOO:agdegree",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agdegree" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agdegree" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "agdegree" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "agdegree" "', argument " "4"" of type '" "int""'"); } arg4 = (int)(val4); result = (int)agdegree(arg1,arg2,arg3,arg4); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agraphof(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject * obj0 = 0 ; Agraph_t *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agraphof",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agraphof" "', argument " "1"" of type '" "void *""'"); } result = (Agraph_t *)agraphof(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Agraph_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agnameof(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject * obj0 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:agnameof",&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agnameof" "', argument " "1"" of type '" "void *""'"); } result = (char *)agnameof(arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agdelnode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agnode_t *arg2 = (Agnode_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OO:agdelnode",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agdelnode" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agnode_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agdelnode" "', argument " "2"" of type '" "Agnode_t *""'"); } arg2 = (Agnode_t *)(argp2); { result = (int)agdelnode(arg1,arg2); if (result==-1) { PyErr_SetString(PyExc_KeyError,"agdelnode: no key"); return NULL; } } resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agdeledge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; Agedge_t *arg2 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; int result; if (!PyArg_ParseTuple(args,(char *)"OO:agdeledge",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "agdeledge" "', argument " "1"" of type '" "Agraph_t *""'"); } arg1 = (Agraph_t *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Agedge_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "agdeledge" "', argument " "2"" of type '" "Agedge_t *""'"); } arg2 = (Agedge_t *)(argp2); result = (int)agdeledge(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN int Swig_var_Agdirected_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable Agdirected is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_Agdirected_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&Agdirected), SWIGTYPE_p_Agdesc_t, 0 ); return pyobj; } SWIGINTERN int Swig_var_Agstrictdirected_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable Agstrictdirected is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_Agstrictdirected_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&Agstrictdirected), SWIGTYPE_p_Agdesc_t, 0 ); return pyobj; } SWIGINTERN int Swig_var_Agundirected_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable Agundirected is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_Agundirected_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&Agundirected), SWIGTYPE_p_Agdesc_t, 0 ); return pyobj; } SWIGINTERN int Swig_var_Agstrictundirected_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable Agstrictundirected is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_Agstrictundirected_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&Agstrictundirected), SWIGTYPE_p_Agdesc_t, 0 ); return pyobj; } static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, { (char *)"agopen", _wrap_agopen, METH_VARARGS, NULL}, { (char *)"agclose", _wrap_agclose, METH_VARARGS, NULL}, { (char *)"agread", _wrap_agread, METH_VARARGS, NULL}, { (char *)"agwrite", _wrap_agwrite, METH_VARARGS, NULL}, { (char *)"agisundirected", _wrap_agisundirected, METH_VARARGS, NULL}, { (char *)"agisdirected", _wrap_agisdirected, METH_VARARGS, NULL}, { (char *)"agisstrict", _wrap_agisstrict, METH_VARARGS, NULL}, { (char *)"agnode", _wrap_agnode, METH_VARARGS, NULL}, { (char *)"agidnode", _wrap_agidnode, METH_VARARGS, NULL}, { (char *)"agsubnode", _wrap_agsubnode, METH_VARARGS, NULL}, { (char *)"agfstnode", _wrap_agfstnode, METH_VARARGS, NULL}, { (char *)"agnxtnode", _wrap_agnxtnode, METH_VARARGS, NULL}, { (char *)"aglstnode", _wrap_aglstnode, METH_VARARGS, NULL}, { (char *)"agprvnode", _wrap_agprvnode, METH_VARARGS, NULL}, { (char *)"agedge", _wrap_agedge, METH_VARARGS, NULL}, { (char *)"agidedge", _wrap_agidedge, METH_VARARGS, NULL}, { (char *)"agsubedge", _wrap_agsubedge, METH_VARARGS, NULL}, { (char *)"agfstin", _wrap_agfstin, METH_VARARGS, NULL}, { (char *)"agnxtin", _wrap_agnxtin, METH_VARARGS, NULL}, { (char *)"agfstout", _wrap_agfstout, METH_VARARGS, NULL}, { (char *)"agnxtout", _wrap_agnxtout, METH_VARARGS, NULL}, { (char *)"agfstedge", _wrap_agfstedge, METH_VARARGS, NULL}, { (char *)"agnxtedge", _wrap_agnxtedge, METH_VARARGS, NULL}, { (char *)"aghead", _wrap_aghead, METH_VARARGS, NULL}, { (char *)"agtail", _wrap_agtail, METH_VARARGS, NULL}, { (char *)"agattr", _wrap_agattr, METH_VARARGS, NULL}, { (char *)"agattrsym", _wrap_agattrsym, METH_VARARGS, NULL}, { (char *)"agnxtattr", _wrap_agnxtattr, METH_VARARGS, NULL}, { (char *)"agget", _wrap_agget, METH_VARARGS, NULL}, { (char *)"agxget", _wrap_agxget, METH_VARARGS, NULL}, { (char *)"agset", _wrap_agset, METH_VARARGS, NULL}, { (char *)"agxset", _wrap_agxset, METH_VARARGS, NULL}, { (char *)"agsafeset", _wrap_agsafeset, METH_VARARGS, NULL}, { (char *)"agattrname", _wrap_agattrname, METH_VARARGS, NULL}, { (char *)"agattrdefval", _wrap_agattrdefval, METH_VARARGS, NULL}, { (char *)"agsafeset_label", _wrap_agsafeset_label, METH_VARARGS, NULL}, { (char *)"agattr_label", _wrap_agattr_label, METH_VARARGS, NULL}, { (char *)"agsubg", _wrap_agsubg, METH_VARARGS, NULL}, { (char *)"agfstsubg", _wrap_agfstsubg, METH_VARARGS, NULL}, { (char *)"agnxtsubg", _wrap_agnxtsubg, METH_VARARGS, NULL}, { (char *)"agparent", _wrap_agparent, METH_VARARGS, NULL}, { (char *)"agroot", _wrap_agroot, METH_VARARGS, NULL}, { (char *)"agdelsubg", _wrap_agdelsubg, METH_VARARGS, NULL}, { (char *)"agnnodes", _wrap_agnnodes, METH_VARARGS, NULL}, { (char *)"agnedges", _wrap_agnedges, METH_VARARGS, NULL}, { (char *)"agdegree", _wrap_agdegree, METH_VARARGS, NULL}, { (char *)"agraphof", _wrap_agraphof, METH_VARARGS, NULL}, { (char *)"agnameof", _wrap_agnameof, METH_VARARGS, NULL}, { (char *)"agdelnode", _wrap_agdelnode, METH_VARARGS, NULL}, { (char *)"agdeledge", _wrap_agdeledge, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_Agdesc_t = {"_p_Agdesc_t", "Agdesc_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Agdisc_t = {"_p_Agdisc_t", "Agdisc_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Agedge_t = {"_p_Agedge_t", "Agedge_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Agnode_t = {"_p_Agnode_t", "Agnode_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Agraph_t = {"_p_Agraph_t", "Agraph_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Agsym_t = {"_p_Agsym_t", "Agsym_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_Agdesc_t, &_swigt__p_Agdisc_t, &_swigt__p_Agedge_t, &_swigt__p_Agnode_t, &_swigt__p_Agraph_t, &_swigt__p_Agsym_t, &_swigt__p_FILE, &_swigt__p_char, }; static swig_cast_info _swigc__p_Agdesc_t[] = { {&_swigt__p_Agdesc_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Agdisc_t[] = { {&_swigt__p_Agdisc_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Agedge_t[] = { {&_swigt__p_Agedge_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Agnode_t[] = { {&_swigt__p_Agnode_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Agraph_t[] = { {&_swigt__p_Agraph_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Agsym_t[] = { {&_swigt__p_Agsym_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_FILE[] = { {&_swigt__p_FILE, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_Agdesc_t, _swigc__p_Agdisc_t, _swigc__p_Agedge_t, _swigc__p_Agnode_t, _swigc__p_Agraph_t, _swigc__p_Agsym_t, _swigc__p_FILE, _swigc__p_char, }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int found, init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ found=0; iter=module_head; do { if (iter==&swig_module) { found=1; break; } iter=iter->next; } while (iter!= module_head); /* if the is found in the list, then all is done and we may leave */ if (found) return; /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString(""); #else return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { #if PY_VERSION_HEX >= 0x03000000 PyObject *str = PyUnicode_InternFromString("("); PyObject *tail; PyObject *joined; swig_globalvar *var; for (var = v->vars; var; var=var->next) { tail = PyUnicode_FromString(var->name); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; if (var->next) { tail = PyUnicode_InternFromString(", "); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; } } tail = PyUnicode_InternFromString(")"); joined = PyUnicode_Concat(str, tail); Py_DecRef(str); Py_DecRef(tail); str = joined; #else PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); #endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { /* PyObject header changed in Python 3 */ #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif (char *)"swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ (printfunc) swig_varlink_print, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc) swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; varlink_type = tmp; type_init = 1; #if PY_VERSION_HEX < 0x02020000 varlink_type.ob_type = &PyType_Type; #else if (PyType_Ready(&varlink_type) < 0) return NULL; #endif } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT #if PY_VERSION_HEX >= 0x03000000 PyObject* #else void #endif SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { # if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, # else { PyObject_HEAD_INIT(NULL) NULL, /* m_init */ 0, /* m_index */ NULL, /* m_copy */ }, # endif (char *) SWIG_name, NULL, -1, SwigMethods, NULL, NULL, NULL, NULL }; #endif #if defined(SWIGPYTHON_BUILTIN) static SwigPyClientData SwigPyObject_clientdata = { 0, 0, 0, 0, 0, 0, 0 }; static PyGetSetDef this_getset_def = { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { (PyCFunction) SwigPyObject_own, (PyCFunction) SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; PyObject *metatype_args; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; int i; (void)builtin_pytype; (void)builtin_base_count; (void)builtin_basetype; (void)tuple; (void)static_getset; /* metatype is used to implement static member variables. */ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); assert(metatype_args); metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); assert(metatype); Py_DECREF(metatype_args); metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; assert(PyType_Ready(metatype) >= 0); #endif /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); (void)md; SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); assert(SwigPyObject_stype); cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; if (!cd) { SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); # if PY_VERSION_HEX >= 0x03000000 return NULL; # else return; # endif } /* All objects have a 'this' attribute */ this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); (void)this_descr; /* All objects have a 'thisown' attribute */ thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); (void)thisown_descr; public_interface = PyList_New(0); public_symbol = 0; (void)public_symbol; PyDict_SetItemString(md, "__all__", public_interface); Py_DECREF(public_interface); for (i = 0; SwigMethods[i].ml_name != NULL; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); #endif SWIG_InstallConstants(d,swig_const_table); PyDict_SetItemString(md,(char*)"cvar", SWIG_globals()); SWIG_addvarlink(SWIG_globals(),(char*)"Agdirected",Swig_var_Agdirected_get, Swig_var_Agdirected_set); SWIG_addvarlink(SWIG_globals(),(char*)"Agstrictdirected",Swig_var_Agstrictdirected_get, Swig_var_Agstrictdirected_set); SWIG_addvarlink(SWIG_globals(),(char*)"Agundirected",Swig_var_Agundirected_get, Swig_var_Agundirected_set); SWIG_addvarlink(SWIG_globals(),(char*)"Agstrictundirected",Swig_var_Agstrictundirected_get, Swig_var_Agstrictundirected_set); SWIG_Python_SetConstant(d, "AGRAPH",SWIG_From_int((int)(0))); SWIG_Python_SetConstant(d, "AGNODE",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "AGOUTEDGE",SWIG_From_int((int)(2))); SWIG_Python_SetConstant(d, "AGINEDGE",SWIG_From_int((int)(3))); SWIG_Python_SetConstant(d, "AGEDGE",SWIG_From_int((int)(2))); #if PY_VERSION_HEX >= 0x03000000 return m; #else return; #endif } pygraphviz-1.3.1/pygraphviz/agraph.py0000644000175000017500000016264312573042175017636 0ustar aricaric00000000000000# -*- coding: utf-8 -*- """ A Python interface to Graphviz. """ # Copyright (C) 2006-2011 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import print_function import re import shlex import subprocess import sys import threading import warnings try: from UserDict import DictMixin except ImportError: # Python 3 from collections import MutableMapping as DictMixin from . import graphviz as gv _DEFAULT_ENCODING = 'UTF-8' _PY2 = sys.version_info[0] == 2 _TEXT_TYPE = unicode if _PY2 else str _STRING_TYPES = (basestring,) if _PY2 else (str,) def is_string_like(obj): return isinstance(obj, _STRING_TYPES) class PipeReader(threading.Thread): """Read and write pipes using threads. """ def __init__(self, result, pipe): threading.Thread.__init__(self) self.result = result self.pipe = pipe def run(self): try: while True: chunk = self.pipe.read() if not chunk: break self.result.append(chunk) finally: self.pipe.close() class _Action(object): find, create = 0, 1 class DotError(ValueError): """Dot data parsing error""" class AGraph(object): """Class for Graphviz agraph type. Example use >>> from pygraphviz import * >>> G=AGraph() >>> G=AGraph(directed=True) >>> G=AGraph("file.dot") # doctest: +SKIP Graphviz graph keyword parameters are processed so you may add them like >>> G=AGraph(landscape='true',ranksep='0.1') or alternatively >>> G=AGraph() >>> G.graph_attr.update(landscape='true',ranksep='0.1') and >>> G.node_attr.update(color='red') >>> G.edge_attr.update(len='2.0',color='blue') See http://www.graphviz.org/doc/info/attrs.html for a list of attributes. Keyword parameters: thing is a generic input type (filename, string, handle to pointer, dictionary of dictionaries). An attempt is made to automaticaly detect the type so you may write for example: >>> d={'1': {'2': None}, '2': {'1': None, '3': None}, '3': {'2': None}} >>> A=AGraph(d) >>> s=A.to_string() >>> B=AGraph(s) >>> h=B.handle >>> C=AGraph(h) Parameters:: name: Name for the graph strict: True|False (True for simple graphs) directed: True|False data: Dictionary of dictionaries or dictionary of lists representing nodes or edges to load into initial graph string: String containing a dot format graph handle: Swig pointer to an agraph_t data structure """ def __init__(self, thing=None, filename=None, data=None, string=None, handle=None, name='', strict=True, directed=False, **attr): self.handle = None # assign first in case the __init__ bombs # initialization can take no arguments (gives empty graph) or # a file name # a string of graphviz dot language # a swig pointer (handle) to a graph # a dict of dicts (or dict of lists) data structure self.has_layout = False # avoid creating members outside of init # backward compability filename = attr.get('file', filename) # guess input type if specified as first (nonkeyword) argument if thing is not None: # can't specify first argument and also file,data,string,handle filename = None data = None string = None handle = None if isinstance(thing, dict): data = thing # a dictionary of dictionaries (or lists) elif hasattr(thing, 'own'): # a Swig pointer - graph handle handle = thing elif is_string_like(thing): pattern = re.compile('(strict)?\s*(graph|digraph).*{.*}\s*', re.DOTALL) if pattern.match(thing): string = thing # this is a dot format graph in a string else: filename = thing # assume this is a file name else: raise TypeError('Unrecognized input %s' % thing) if handle is not None: # if handle was specified, reference it self.handle = handle elif filename is not None: # load new graph from file (creates self.handle) self.read(filename) elif string is not None: # load new graph from string (creates self.handle) # get the charset from the string to properly encode it for # writing to the temporary file in from_string() match = re.search(r'charset\s*=\s*"([^"]+)"', string) if match is not None: self.encoding = match.group(1) else: self.encoding = _DEFAULT_ENCODING self.from_string(string) else: # no handle, need to self.handle = None if self.handle is not None: # the handle was specified or created # get the encoding from the "charset" graph attribute item = gv.agget(self.handle, b'charset') if item is not None: self.encoding = item else: self.encoding = _DEFAULT_ENCODING else: # no handle was specified or created # get encoding from the "charset" kwarg self.encoding = attr.get('charset', _DEFAULT_ENCODING) try: if name is None: name = '' # instantiate a new, empty graph self.handle = gv.agraphnew(name.encode(self.encoding), strict, directed) except TypeError: raise TypeError("Graph name must be a string: %s" % name) # encoding is already set but if it was specified explicitly # as an attr, then set it explicitly for the graph if 'charset' in attr: gv.agattr_label(self.handle, 0, 'charset', self.encoding) # if data is specified, populate the newly created graph if data is not None: # load from dict of dicts or dict of lists for node in data: for nbr in data[node]: self.add_edge(node, nbr) self.add_nodes_from(data.keys()) # throw away the charset attribute, if one exists, # since we've already set it, and now it should not be changed if 'charset' in attr: del attr['charset'] # assign any attributes specified through keywords self.graph_attr = Attribute(self.handle, 0) # default graph attributes self.graph_attr.update(attr) # apply attributes passed to init self.node_attr = Attribute(self.handle, 1) # default node attributes self.edge_attr = Attribute(self.handle, 2) # default edge attribtes def __enter__(self): return self def __exit__(self, ext_type, exc_value, traceback): self.close() if _PY2: def __unicode__(self): return self.string() def __str__(self): return unicode(self).encode(self.encoding, 'replace') else: def __str__(self): return self.string() def __repr__(self): name = gv.agnameof(self.handle) if name is None: return '' % self.handle return '' % (name, self.handle) def __eq__(self, other): # two graphs are equal if they have exact same string representation # this is not graph isomorphism return self.string() == other.string() def __hash__(self): # hash the string representation for id return hash(self.string()) def __iter__(self): # provide "for n in G" return self.nodes_iter() def __contains__(self, n): # provide "n in G" return self.has_node(n) def __len__(self): return self.number_of_nodes() def __getitem__(self, n): # "G[n]" returns nodes attached to n return self.neighbors(n) # not implemented, but could be... # def __setitem__(self,u,v): # self.add_edge(u,v) def get_name(self): name = gv.agnameof(self.handle) if name is not None: name = name.decode(self.encoding) return name name = property(get_name) def add_node(self, n, **attr): """Add a single node n. If n is not a string, conversion to a string will be attempted. String conversion will work if n has valid string representation (try str(n) if you are unsure). >>> G=AGraph() >>> G.add_node('a') >>> G.nodes() # doctest: +IGNORE_UNICODE [u'a'] >>> G.add_node(1) # will be converted to a string >>> G.nodes() # doctest: +IGNORE_UNICODE [u'a', u'1'] Attributes can be added to nodes on creation or updated after creation (attribute values must be strings) >>> G.add_node(2,color='red') See http://www.graphviz.org/doc/info/attrs.html for a list of attributes. Anonymous Graphviz nodes are currently not implemented. """ if not is_string_like(n): n = str(n) n = n.encode(self.encoding) try: nh = gv.agnode(self.handle, n, _Action.find) except KeyError: nh = gv.agnode(self.handle, n, _Action.create) node = Node(self, nh=nh) node.attr.update(**attr) def add_nodes_from(self, nbunch, **attr): """Add nodes from a container nbunch. nbunch can be any iterable container such as a list or dictionary >>> G=AGraph() >>> nlist=['a','b',1,'spam'] >>> G.add_nodes_from(nlist) >>> sorted(G.nodes()) # doctest: +IGNORE_UNICODE [u'1', u'a', u'b', u'spam'] Attributes can be added to nodes on creation or updated after creation >>> G.add_nodes_from(nlist, color='red') # set all nodes in nlist red """ for n in nbunch: self.add_node(n, **attr) def remove_node(self, n): """Remove the single node n. Attempting to remove a node that isn't in the graph will produce an error. >>> G=AGraph() >>> G.add_node('a') >>> G.remove_node('a') """ if not is_string_like(n): n = str(n) n = n.encode(self.encoding) try: nh = gv.agnode(self.handle, n, _Action.find) gv.agdelnode(self.handle, nh) except KeyError: raise KeyError("Node %s not in graph." % n.decode(self.encoding)) delete_node = remove_node def remove_nodes_from(self, nbunch): """Remove nodes from a container nbunch. nbunch can be any iterable container such as a list or dictionary >>> G=AGraph() >>> nlist=['a','b',1,'spam'] >>> G.add_nodes_from(nlist) >>> G.remove_nodes_from(nlist) """ for n in nbunch: self.remove_node(n) delete_nodes_from = remove_nodes_from def nodes_iter(self): """Return an iterator over all the nodes in the graph. Note: modifying the graph structure while iterating over the nodes may produce unpredictable results. Use nodes() as an alternative. """ nh = gv.agfstnode(self.handle) while nh is not None: yield Node(self, nh=nh) nh = gv.agnxtnode(self.handle, nh) raise StopIteration iternodes = nodes_iter def nodes(self): """Return a list of all nodes in the graph.""" return list(self.nodes_iter()) def number_of_nodes(self): """Return the number of nodes in the graph.""" return gv.agnnodes(self.handle) def order(self): """Return the number of nodes in the graph.""" return self.number_of_nodes() def has_node(self, n): """Return True if n is in the graph or False if not. >>> G=AGraph() >>> G.add_node('a') >>> G.has_node('a') True >>> 'a' in G # same as G.has_node('a') True """ try: node = Node(self, n) return True except KeyError: return False def get_node(self, n): """Return a node object (Node) corresponding to node n. >>> G=AGraph() >>> G.add_node('a') >>> node=G.get_node('a') >>> print(node) a """ return Node(self, n) def add_edge(self, u, v=None, key=None, **attr): """Add a single edge between nodes u and v. If the nodes u and v are not in the graph they will added. If u and v are not strings, conversion to a string will be attempted. String conversion will work if u and v have valid string representation (try str(u) if you are unsure). >>> G=AGraph() >>> G.add_edge('a','b') >>> G.edges() # doctest: +IGNORE_UNICODE [(u'a', u'b')] The optional key argument allows assignment of a key to the edge. This is especially useful to distinguish between parallel edges in multi-edge graphs (strict=False). >>> G=AGraph(strict=False) >>> G.add_edge('a','b','first') >>> G.add_edge('a','b','second') >>> sorted(G.edges(keys=True)) # doctest: +IGNORE_UNICODE [(u'a', u'b', u'first'), (u'a', u'b', u'second')] Attributes can be added when edges are created or updated after creation >>> G.add_edge('a','b',color='green') Attributes must be valid strings. See http://www.graphviz.org/doc/info/attrs.html for a list of attributes. """ if v is None: (u, v) = u # no v given, assume u is an edge tuple try: uh = Node(self, u).handle except: self.add_node(u) uh = Node(self, u).handle try: vh = Node(self, v).handle except: self.add_node(v) vh = Node(self, v).handle if key is not None: if not is_string_like(key): key = str(key) key = key.encode(self.encoding) try: # new eh = gv.agedge(self.handle, uh, vh, key, _Action.create) except KeyError: # for strict graph, or already added eh = gv.agedge(self.handle, uh, vh, key, _Action.find) e = Edge(self, eh=eh) e.attr.update(**attr) def add_edges_from(self, ebunch, **attr): """Add nodes to graph from a container ebunch. ebunch is a container of edges such as a list or dictionary. >>> G=AGraph() >>> elist=[('a','b'),('b','c')] >>> G.add_edges_from(elist) Attributes can be added when edges are created or updated after creation >>> G.add_edges_from(elist, color='green') """ for e in ebunch: self.add_edge(e, **attr) def get_edge(self, u, v, key=None): """Return an edge object (Edge) corresponding to edge (u,v). >>> G=AGraph() >>> G.add_edge('a','b') >>> edge=G.get_edge('a','b') >>> print(edge) # doctest: +IGNORE_UNICODE (u'a', u'b') With optional key argument will only get edge matching (u,v,key). """ return Edge(self, u, v, key) def remove_edge(self, u, v=None, key=None): """Remove edge between nodes u and v from the graph. With optional key argument will only remove an edge matching (u,v,key). """ if v is None: (u, v) = u # no v given, assume u is an edge tuple e = Edge(self, u, v, key) try: gv.agdeledge(self.handle, e.handle) except KeyError: raise KeyError("Edge %s-%s not in graph." % (u, v)) delete_edge = remove_edge def remove_edges_from(self, ebunch): """Remove edges from ebunch (a container of edges).""" for e in ebunch: self.remove_edge(e) delete_edges_from = remove_edges_from def has_edge(self, u, v=None, key=None): """Return True an edge u-v is in the graph or False if not. >>> G=AGraph() >>> G.add_edge('a','b') >>> G.has_edge('a','b') True Optional key argument will restrict match to edges (u,v,key). """ if v is None: (u, v) = u # no v given, assume u is an edge tuple try: Edge(self, u, v, key) return True except KeyError: return False def edges(self, nbunch=None, keys=False): """Return list of edges in the graph. If the optional nbunch (container of nodes) only edges adjacent to nodes in nbunch will be returned. >>> G=AGraph() >>> G.add_edge('a','b') >>> G.add_edge('c','d') >>> print(sorted(G.edges())) # doctest: +IGNORE_UNICODE [(u'a', u'b'), (u'c', u'd')] >>> print(G.edges('a')) # doctest: +IGNORE_UNICODE [(u'a', u'b')] """ return list(self.edges_iter(nbunch=nbunch, keys=keys)) def has_neighbor(self, u, v, key=None): """Return True if u has an edge to v or False if not. >>> G=AGraph() >>> G.add_edge('a','b') >>> G.has_neighbor('a','b') True Optional key argument will only find edges (u,v,key). """ return self.has_edge(u, v) def neighbors_iter(self, n): """Return iterator over the nodes attached to n. Note: modifying the graph structure while iterating over node neighbors may produce unpredictable results. Use neighbors() as an alternative. """ n = Node(self, n) nh = n.handle eh = gv.agfstedge(self.handle, nh) while eh is not None: (s, t) = Edge(self, eh=eh) if s == n: yield Node(self, t) else: yield Node(self, s) eh = gv.agnxtedge(self.handle, eh, nh) raise StopIteration def neighbors(self, n): """Return a list of the nodes attached to n.""" return list(self.neighbors_iter(n)) iterneighbors = neighbors_iter def out_edges_iter(self, nbunch=None, keys=False): """Return iterator over out edges in the graph. If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be returned. Note: modifying the graph structure while iterating over edges may produce unpredictable results. Use out_edges() as an alternative. """ if nbunch is None: # all nodes nh = gv.agfstnode(self.handle) while nh is not None: eh = gv.agfstout(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtout(self.handle, eh) nh = gv.agnxtnode(self.handle, nh) elif nbunch in self: # if nbunch is a single node n = Node(self, nbunch) nh = n.handle eh = gv.agfstout(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtout(self.handle, eh) else: # if nbunch is a sequence of nodes try: bunch = [n for n in nbunch if n in self] except TypeError: raise TypeError("nbunch is not a node or a sequence of nodes.") for n in nbunch: try: nh = Node(self, n).handle except KeyError: continue eh = gv.agfstout(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtout(self.handle, eh) raise StopIteration iteroutedges = out_edges_iter def in_edges_iter(self, nbunch=None, keys=False): """Return iterator over out edges in the graph. If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be returned. Note: modifying the graph structure while iterating over edges may produce unpredictable results. Use in_edges() as an alternative. """ if nbunch is None: # all nodes nh = gv.agfstnode(self.handle) while nh is not None: eh = gv.agfstin(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtin(self.handle, eh) nh = gv.agnxtnode(self.handle, nh) elif nbunch in self: # if nbunch is a single node n = Node(self, nbunch) nh = n.handle eh = gv.agfstin(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtin(self.handle, eh) else: # if nbunch is a sequence of nodes try: bunch = [n for n in nbunch if n in self] except TypeError: raise TypeError("nbunch is not a node or a sequence of nodes.") for n in nbunch: try: nh = Node(self, n).handle except KeyError: continue eh = gv.agfstin(self.handle, nh) while eh is not None: e = Edge(self, eh=eh) if keys: yield (e[0], e[1], e.name) else: yield e eh = gv.agnxtin(self.handle, eh) raise StopIteration def edges_iter(self, nbunch=None, keys=False): """Return iterator over edges in the graph. If the optional nbunch (container of nodes) only edges adjacent to nodes in nbunch will be returned. Note: modifying the graph structure while iterating over edges may produce unpredictable results. Use edges() as an alternative. """ if nbunch is None: # all nodes for e in self.out_edges_iter(keys=keys): yield e elif nbunch in self: # only one node for e in self.out_edges_iter(nbunch, keys=keys): yield e for e in self.in_edges_iter(nbunch, keys=keys): if e != (nbunch, nbunch): yield e else: # a group of nodes used = set() for e in self.out_edges_iter(nbunch, keys=keys): yield e used.add(e) for e in self.in_edges_iter(nbunch, keys=keys): if e not in used: yield e iterinedges = in_edges_iter iteredges = edges_iter def out_edges(self, nbunch=None, keys=False): """Return list of out edges in the graph. If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be returned. """ return list(self.out_edges_iter(nbunch=nbunch, keys=keys)) def in_edges(self, nbunch=None, keys=False): """Return list of in edges in the graph. If the optional nbunch (container of nodes) only in edges adjacent to nodes in nbunch will be returned. """ return list(self.in_edges_iter(nbunch=nbunch, keys=keys)) def predecessors_iter(self, n): """Return iterator over predecessor nodes of n. Note: modifying the graph structure while iterating over node predecessors may produce unpredictable results. Use predecessors() as an alternative. """ n = Node(self, n) nh = n.handle eh = gv.agfstin(self.handle, nh) while eh is not None: (s, t) = Edge(self, eh=eh) if s == n: yield Node(self, t) else: yield Node(self, s) eh = gv.agnxtin(self.handle, eh) raise StopIteration iterpred = predecessors_iter def successors_iter(self, n): """Return iterator over successor nodes of n. Note: modifying the graph structure while iterating over node successors may produce unpredictable results. Use successors() as an alternative. """ n = Node(self, n) nh = n.handle eh = gv.agfstout(self.handle, nh) while eh is not None: (s, t) = Edge(self, eh=eh) if s == n: yield Node(self, t) else: yield Node(self, s) eh = gv.agnxtout(self.handle, eh) raise StopIteration itersucc = successors_iter def successors(self, n): """Return list of successor nodes of n.""" return list(self.successors_iter(n)) def predecessors(self, n): """Return list of predecessor nodes of n.""" return list(self.predecessors_iter(n)) # digraph definitions out_neighbors = successors in_neighbors = predecessors def degree_iter(self, nbunch=None, indeg=True, outdeg=True): """Return an iterator over the degree of the nodes given in nbunch container. Returns paris of (node,degree). """ # prepare nbunch if nbunch is None: # include all nodes via iterator bunch = [n for n in self.nodes_iter()] elif nbunch in self: # if nbunch is a single node bunch = [Node(self, nbunch)] else: # if nbunch is a sequence of nodes try: bunch = [Node(self, n) for n in nbunch if n in self] except TypeError: raise TypeError("nbunch is not a node or a sequence of nodes.") for n in bunch: yield (Node(self, n), gv.agdegree(self.handle, n.handle, indeg, outdeg)) def in_degree_iter(self, nbunch=None): """Return an iterator over the in-degree of the nodes given in nbunch container. Returns paris of (node,degree). """ return self.degree_iter(nbunch, indeg=True, outdeg=False) def out_degree_iter(self, nbunch=None): """Return an iterator over the out-degree of the nodes given in nbunch container. Returns paris of (node,degree). """ return self.degree_iter(nbunch, indeg=False, outdeg=True) iteroutdegree = out_degree_iter iterindegree = in_degree_iter def out_degree(self, nbunch=None, with_labels=False): """Return the out-degree of nodes given in nbunch container. Using optional with_labels=True returns a dictionary keyed by node with value set to the degree. """ if with_labels: return dict(self.out_degree_iter(nbunch)) else: dlist = list(d for n, d in self.out_degree_iter(nbunch)) if nbunch in self: return dlist[0] else: return dlist def in_degree(self, nbunch=None, with_labels=False): """Return the in-degree of nodes given in nbunch container. Using optional with_labels=True returns a dictionary keyed by node with value set to the degree. """ if with_labels: return dict(self.in_degree_iter(nbunch, with_labels)) else: dlist = list(d for n, d in self.in_degree_iter(nbunch)) if nbunch in self: return dlist[0] else: return dlist def reverse(self): """Return copy of directed graph with edge directions reversed.""" if self.directed: # new empty DiGraph H = self.__class__(strict=self.strict, directed=True, name=self.name) H.graph_attr.update(self.graph_attr) H.node_attr.update(self.node_attr) H.edge_attr.update(self.edge_attr) for n in self.nodes(): H.add_node(n) new_n = Node(H, n) new_n.attr.update(n.attr) for e in self.edges(): (u, v) = e H.add_edge(v, u) uv = H.get_edge(v, u) uv.attr.update(e.attr) return H else: return self def degree(self, nbunch=None, with_labels=False): """Return the degree of nodes given in nbunch container. Using optional with_labels=True returns a dictionary keyed by node with value set to the degree. """ if with_labels: return dict(self.degree_iter(nbunch)) else: dlist = list(d for n, d in self.degree_iter(nbunch)) if nbunch in self: return dlist[0] else: return dlist iterdegree = degree_iter def number_of_edges(self): """Return the number of edges in the graph.""" return gv.agnedges(self.handle) def size(self): """Return the number of edges in the graph.""" return self.number_of_edges() def clear(self): """Remove all nodes, edges, and attributes from the graph.""" self.remove_edges_from(self.edges()) self.remove_nodes_from(self.nodes()) # now "close" existing graph and create a new graph name = gv.agnameof(self.handle) strict = self.strict directed = self.directed gv.agclose(self.handle) self.handle = gv.agraphnew(name, strict, directed) def close(self): # may be useful to clean up graphviz data # this should completely remove all of the existing graphviz data gv.agclose(self.handle) def copy(self): """Return a copy of the graph.""" from tempfile import TemporaryFile fh = TemporaryFile() # Cover TemporaryFile wart: on 'nt' we need the file member if hasattr(fh, 'file'): fhandle = fh.file else: fhandle = fh self.write(fhandle) fh.seek(0) return self.__class__(filename=fhandle) def add_path(self, nlist): """Add the path of nodes given in nlist.""" fromv = nlist.pop(0) while len(nlist) > 0: tov = nlist.pop(0) self.add_edge(fromv, tov) fromv = tov def add_cycle(self, nlist): """Add the cycle of nodes given in nlist.""" self.add_path(nlist + [nlist[0]]) def prepare_nbunch(self, nbunch=None): # private function to build bunch from nbunch if nbunch is None: # include all nodes via iterator bunch = self.nodes_iter() elif nbunch in self: # if nbunch is a single node bunch = [Node(self, nbunch)] else: # if nbunch is a sequence of nodes try: # capture error for nonsequence/iterator entries. bunch = [Node(self, n) for n in nbunch if n in self] # bunch=(n for n in nbunch if n in self) # need python 2.4 except TypeError: raise TypeError("nbunch is not a node or a sequence of nodes.") return bunch def add_subgraph(self, nbunch=None, name=None, **attr): """Return subgraph induced by nodes in nbunch. """ if name is not None: name = name.encode(self.encoding) try: handle = gv.agsubg(self.handle, name, _Action.create) except TypeError: raise TypeError("Subgraph name must be a string: %s" % name.decode(self.encoding)) H = self.__class__(strict=self.strict, directed=self.directed, handle=handle, name=name, **attr) if nbunch is None: return H # add induced subgraph on nodes in nbunch bunch = self.prepare_nbunch(nbunch) for n in bunch: node = Node(self, n) nh = gv.agsubnode(handle, node.handle, _Action.create) for (u, v, k) in self.edges(keys=True): if u in H and v in H: edge = Edge(self, u, v, k) eh = gv.agsubedge(handle, edge.handle, _Action.create) return H def remove_subgraph(self, name): """Remove subgraph with given name.""" try: handle = gv.agsubg(self.handle, name.encode(self.encoding), _Action.find) except TypeError: raise TypeError("Subgraph name must be a string: %s" % name) if handle is None: raise KeyError("Subgraph %s not in graph." % name) gv.agdelsubg(self.handle, handle) delete_subgraph = remove_subgraph subgraph = add_subgraph def subgraph_parent(self, nbunch=None, name=None): """Return parent graph of subgraph or None if graph is root graph. """ handle = gv.agparent(self.handle) if handle is None: return None H = self.__class__(strict=self.strict, directed=self.directed, handle=handle, name=name) return H def subgraph_root(self, nbunch=None, name=None): """Return root graph of subgraph or None if graph is root graph. """ handle = gv.agroot(self.handle) if handle is None: return None H = self.__class__(strict=self.strict, directed=self.directed, handle=handle, name=name) return H def get_subgraph(self, name): """Return existing subgraph with specified name or None if it doesn't exist. """ try: handle = gv.agsubg(self.handle, name.encode(self.encoding) , _Action.find) except TypeError: raise TypeError("Subgraph name must be a string: %s" % name) if handle is None: return None H = self.__class__(strict=self.strict, directed=self.directed, handle=handle) return H def subgraphs_iter(self): """Iterator over subgraphs.""" handle = gv.agfstsubg(self.handle) while handle is not None: yield self.__class__(strict=self.strict, directed=self.directed, handle=handle) handle = gv.agnxtsubg(handle) raise StopIteration def subgraphs(self): """Return a list of all subgraphs in the graph.""" return list(self.subgraphs_iter()) # directed, undirected tests and conversions def is_strict(self): """Return True if graph is strict or False if not. Strict graphs do not allow parallel edges or self loops. """ if gv.agisstrict(self.handle) == 1: return True else: return False strict = property(is_strict) def is_directed(self): """Return True if graph is directed or False if not.""" if gv.agisdirected(self.handle) == 1: return True else: return False directed = property(is_directed) def is_undirected(self): """Return True if graph is undirected or False if not.""" if gv.agisundirected(self.handle) == 1: return True else: return False def to_undirected(self): """Return undirected copy of graph.""" if not self.directed: return self.copy() else: U = AGraph(strict=self.strict) U.graph_attr.update(self.graph_attr) U.node_attr.update(self.node_attr) U.edge_attr.update(self.edge_attr) for n in self.nodes(): U.add_node(n) new_n = Node(U, n) new_n.attr.update(n.attr) for e in self.edges(): (u, v) = e U.add_edge(u, v) uv = U.get_edge(u, v) uv.attr.update(e.attr) return U def to_directed(self, **kwds): """Return directed copy of graph. Each undirected edge u-v is represented as two directed edges u->v and v->u. """ if not self.directed: D = AGraph(strict=self.strict, directed=True) D.graph_attr.update(self.graph_attr) D.node_attr.update(self.node_attr) D.edge_attr.update(self.edge_attr) for n in self.nodes(): D.add_node(n) new_n = Node(D, n) new_n.attr.update(n.attr) for e in self.edges(): (u, v) = e D.add_edge(u, v) D.add_edge(v, u) uv = D.get_edge(u, v) vu = D.get_edge(v, u) uv.attr.update(e.attr) uv.attr.update(e.attr) vu.attr.update(e.attr) return D else: return self.copy() # io def read(self, path): """Read graph from dot format file on path. path can be a file name or file handle use:: G.read('file.dot') """ fh = self._get_fh(path) try: if self.handle is not None: gv.agclose(self.handle) try: self.handle = gv.agread(fh, None) except ValueError: raise DotError except IOError: print("IO error reading file") def write(self, path=None): """Write graph in dot format to file on path. path can be a file name or file handle use:: G.write('file.dot') """ if path is None: path = sys.stdout fh = self._get_fh(path, 'w') try: gv.agwrite(self.handle, fh) except IOError: print("IO error writing file") def string_nop(self): """Return a string (unicode) representation of graph in dot format.""" # this will fail for graphviz-2.8 because of a broken nop # so use tempfile version below return self.draw(format='dot', prog='nop').decode(self.encoding) def to_string(self): """Return a string (unicode) representation of graph in dot format.""" from tempfile import TemporaryFile fh = TemporaryFile() # Cover TemporaryFile wart: on 'nt' we need the file member if hasattr(fh, 'file'): self.write(fh.file) else: self.write(fh) fh.seek(0) data = fh.read() fh.close() return data.decode(self.encoding) def string(self): """Return a string (unicode) representation of graph in dot format.""" # return self.to_string() return self.string_nop() def from_string(self, string): """Load a graph from a string in dot format. Overwrites any existing graph. To make a new graph from a string use >>> s='digraph {1 -> 2}' >>> A=AGraph() >>> t=A.from_string(s) >>> A=AGraph(string=s) # specify s is a string >>> A=AGraph(s) # s assumed to be a string during initialization """ # allow either unicode or encoded string try: string = string.decode(self.encoding) except (UnicodeEncodeError, AttributeError): pass from tempfile import TemporaryFile fh = TemporaryFile() fh.write(string.encode(self.encoding)) fh.seek(0) # Cover TemporaryFile wart: on 'nt' we need the file member if hasattr(fh, 'file'): self.read(fh.file) else: self.read(fh) fh.close() return self def _get_prog(self, prog): # private: get path of graphviz program progs = ['neato', 'dot', 'twopi', 'circo', 'fdp', 'nop', 'wc', 'acyclic', 'gvpr', 'gvcolor', 'ccomps', 'sccmap', 'tred', 'sfdp'] if prog not in progs: raise ValueError("Program %s is not one of: %s." % (prog, ', '.join(progs))) try: # user must pick one of the graphviz programs... runprog = self._which(prog) except: raise ValueError("Program %s not found in path." % prog) return runprog def _run_prog(self, prog='nop', args=''): """Apply graphviz program to graph and return the result as a string. >>> A = AGraph() >>> s = A._run_prog() # doctest: +SKIP >>> s = A._run_prog(prog='acyclic') # doctest: +SKIP Use keyword args to add additional arguments to graphviz programs. """ runprog = r'"%s"' % self._get_prog(prog) cmd = ' '.join([runprog, args]) dotargs = shlex.split(cmd) p = subprocess.Popen(dotargs, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) # Use threading to avoid blocking data = [] errors = [] threads = [PipeReader(data, child_stdout), PipeReader(errors, child_stderr)] for t in threads: t.start() self.write(child_stdin) child_stdin.close() for t in threads: t.join() if not data: raise IOError(b"".join(errors)) if len(errors) > 0: warnings.warn(b"".join(errors), RuntimeWarning) return b"".join(data) def layout(self, prog='neato', args=''): """Assign positions to nodes in graph. Optional prog=['neato'|'dot'|'twopi'|'circo'|'fdp'|'nop'] will use specified graphviz layout method. >>> A=AGraph() >>> A.layout() # uses neato >>> A.layout(prog='dot') Use keyword args to add additional arguments to graphviz programs. The layout might take a long time on large graphs. """ fmt = 'dot' data = self._run_prog(prog, ' '.join([args, "-T", fmt])) self.from_string(data) self.has_layout = True return def tred(self, args='', copy=False): """Transitive reduction of graph. Modifies existing graph. To create a new graph use >>> A=AGraph() >>> B=A.tred(copy=True) # doctest: +SKIP See the graphviz "tred" program for details of the algorithm. """ data = self._run_prog('tred', args) if copy: return self.__class__(string=data) else: return self.from_string(data) def acyclic(self, args='', copy=False): """Reverse sufficient edges in digraph to make graph acyclic. Modifies existing graph. To create a new graph use >>> A=AGraph() >>> B=A.acyclic(copy=True) # doctest: +SKIP See the graphviz "acyclic" program for details of the algorithm. """ data = self._run_prog('acyclic', args) if copy: return self.__class__(string=data) else: return self.from_string(data) def draw(self, path=None, format=None, prog=None, args=''): """Output graph to path in specified format. An attempt will be made to guess the output format based on the file extension of `path`. If that fails, then the `format` parameter will be used. Note, if `path` is a file object returned by a call to os.fdopen(), then the method for discovering the format will not work. In such cases, one should explicitly set the `format` parameter; otherwise, it will default to 'dot'. Formats (not all may be available on every system depending on how Graphviz was built) 'canon', 'cmap', 'cmapx', 'cmapx_np', 'dia', 'dot', 'fig', 'gd', 'gd2', 'gif', 'hpgl', 'imap', 'imap_np', 'ismap', 'jpe', 'jpeg', 'jpg', 'mif', 'mp', 'pcl', 'pdf', 'pic', 'plain', 'plain-ext', 'png', 'ps', 'ps2', 'svg', 'svgz', 'vml', 'vmlz', 'vrml', 'vtx', 'wbmp', 'xdot', 'xlib' If prog is not specified and the graph has positions (see layout()) then no additional graph positioning will be performed. Optional prog=['neato'|'dot'|'twopi'|'circo'|'fdp'|'nop'] will use specified graphviz layout method. >>> G = AGraph() >>> G.layout() # use current node positions, output ps in 'file.ps' >>> G.draw('file.ps') # use dot to position, output png in 'file' >>> G.draw('file', format='png',prog='dot') # use keyword 'args' to pass additional arguments to graphviz >>> G.draw('test.ps',prog='twopi',args='-Gepsilon=1') The layout might take a long time on large graphs. """ import os # try to guess format from extension if format is None and path is not None: p = path # in case we got a file handle get its name instead if not is_string_like(p): p = path.name format = os.path.splitext(p)[-1].lower()[1:] if format is None or format == '': format = 'dot' if prog is None: if self.has_layout: prog = 'neato' args += "-n2" else: raise AttributeError( """Graph has no layout information, see layout() or specify prog=%s.""" % ("|".join(['neato', 'dot', 'twopi', 'circo', 'fdp', 'nop']))) else: if self.number_of_nodes() > 1000: sys.stderr.write( "Warning: graph has %s nodes...layout may take a long time.\n" % self.number_of_nodes()) if prog == 'nop': # nop takes no switches args = '' else: args = ' '.join([args, "-T" + format]) data = self._run_prog(prog, args) if path is not None: fh = self._get_fh(path, 'w+b') fh.write(data) if is_string_like(path): fh.close() d = None else: d = data return d # some private helper functions def _get_fh(self, path, mode='r'): """ Return a file handle for given path. Path can be a string or a file handle. Attempt to uncompress/compress files ending in '.gz' and '.bz2'. """ import os if is_string_like(path): if path.endswith('.gz'): #import gzip #fh = gzip.open(path,mode=mode) # doesn't return real fh fh = os.popen("gzcat " + path) # probably not portable elif path.endswith('.bz2'): #import bz2 #fh = bz2.BZ2File(path,mode=mode) # doesn't return real fh fh = os.popen("bzcat " + path) # probably not portable else: fh = open(path, mode=mode) elif hasattr(path, 'write'): # Note, mode of file handle is unchanged. fh = path else: raise TypeError('path must be a string or file handle.') return fh def _which(self, name): """Searches for name in exec path and returns full path""" import os import glob paths = os.environ["PATH"] if os.name == "nt": exe = ".exe" else: exe = "" for path in paths.split(os.pathsep): match = glob.glob(os.path.join(path, name + exe)) if match: return match[0] raise ValueError("No prog %s in path." % name) class Node(_TEXT_TYPE): """Node object based on unicode. If G is a graph >>> G=AGraph() then >>> G.add_node(1) will create a node object labeled by the string "1". To get the object use >>> node=Node(G,1) or >>> node=G.get_node(1) The node object is derived from a string and can be manipulated as such. Each node has attributes that can be directly accessed through the attr dictionary: >>> node.attr['color']='red' """ def __new__(self, graph, name=None, nh=None): if nh is not None: n = super(Node, self).__new__(self, gv.agnameof(nh), graph.encoding) else: n = super(Node, self).__new__(self, name) try: nh = gv.agnode(graph.handle, n.encode(graph.encoding), _Action.find) except KeyError: raise KeyError("Node %s not in graph." % n) n.ghandle = graph.handle n.attr = ItemAttribute(nh, 1) n.handle = nh n.encoding = graph.encoding return n def get_handle(self): """Return pointer to graphviz node object.""" return gv.agnode(self.ghandle, self.encode(self.encoding), _Action.find) # handle=property(get_handle) def get_name(self): name = gv.agnameof(self.handle) if name is not None: name = name.decode(self.encoding) return name name = property(get_name) class Edge(tuple): """Edge object based on tuple. If G is a graph >>> G=AGraph() then >>> G.add_edge(1,2) will add the edge 1-2 to the graph. >>> edge=Edge(G,1,2) or >>> edge=G.get_edge(1,2) will get the edge object. An optional key can be used >>> G.add_edge(2,3,'spam') >>> edge=Edge(G,2,3,'spam') The edge is represented as a tuple (u,v) or (u,v,key) and can be manipulated as such. Each edge has attributes that can be directly accessed through the attr dictionary: >>> edge.attr['color']='red' """ def __new__(self, graph, source=None, target=None, key=None, eh=None): # edge handle given, reconstruct node object if eh is not None: (source, target) = (gv.agtail(eh), gv.aghead(eh)) s = Node(graph, nh=source) t = Node(graph, nh=target) # no edge handle, search for edge and construct object else: s = Node(graph, source) t = Node(graph, target) if key is not None: if not is_string_like(key): key = str(key) key = key.encode(graph.encoding) try: eh = gv.agedge(graph.handle, s.handle, t.handle, key, _Action.find) except KeyError: raise KeyError("Edge %s-%s not in graph." % (source, target)) tp = tuple.__new__(self, (s, t)) tp.ghandle = graph.handle tp.handle = eh tp.attr = ItemAttribute(eh, 3) tp.encoding = graph.encoding return tp def get_name(self): name = gv.agnameof(self.handle) if name is not None: name = name.decode(self.encoding) return name name = property(get_name) key = property(get_name) class Attribute(DictMixin): """Default attributes for graphs. Assigned on initialization of AGraph class. and manipulated through the class data. >>> G=AGraph() # initialize, G.graph_attr, G.node_attr, G.edge_attr >>> G.graph_attr['splines']='true' >>> G.node_attr['shape']='circle' >>> G.edge_attr['color']='red' See http://graphviz.org/doc/info/attrs.html for a list of all attributes. """ # use for graph, node, and edge default attributes # atype:graph=0, node=1,edge=3 def __init__(self, handle, atype): self.handle = handle self.type = atype # get the encoding ghandle = gv.agraphof(handle) root_handle = gv.agroot(ghandle) # get root graph try: ah = gv.agattr(root_handle, 0, b'charset', None) self.encoding = gv.agattrdefval(ah) except KeyError: self.encoding = _DEFAULT_ENCODING def __setitem__(self, name, value): if name == 'charset' and self.type == 0: raise ValueError('Graph charset is immutable!') if not is_string_like(value): value = str(value) ghandle = gv.agroot(self.handle) # get root graph if ghandle == self.handle: gv.agattr_label(self.handle, self.type, name.encode(self.encoding), value.encode(self.encoding)) else: gv.agsafeset_label(ghandle, self.handle, name.encode(self.encoding), value.encode(self.encoding), b'') def __getitem__(self, name): item = gv.agget(self.handle, name.encode(self.encoding)) if item is None: ah = gv.agattr(self.handle, self.type, name.encode(self.encoding), None) item = gv.agattrdefval(ah) return item.decode(self.encoding) def __delitem__(self, name): gv.agattr(self.handle, self.type, name.encode(self.encoding), b'') def __contains__(self, name): try: self.__getitem__(name) return True except: return False def __len__(self): return len(self.__iter__()) def has_key(self, name): return self.__contains__(name) def keys(self): return list(self.__iter__()) def __iter__(self): for (k, v) in self.iteritems(): yield k def iteritems(self): ah = None while True: try: ah = gv.agnxtattr(self.handle, self.type, ah) yield (gv.agattrname(ah).decode(self.encoding), gv.agattrdefval(ah).decode(self.encoding)) except KeyError: # gv.agattrdefval returned KeyError, skip continue class ItemAttribute(Attribute): """Attributes for individual nodes and edges. Assigned on initialization of Node or Edge classes and manipulated through the class data. >>> G=AGraph() >>> G.add_edge('a','b') >>> n=Node(G,'a') >>> n.attr['shape']='circle' >>> e=Edge(G,'a','b') >>> e.attr['color']='red' See http://graphviz.org/doc/info/attrs.html for a list of all attributes. """ # use for individual item attributes - either a node or an edge # graphs and default node and edge attributes use Attribute def __init__(self, handle, atype): self.handle = handle self.type = atype self.ghandle = gv.agraphof(handle) # get the encoding root_handle = gv.agroot(self.ghandle) # get root graph try: ah = gv.agattr(root_handle, 0, b'charset', None) self.encoding = gv.agattrdefval(ah) except KeyError: self.encoding = _DEFAULT_ENCODING def __setitem__(self, name, value): if not is_string_like(value): value = str(value) if self.type == 1 and name == 'label': default = '\\N' else: default = '' gv.agsafeset_label(self.ghandle, self.handle, name.encode(self.encoding), value.encode(self.encoding), default.encode(self.encoding)) def __getitem__(self, name): val = gv.agget(self.handle, name.encode(self.encoding)) if val is not None: val = val.decode(self.encoding) return val def __delitem__(self, name): gv.agset(self.handle, name.encode(self.encoding), b'') def iteritems(self): ah = None while 1: try: ah = gv.agnxtattr(self.ghandle, self.type, ah) value = gv.agxget(self.handle, ah) try: defval = gv.agattrdefval(ah) # default value if defval == value: continue # don't report default except: # no default, gv.getattrdefval raised error pass # unique value for this edge yield (gv.agattrname(ah).decode(self.encoding), value.decode(self.encoding)) except KeyError: # gv.agxget returned KeyError, skip continue def _test_suite(): import doctest suite = doctest.DocFileSuite('tests/graph.txt', 'tests/attributes.txt', 'tests/layout_draw.txt', 'tests/subgraph.txt', package='pygraphviz') doctest.testmod() # test docstrings in module return suite if __name__ == "__main__": import os import sys import unittest if sys.version_info[:2] < (2, 4): print("Python version 2.4 or later required for tests (%d.%d detected)." % sys.version_info[:2]) sys.exit(-1) # directory of package (relative to this) nxbase = sys.path[0] + os.sep + os.pardir sys.path.insert(0, nxbase) # prepend to search path unittest.TextTestRunner().run(_test_suite()) pygraphviz-1.3.1/pygraphviz/version.py0000644000175000017500000000030512573042206020036 0ustar aricaric00000000000000""" Version information for PyGraphviz, created during installation. Do not add this file to the repository. """ __version__ = '1.3.1' __revision__ = None __date__ = 'Sun Sep 6 07:49:58 2015' pygraphviz-1.3.1/tox.ini0000644000175000017500000000034312573042175015116 0ustar aricaric00000000000000[tox] envlist = py26,py27,py32,py33,py34 [testenv] deps = nose doctest-ignore-unicode commands = nosetests -c {toxinidir}/setup.cfg -x ; Run tests from inside the virtualenv. changedir = {envsitepackagesdir}/pygraphviz pygraphviz-1.3.1/LICENSE0000644000175000017500000000312512573042175014611 0ustar aricaric00000000000000Copyright (C) 2004-2015 by Aric Hagberg Dan Schult Manos Renieris, http://www.cs.brown.edu/~er/ Distributed with BSD license. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pygraphviz-1.3.1/MANIFEST.in0000644000175000017500000000056712573042175015351 0ustar aricaric00000000000000include MANIFEST.in include INSTALL.txt include README.rst include LICENSE include *.py include *.swg include Makefile include tox.ini recursive-include doc *.png recursive-include pygraphviz *.i recursive-include examples *.py *.gz recursive-include doc *.py *.rst Makefile *.html *.txt *.css global-exclude *~ global-exclude *.pyc global-exclude .svn prune doc/build pygraphviz-1.3.1/doc/0000755000175000017500000000000012573042274014350 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/source/0000755000175000017500000000000012573042274015650 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/source/download.rst0000644000175000017500000000060112573042175020206 0ustar aricaric00000000000000-------- Download -------- Software ~~~~~~~~ Source and binary releases: https://pypi.python.org/pypi/pygraphviz Github (latest development): https://github.com/pygraphviz/pygraphviz Documentation ~~~~~~~~~~~~~ *PDF* http://pygraphviz.github.io/documentation/latest/pygraphviz.pdf *HTML in zip file* http://pygraphviz.github.io/documentation/latest/pygraphviz-documentation.zip pygraphviz-1.3.1/doc/source/tutorial.rst0000644000175000017500000000540012573042175020244 0ustar aricaric00000000000000Tutorial ======== The API is very similar to that of NetworkX. Much of the NetworkX tutorial at http://networkx.github.io/documentation/latest/tutorial/ is applicable to PyGraphviz. See http://pygraphviz.github.io/documentation/latest/reference/api_notes.html for major differences. Start-up -------- Import PyGraphviz with >>> import pygraphviz as pgv or to bring into the current namespace without the "pgv" prefix >>> from pygraphviz import * Graphs ------ To make an empty pygraphviz graph use the AGraph class: >>> G=pgv.AGraph() You can use the strict and directed keywords to control what type of graph you want. The default is to create a strict graph (no parallel edges or self-loops). To create a digraph with possible parallel edges and self-loops use >>> G=pgv.AGraph(strict=False,directed=True) You may specify a dot format file to be read on initialization: >>> G=pgv.AGraph("Petersen.dot") # doctest: +SKIP Other options for intializing a graph are using a string, >>> G=pgv.AGraph('graph {1 - 2}') using a dict of dicts, >>> d={'1': {'2': None}, '2': {'1': None, '3': None}, '3': {'2': None}} >>> A=pgv.AGraph(d) or using a SWIG pointer to the AGraph datastructure, >>> h=A.handle >>> C=pgv.AGraph(h) Nodes, and edges ---------------- Nodes and edges can be added one at a time >>> G.add_node('a') # adds node 'a' >>> G.add_edge('b','c') # adds edge 'b'-'c' (and also nodes 'b', 'c') or from lists or containers. >>> nodelist=['f','g','h'] >>> G.add_nodes_from(nodelist) If the node is not a string an attempt will be made to convert it to a string >>> G.add_node(1) # adds node '1' Attributes ---------- To set the default attributes for graphs, nodes, and edges use the graph_attr, node_attr, and edge_attr dictionaries >>> G.graph_attr['label']='Name of graph' >>> G.node_attr['shape']='circle' >>> G.edge_attr['color']='red' Graph attributes can be set when initializing the graph >>> G=pgv.AGraph(ranksep='0.1') Attributes can be added when adding nodes or edges, >>> G.add_node(1, color='red') >>> G.add_edge('b','c',color='blue') or through the node or edge attr dictionaries, >>> n=G.get_node(1) >>> n.attr['shape']='box' >>> e=G.get_edge('b','c') >>> e.attr['color']='green' Layout and Drawing ------------------ Pygraphviz provides several methods for layout and drawing of graphs. To store and print the graph in dot format as a Python string use >>> s=G.string() To write to a file use >>> G.write("file.dot") To add positions to the nodes with a Graphviz layout algorithm >>> G.layout() # default to neato >>> G.layout(prog='dot') # use dot To render the graph to an image >>> G.draw('file.png') # write previously positioned graph to PNG file >>> G.draw('file.ps',prog='circo') # use circo to position, write PS file pygraphviz-1.3.1/doc/source/conf.py0000644000175000017500000001363412573042175017156 0ustar aricaric00000000000000# -*- coding: utf-8 -*- # # Sphinx documentation build configuration file, created by # sphinx-quickstart.py on Sat Mar 8 21:47:50 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os, re # If your extensions are in another directory, add it here. #sys.path.append(os.path.dirname(__file__)) sys.path.append(os.path.abspath('../sphinxext')) #sys.path.append(os.path.abspath('../sphinxext/numpyext')) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.addons.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.pngmath','sphinx.ext.doctest'] # Add any paths that contain templates here, relative to this directory. templates_path = ['templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' # General substitutions. project = 'PyGraphviz' copyright = '2013, PyGraphviz Developers' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. import pygraphviz version =pygraphviz.__version__ # The full version, including alpha/beta/rc tags. release = version # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. unused_docs = [] # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = False show_authors = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'friendly' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'sphinxdoc.css' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Content template for the index page. html_index = 'contents.html' # Custom sidebar templates, maps page names to templates. #html_sidebars = {'index': 'indexsidebar.html'} # Additional templates that should be rendered to pages, maps page names to # templates. #html_additional_pages = {'index': 'index.html'} # If true, the reST sources are included in the HTML build as _sources/. html_copy_source = False html_use_opensearch = 'http://pygraphviz.github.io' # Output file base name for HTML help builder. htmlhelp_basename = 'PyGraphviz' pngmath_use_preview = True # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [('index', 'pygraphviz.tex', 'PyGraphviz Documentation', 'PyGraphviz Developers', 'manual', 1)] #latex_use_parts = True # Additional stuff for the LaTeX preamble. latex_elements = { 'fontpkg': '\\usepackage{palatino}' } # Documents to append as an appendix to all manuals. #latex_appendices = [] # Extension interface # ------------------- from sphinx import addnodes dir_sig_re = re.compile(r'\.\. ([^:]+)::(.*)$') def parse_directive(env, sig, signode): if not sig.startswith('.'): dec_sig = '.. %s::' % sig signode += addnodes.desc_name(dec_sig, dec_sig) return sig m = dir_sig_re.match(sig) if not m: signode += addnodes.desc_name(sig, sig) return sig name, args = m.groups() dec_name = '.. %s::' % name signode += addnodes.desc_name(dec_name, dec_name) signode += addnodes.desc_addname(args, args) return name def parse_role(env, sig, signode): signode += addnodes.desc_name(':%s:' % sig, ':%s:' % sig) return sig event_sig_re = re.compile(r'([a-zA-Z-]+)\s*\((.*)\)') def parse_event(env, sig, signode): m = event_sig_re.match(sig) if not m: signode += addnodes.desc_name(sig, sig) return sig name, args = m.groups() signode += addnodes.desc_name(name, name) plist = addnodes.desc_parameterlist() for arg in args.split(','): arg = arg.strip() plist += addnodes.desc_parameter(arg, arg) signode += plist return name def setup(app): from sphinx.ext.autodoc import cut_lines app.connect('autodoc-process-docstring', cut_lines(4, what=['module'])) app.add_description_unit('directive', 'dir', 'pair: %s; directive', parse_directive) app.add_description_unit('role', 'role', 'pair: %s; role', parse_role) app.add_description_unit('confval', 'confval', 'pair: %s; configuration value') app.add_description_unit('event', 'event', 'pair: %s; event', parse_event) pygraphviz-1.3.1/doc/source/templates/0000755000175000017500000000000012573042274017646 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/source/templates/index.html0000644000175000017500000000511212573042175021642 0ustar aricaric00000000000000{% extends "layout.html" %} {% set title = 'Overview' %} {% block body %}

PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms. PyGraphviz is independent from NetworkX but provides a similar programming interface.

Quick Example

>>> import pygraphviz as pgv
>>> G=pgv.AGraph()
>>> G.add_node('a')
>>> G.add_edge('b','c')
>>> G
strict graph {
        a;
        b -- c;
}

To load a dot file use

>>> G=pgv.AGraph("file.dot")

Documentation

Get PyGraphviz

Download PyGraphviz from the Python Package Index.

The code source code is available from the NetworkX SVN server at http://networkx.lanl.gov/svn/pygraphviz/trunk.

{% endblock %} pygraphviz-1.3.1/doc/source/templates/indexsidebar.html0000644000175000017500000000211112573042175023170 0ustar aricaric00000000000000

Download

{% if version.split('.')[-1].startswith('dev') %}

This documentation is for version {{ version }}, which is not released yet.

You can check it out from Subversion or look for released versions in the Python Package Index.

{% else %}

Current version: {{ version }}

Get NetworkX from the Python Package Index, or install it with:

easy_install pygraphviz
{% endif %}

Questions? Suggestions?

Join the Google group:

You can also open an issue at the on the developer's site.

pygraphviz-1.3.1/doc/source/templates/layout.html0000644000175000017500000000157112573042175022055 0ustar aricaric00000000000000{% extends "!layout.html" %} {% block rootrellink %}
  • PyGraphviz Home
  • Documentation
  • Download
  • Developer (Github)
  • {% endblock %} {% block relbar1 %}
    PyGraphviz
    {{ super() }} {% if version.split('.')[-1].startswith('dev') %}

    This documentation is for version {{ version }}, which is not released yet.

    {% endif %} {% endblock %} {# put the sidebar before the body #} {% block sidebar1 %}{{ sidebar() }}{% endblock %} {% block sidebar2 %}{% endblock %} pygraphviz-1.3.1/doc/source/reference/0000755000175000017500000000000012573042274017606 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/source/reference/faq.rst0000644000175000017500000000240612573042175021111 0ustar aricaric00000000000000FAQ --- :Q: I followed the installation instructions but when I do >>> import pygraphviz I get an error like ImportError: libagraph.so.1: cannot open shared object file: No such file or directory What is wrong? :A: Some Unix systems don't include the Graphviz library in the default search path for the run-time linker. The path is often something like /usr/lib/graphviz or /sw/lib/graphviz etc. and it needs to be added to your search path. You can 1. set the LD_LIBRARY_PATH environment variable e.g. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/graphviz 2. configure your system with the additional path. e.g. for Linux add a line to /etc/ld.so.conf and run ldconfig :Q: How do I compile pygraphviz under Windows? And why don't you distribute a pygraphviz Windows installer? :A: We don't have Windows development machines but would like to have pygraphviz work on all platforms. If you have success with Windows or would be willing to help test and distribute a Windows installer please drop us a note. See also tickets: https://networkx.lanl.gov/trac/ticket/117 https://networkx.lanl.gov/trac/ticket/491 pygraphviz-1.3.1/doc/source/reference/credits.rst0000644000175000017500000000133012573042175021772 0ustar aricaric00000000000000Credits ======= Thanks to Stephen North and the AT&T Graphviz team for creating and maintaining the Graphviz graph layout and drawing packages Thanks to Manos Renieris for the original idea. Thanks to the following people who have made contributions: - Cyril Brulebois helped clean up the packaging for Debian and find bugs. - Rene Hogendoorn developed the threads code to provide nonblocking, multiplatform IO. - Ross Richardson suggested fixes and tested the attribute handling. - Alexis Dinno debugged the setup and installation for OSX. - Stefano Costa reported attribute bugs and contributed the code to run Graphviz "tred" and friends. - Casey Deccio contributed unicode handling design and code. pygraphviz-1.3.1/doc/source/reference/news.rst0000644000175000017500000001160312573042175021315 0ustar aricaric00000000000000.. -*- coding: utf-8 -*- News ==== pygraphviz-1.3.1 ---------------- Release date: 6 September 2015 - Update manifest to include missing files pygraphviz-1.3 -------------- Release date: 5 September 2015 - Python 3 support - Encoding bugfixes https://github.com/pygraphviz/pygraphviz/issues?q=milestone%3Apygraphivz-1.3+is%3Aclosed pygraphviz-1.2 ----------------- Release date: 3 August 2013 - Quote Graphviz program names to work with space (Windows fix) - Keep name in reverse() pygraphviz-1.1 ----------------- Release date: 9 February 2011 - Added unicode support for handling non-ASCII characters - Better handling of user data on initialization of AGraph() object to guess input type (AGraph object, file, dict-of-dicts, file) - Add sfdp to layout options See https://networkx.lanl.gov/trac/query?group=status&milestone=pygraphviz-1.1 pygraphviz-1.0.0 ----------------- Release date: 30 July 2010 See: https://networkx.lanl.gov/trac/timeline - Added to_string() and from_string methods - Interface to graphviz "acyclic" and "tred" - Better handling of user data on initialization of AGraph() object to guess input type (AGraph object, file, dict-of-dicts, file) - Add handling of default attributes for subgraphs - Improved error handling when using non-string data - Fix bug in default attribute handling - Make sure file handles are closed correctly pygraphviz-0.99.1 ----------------- Release date: 7 December 2008 See: https://networkx.lanl.gov/trac/timeline - Use Graphviz libcgraph instead of deprecated libagraph - More closely match API to NetworkX - edges() now produces two-tuples or three tuples if edges(keys=True) - Edge and Node objects now have .name and .handle properties - Warn without throwing exceptions for Graphviz errors - Graph now has .strict and .directed properties - Cleared up fontsize warnings in examples pygraphviz-0.99 --------------- Release date: 18 November 2008 See: https://networkx.lanl.gov/trac/timeline - New documentation at http://networkx.lanl.gov/pygraphviz/ - Developer's site at https://networkx.lanl.gov/trac/wiki/PyGraphviz pygraphviz-0.37 --------------- Release date: 17 August 2008 See: https://networkx.lanl.gov/trac/timeline - Handle default attributes for subgraphs, examples at https://networkx.lanl.gov/trac/browser/pygraphviz/trunk/doc/examples/attributes.py https://networkx.lanl.gov/trac/browser/pygraphviz/trunk/doc/examples/subgraph.py - Buggy attribute assignment fixed by Graphviz team (use Graphviz>2.17.20080127) - Encode all stings as UTF-8 as default - Fix AGraph.clear() memory leak and attempt to address slow deletion of nodes and edges - Allow pdf output and support all available output types on a given platform - Fix number_of_edges() to use gv.agnedges to correctly report edges for graphs with self loops pygraphviz-0.36 --------------- Release date: 13 January 2008 See: https://networkx.lanl.gov/trac/timeline - Automatic handling of types on init of AGraph(data): data can be a filename, string in dot format, dictionary-of-dictionaries, or a SWIG AGraph pointer. - Add interface to Graphviz programs acyclic and tred - Refactor process handling to allow easier access to Graphviz layout and graph processing programs - to_string() and from_string() methods - Handle multiple anonymous edges correctly - Attribute handling on add_node, add_edge and init of AGraph. So you can e.g. A=AGraph(ranksep='0.1'); A.add_node('a',color='red') A.add_edge('a','b',color='blue') pygraphviz-0.35 --------------- Release date: 22 July 2007 See: https://networkx.lanl.gov/trac/timeline - Rebuilt SWIG wrappers - works correctly now on 64 bit machines/python2.5 - Implement Graphviz subgraph functionality - Better error reporting when attempting to set attributes, avoid segfault when using None - pkg-config handling now works in more configurations (hopefully all) pygraphviz-0.34 --------------- Release date: 11 April 2007 See: https://networkx.lanl.gov/trac/timeline - run "python setup_egg.py test" for tests if you have setuptools - added tests for layout code - use pkg-config for finding graphviz (dotneato-config still works for older graphviz versions) - use threads and temporary files for multiplatform nonblocking IO - django example pygraphviz-0.33 --------------- - Workaround for "nop" bug in graphviz-2.8, improved packaging, updated swig wrapper, better error handling. pygraphviz-0.32 --------------- The release pygraphviz-0.32 is the second rewrite of the original project. It has improved attribute handling and drawing capabilities. It is not backward compatible with earlier versions. Earlier versions will always be available at the download site. This version now inter-operates with many of the NetworkX algorithms and graph generators. See https://networkx.lanl.gov/trac/browser/networkx/trunk/doc/examples/pygraphviz_simple.py pygraphviz-1.3.1/doc/source/reference/index.rst0000644000175000017500000000024012573042175021443 0ustar aricaric00000000000000.. _reference: ********* Reference ********* .. toctree:: :maxdepth: 2 agraph faq api_notes news related history credits legal pygraphviz-1.3.1/doc/source/reference/related.rst0000644000175000017500000000043312573042175021760 0ustar aricaric00000000000000Related Pacakges ---------------- - Python bindings distributed with Graphviz (graphviz-python): http://www.graphviz.org/ - pydot: http://code.google.com/p/pydot/ - mfGraph: http://www.geocities.com/foetsch/mfgraph/index.htm - Yapgvb: http://yapgvb.sourceforge.net/ pygraphviz-1.3.1/doc/source/reference/legal.rst0000644000175000017500000000561312573042175021431 0ustar aricaric00000000000000Legal ===== PyGraphviz License ------------------ Copyright (C) 2004-2010 by Aric Hagberg Dan Schult Manos Renieris, http://www.cs.brown.edu/~er/ Distributed with BSD license. All rights reserved, see LICENSE for details. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Notice ------ This software and ancillary information (herein called SOFTWARE ) called pygraphviz is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC number 04-073. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from Los Alamos National Laboratory. pygraphviz-1.3.1/doc/source/reference/api_notes.rst0000644000175000017500000000456012573042175022326 0ustar aricaric00000000000000API Notes ========= pygraphviz-1.2 -------------- No API changes pygraphviz-1.1 -------------- Pygraphviz-1.1 adds unicode (graphviz charset) support. The default Node type is now unicode. See examples/utf8.py for an example of how to use non-ASCII characters. The __str__ and __repr__ methods have been rewritten and a __unicode__ method added. If G is a pygraphviz.AGraph object then - str(G) produces a dot-format string representation (some characters might not be represented correctly) - unicode(G) produces a dot-format unicode representation - repr(G) produces a string of the unicode representation. - print G produces a formatted dot language output pygraphivz-0.32 --------------- pygraphviz-0.32 is a rewrite of pygraphviz-0.2x with some significant changes in the API and Graphviz wrapper. It is not compatible with with earlier versions. The goal of pygraphviz is to provide a (mostly) Pythonic interface to the Graphviz Agraph data-structure, layout, and drawing algorithms. The API is now similar to the NetworkX API. Studying the documentation and Tutorial for NetworkX will teach you most of what you need to know for pygraphviz. For a short introduction on pygraphviz see the pygraphviz Tutorial. There are some important differences between the PyGraphviz and NetworkX API. With PyGraphviz - All nodes must be of string or unicode type. An attempt will be made to convert other types to a string. - Nodes and edges are custom Python objects. Nodes are like unicode/string objects and edges are like tuple objects. (In NetworkX nodes can be anything and edges are two- or three-tuples.) - Graphs, edges, and nodes may have attributes such as color, size, shape, attached to them. If the attributes are known Graphviz attributes they will be used for drawing and layout. - The layout() and draw() methods allow positioning of nodes and rendering in all of the supported Graphviz output formats. - The string() method produces a string with the graph represented in Graphviz dot format. See also from_string(). - The subgraph() method is the Graphviz representation of subgraphs: a tree of graphs under the original (root) graph. The are primarily used for clustering of nodes when drawing with dot. Pygraphviz supports most of the Graphviz API. pygraphviz-1.3.1/doc/source/reference/history.rst0000644000175000017500000000023312573042175022037 0ustar aricaric00000000000000History ------- The original concept was developed and implemented by Manos Renieris at Brown University: http://www.cs.brown.edu/~er/software/ pygraphviz-1.3.1/doc/source/reference/agraph.rst0000644000175000017500000000021212573042175021575 0ustar aricaric00000000000000.. _agraph: ************ AGraph Class ************ .. currentmodule:: pygraphviz .. autoclass:: AGraph :members: :undoc-members: pygraphviz-1.3.1/doc/source/index.rst0000644000175000017500000000076612573042175017522 0ustar aricaric00000000000000.. _contents: ************************ PyGraphviz documentation ************************ .. only:: html :Release: |version| :Date: |today| Download `PDF `_ `HTML `_ .. toctree:: :maxdepth: 2 download install tutorial reference/index examples Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` pygraphviz-1.3.1/doc/source/install.rst0000777000175000017500000000000012573042175022342 2../../INSTALL.txtustar aricaric00000000000000pygraphviz-1.3.1/doc/source/examples.rst0000644000175000017500000000125712573042175020225 0ustar aricaric00000000000000Examples ======== See the examples for sample usage and ideas http://github.com/pygraphviz/pygraphviz/tree/master/examples There is a complete reference guide at http://pygraphviz.github.io/documentation/latest Simple ~~~~~~ A basic example showing how to read and write dot files and draw graphs. http://github.com/pygraphviz/pygraphviz/tree/master/examples/simple.py Star ~~~~ An example showing how to set attributes. http://github.com/pygraphviz/pygraphviz/tree/master/examples/star.py Miles ~~~~~ An example showing how to use Graphviz to draw a graph with given positions. http://github.com/pygraphviz/pygraphviz/tree/master/examples/miles.py pygraphviz-1.3.1/doc/source/static/0000755000175000017500000000000012573042274017137 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/source/static/sphinxdoc.css0000644000175000017500000001330712573042175021654 0ustar aricaric00000000000000/* * sphinxdoc.css_t * ~~~~~~~~~~~~~~~ * * Sphinx stylesheet -- sphinxdoc theme. Originally created by * Armin Ronacher for Werkzeug. * * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @import url("basic.css"); /* -- page layout ----------------------------------------------------------- */ body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif; font-size: 14px; letter-spacing: -0.01em; line-height: 150%; text-align: center; background-color: #BFD1D4; color: black; padding: 0; border: 1px solid #aaa; margin: 0px 80px 0px 80px; min-width: 740px; } div.document { background-color: white; text-align: left; background-image: url(contents.png); background-repeat: repeat-x; } div.bodywrapper { margin: 0 240px 0 0; border-right: 1px solid #ccc; } div.body { margin: 0; padding: 0.5em 20px 20px 20px; } div.related { font-size: 1em; } div.related ul { background-image: url(navigation.png); height: 2em; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; } div.related ul li { margin: 0; padding: 0; height: 2em; float: left; } div.related ul li.right { float: right; margin-right: 5px; } div.related ul li a { margin: 0; padding: 0 5px 0 5px; line-height: 1.75em; color: #EE9816; } div.related ul li a:hover { color: #3CA8E7; } div.sphinxsidebarwrapper { padding: 0; } div.sphinxsidebar { margin: 0; padding: 0.5em 15px 15px 0; width: 210px; float: right; font-size: 1em; text-align: left; } div.sphinxsidebar h3, div.sphinxsidebar h4 { margin: 1em 0 0.5em 0; font-size: 1em; padding: 0.1em 0 0.1em 0.5em; color: white; border: 1px solid #86989B; background-color: #AFC1C4; } div.sphinxsidebar h3 a { color: white; } div.sphinxsidebar ul { padding-left: 1.5em; margin-top: 7px; padding: 0; line-height: 130%; } div.sphinxsidebar ul ul { margin-left: 20px; } div.footer { background-color: #E3EFF1; color: #86989B; padding: 3px 8px 3px 0; clear: both; font-size: 0.8em; text-align: right; } div.footer a { color: #86989B; text-decoration: underline; } /* -- body styles ----------------------------------------------------------- */ p { margin: 0.8em 0 0.5em 0; } a { color: #CA7900; text-decoration: none; } a:hover { color: #2491CF; } div.body a { text-decoration: underline; } h1 { margin: 0; padding: 0.7em 0 0.3em 0; font-size: 1.5em; color: #11557C; } h2 { margin: 1.3em 0 0.2em 0; font-size: 1.35em; padding: 0; } h3 { margin: 1em 0 -0.3em 0; font-size: 1.2em; } div.body h1 a, div.body h2 a, div.body h3 a, div.body h4 a, div.body h5 a, div.body h6 a { color: black!important; } h1 a.anchor, h2 a.anchor, h3 a.anchor, h4 a.anchor, h5 a.anchor, h6 a.anchor { display: none; margin: 0 0 0 0.3em; padding: 0 0.2em 0 0.2em; color: #aaa!important; } h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { display: inline; } h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover, h5 a.anchor:hover, h6 a.anchor:hover { color: #777; background-color: #eee; } a.headerlink { color: #c60f0f!important; font-size: 1em; margin-left: 6px; padding: 0 4px 0 4px; text-decoration: none!important; } a.headerlink:hover { background-color: #ccc; color: white!important; } cite, code, tt { font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.95em; letter-spacing: 0.01em; } tt { background-color: #f2f2f2; border-bottom: 1px solid #ddd; color: #333; } tt.descname, tt.descclassname, tt.xref { border: 0; } hr { border: 1px solid #abc; margin: 2em; } a tt { border: 0; color: #CA7900; } a tt:hover { color: #2491CF; } pre { font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.95em; letter-spacing: 0.015em; line-height: 120%; padding: 0.5em; border: 1px solid #ccc; background-color: #f8f8f8; } pre a { color: inherit; text-decoration: underline; } td.linenos pre { padding: 0.5em 0; } div.quotebar { background-color: #f8f8f8; max-width: 250px; float: right; padding: 2px 7px; border: 1px solid #ccc; } div.topic { background-color: #f8f8f8; } table { border-collapse: collapse; margin: 0 -0.5em 0 -0.5em; } table td, table th { padding: 0.2em 0.5em 0.2em 0.5em; } div.admonition, div.warning { font-size: 0.9em; margin: 1em 0 1em 0; border: 1px solid #86989B; background-color: #f7f7f7; padding: 0; } div.admonition p, div.warning p { margin: 0.5em 1em 0.5em 1em; padding: 0; } div.admonition pre, div.warning pre { margin: 0.4em 1em 0.4em 1em; } div.admonition p.admonition-title, div.warning p.admonition-title { margin: 0; padding: 0.1em 0 0.1em 0.5em; color: white; border-bottom: 1px solid #86989B; font-weight: bold; background-color: #AFC1C4; } div.warning { border: 1px solid #940000; } div.warning p.admonition-title { background-color: #CF0000; border-bottom-color: #940000; } div.admonition ul, div.admonition ol, div.warning ul, div.warning ol { margin: 0.1em 0.5em 0.5em 3em; padding: 0; } div.versioninfo { margin: 1em 0 0 0; border: 1px solid #ccc; background-color: #DDEAF0; padding: 8px; line-height: 1.3em; font-size: 0.9em; } pygraphviz-1.3.1/doc/source/static/navigation.png0000644000175000017500000000033212573042175022002 0ustar aricaric00000000000000PNG  IHDR<sRGB pHYs  tIME y݉tEXtCommentCreated with GIMPWGIDATӽ0 OBt~8qg*m, 0{,Bt6o.q\Y~t7"LIENDB`pygraphviz-1.3.1/doc/source/static/contents.png0000644000175000017500000000031212573042175021476 0ustar aricaric00000000000000PNG  IHDR(?wsRGB pHYs  tIME 7C{tEXtCommentCreated with GIMPW7IDATץ9 Z^']x.$@Z[!8EȞ-oÝo\KIENDB`pygraphviz-1.3.1/doc/source/static/empty.txt0000644000175000017500000000000012573042175021024 0ustar aricaric00000000000000pygraphviz-1.3.1/doc/sphinxext/0000755000175000017500000000000012573042274016402 5ustar aricaric00000000000000pygraphviz-1.3.1/doc/sphinxext/only_directives.py0000644000175000017500000000534212573042175022162 0ustar aricaric00000000000000# # A pair of directives for inserting content that will only appear in # either html or latex. # from docutils.nodes import Body, Element from docutils.writers.html4css1 import HTMLTranslator from sphinx.latexwriter import LaTeXTranslator from docutils.parsers.rst import directives class html_only(Body, Element): pass class latex_only(Body, Element): pass def run(content, node_class, state, content_offset): text = '\n'.join(content) node = node_class(text) state.nested_parse(content, content_offset, node) return [node] try: from docutils.parsers.rst import Directive except ImportError: from docutils.parsers.rst.directives import _directives def html_only_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): return run(content, html_only, state, content_offset) def latex_only_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): return run(content, latex_only, state, content_offset) for func in (html_only_directive, latex_only_directive): func.content = 1 func.options = {} func.arguments = None _directives['htmlonly'] = html_only_directive _directives['latexonly'] = latex_only_directive else: class OnlyDirective(Directive): has_content = True required_arguments = 0 optional_arguments = 0 final_argument_whitespace = True option_spec = {} def run(self): self.assert_has_content() return run(self.content, self.node_class, self.state, self.content_offset) class HtmlOnlyDirective(OnlyDirective): node_class = html_only class LatexOnlyDirective(OnlyDirective): node_class = latex_only directives.register_directive('htmlonly', HtmlOnlyDirective) directives.register_directive('latexonly', LatexOnlyDirective) def setup(app): app.add_node(html_only) app.add_node(latex_only) # Add visit/depart methods to HTML-Translator: def visit_perform(self, node): pass def depart_perform(self, node): pass def visit_ignore(self, node): node.children = [] def depart_ignore(self, node): node.children = [] HTMLTranslator.visit_html_only = visit_perform HTMLTranslator.depart_html_only = depart_perform HTMLTranslator.visit_latex_only = visit_ignore HTMLTranslator.depart_latex_only = depart_ignore LaTeXTranslator.visit_html_only = visit_ignore LaTeXTranslator.depart_html_only = depart_ignore LaTeXTranslator.visit_latex_only = visit_perform LaTeXTranslator.depart_latex_only = depart_perform pygraphviz-1.3.1/doc/gh-pages.py0000755000175000017500000001034412573042175016422 0ustar aricaric00000000000000#!/usr/bin/env python """Script to commit the doc build outputs into the github-pages repo. Use: gh-pages.py [tag] If no tag is given, the current output of 'git describe' is used. If given, that is how the resulting directory will be named. In practice, you should use either actual clean tags from a current build or something like 'current' as a stable URL for the most current version""" # Borrowed from IPython. #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- import os import re import shutil import sys from os import chdir as cd from os.path import join as pjoin from subprocess import Popen, PIPE, CalledProcessError, check_call #----------------------------------------------------------------------------- # Globals #----------------------------------------------------------------------------- pages_dir = 'gh-pages' html_dir = 'build/dist' pdf_dir = 'build/latex' pages_repo = 'git@github.com:pygraphviz/documentation.git' #----------------------------------------------------------------------------- # Functions #----------------------------------------------------------------------------- def sh(cmd): """Execute command in a subshell, return status code.""" return check_call(cmd, shell=True) def sh2(cmd): """Execute command in a subshell, return stdout. Stderr is unbuffered from the subshell.x""" p = Popen(cmd, stdout=PIPE, shell=True) out = p.communicate()[0] retcode = p.returncode if retcode: raise CalledProcessError(retcode, cmd) else: return out.rstrip() def sh3(cmd): """Execute command in a subshell, return stdout, stderr If anything appears in stderr, print it out to sys.stderr""" p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True) out, err = p.communicate() retcode = p.returncode if retcode: raise CalledProcessError(retcode, cmd) else: return out.rstrip(), err.rstrip() def init_repo(path): """clone the gh-pages repo if we haven't already.""" sh("git clone %s %s"%(pages_repo, path)) here = os.getcwdu() cd(path) sh('git checkout gh-pages') cd(here) #----------------------------------------------------------------------------- # Script starts #----------------------------------------------------------------------------- if __name__ == '__main__': # The tag can be given as a positional argument try: tag = sys.argv[1] except IndexError: try: tag = sh2('git describe --exact-match') except CalledProcessError: print("using development as label") tag = "development" # Fallback startdir = os.getcwdu() if not os.path.exists(pages_dir): # init the repo init_repo(pages_dir) else: # ensure up-to-date before operating cd(pages_dir) sh('git checkout gh-pages') sh('git pull') cd(startdir) dest = pjoin(pages_dir, tag) # don't `make html` here, because gh-pages already depends on html in Makefile # sh('make html') if tag != 'dev': # only build pdf for non-dev targets #sh2('make pdf') pass # This is pretty unforgiving: we unconditionally nuke the destination # directory, and then copy the html tree in there shutil.rmtree(dest, ignore_errors=True) shutil.copytree(html_dir, dest) if tag != 'dev': #shutil.copy(pjoin(pdf_dir, 'ipython.pdf'), pjoin(dest, 'ipython.pdf')) pass try: cd(pages_dir) status = sh2('git status | head -1') branch = re.match('On branch (.*)$', status).group(1) if branch != 'gh-pages': e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir, branch) raise RuntimeError(e) sh('git add -A %s' % tag) sh('git commit -m"Updated doc release: %s"' % tag) print print 'Most recent 3 commits:' sys.stdout.flush() sh('git --no-pager log --oneline HEAD~3..') finally: cd(startdir) print print 'Now verify the build in: %r' % dest print "If everything looks good, 'git push'" pygraphviz-1.3.1/doc/Makefile0000644000175000017500000001036312573042175016013 0ustar aricaric00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest epub help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " epub to make an epub" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf build/* source/reference/generated/* source/examples/* source/static/examples doc/source/*.pdf doc/source/*.zip -rm -rf ../examples/*/*.png generate: build/generate-stamp build/generate-stamp: $(wildcard source/reference/*.rst) mkdir -p build touch build/generate-stamp dist: html test -d build/latex || make latex make -C build/latex all-pdf -rm -rf build/dist (cd build/html; cp -r . ../../build/dist) # -rm -f build/dist/_downloads/* # -mkdir build/dist/_downloads # (cd build/html && zip -9r ../dist/_downloads/pygraphviz-documentation.zip .) (cd build/html && zip -9r ../dist/pygraphviz-documentation.zip .) # cp build/latex/*.pdf build/dist/_downloads cp build/latex/*.pdf build/dist/ # (cd build/dist && ln -s _downloads/* .) # (cd build/dist && tar czf ../dist.tar.gz .) html: generate touch source/pygraphviz.pdf touch source/pygraphviz-documentation.zip $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." dirhtml: generate $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) build/dirhtml @echo @echo "Build finished. The HTML pages are in build/dirhtml." pickle: generate $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files." json: generate $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: generate $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." qthelp: generate $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in build/qthelp, like this:" @echo "# qcollectiongenerator build/qthelp/test.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile build/qthelp/test.qhc" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) build/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: generate $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: generate $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." doctest: generate $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) build/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in build/doctest/output.txt." gh-pages: clean dist python gh-pages.py $(tag) gitwash-update: python gitwash_dumper.py source/developer pygraphviz \ --project-url=http://pygraphviz.github.io \ --project-ml-url=http://groups.google.com/group/pygraphviz-discuss/ pygraphviz-1.3.1/INSTALL.txt0000644000175000017500000000644212573042175015460 0ustar aricaric00000000000000********** Installing ********** Quick Install ============= Get PyGraphviz from the Python Package Index at http://pypi.python.org/pypi/pygraphviz or install it with:: pip install pygraphviz and an attempt will be made to find and install an appropriate version that matches your operating system and Python version. You can install the development version (at github.com) with:: pip install git://github.com/pygraphviz/pygraphviz.git#egg=pygraphviz Get PyGraphviz from the Python Package Index at http://pypi.python.org/pypi/pygraphviz or install it with:: easy_install pygraphviz and an attempt will be made to find and install an appropriate version that matches your operating system and Python version. Providing path to graphviz -------------------------- We tried our best to discover graphviz location automatically, but if you would like specify specific location for graphviz you may provide additrional parameters to specify graphviz location include-path= path to graphviz include files library-path= path to graphviz library files For example :: python setup.py install --include-path=/usr/local/Cellar/graphviz/2.38.0/include/graphviz --library-path=/usr/local/Cellar/graphviz/2.38.0/lib Installing from Source ====================== You can install from source by downloading a source archive file (tar.gz or zip) or by checking out the source files from the Subversion repository. Source Archive File ------------------- 1. Download the source (tar.gz or zip file). 2. Unpack and change directory to pygraphviz-"version" 3. Run "python setup.py install" to build and install 4. (optional) Run "python setup_egg.py nosetests" to execute the tests Github ------ 1. Clone the pygraphviz repository git clone https://github.com/pygraphviz/pygraphviz.git (see https://github.com/pygraphviz/pygraphviz/ for other options) 2. Change directory to "pygraphviz" 3. Run "python setup.py install" to build and install 4. (optional) Run "python setup_egg.py nosetests" to execute the tests If you don't have permission to install software on your system, you can install into another directory using the --user, --prefix, or --home flags to setup.py. For example :: python setup.py install --prefix=/home/username/python or python setup.py install --home=~ or python setup.py install --user If you didn't install in the standard Python site-packages directory you will need to set your PYTHONPATH variable to the alternate location. Seehttp://docs.python.org/2/install/index.html#search-path for further details. Requirements ============ Python ------ PyGraphviz is tested and works with Python 2.7 and Python 3.4. It may work correctly with other Python 3.x versions. The easiest way to get Python and most optional packages is to install the Enthought Python distribution "Canopy" https://www.enthought.com/products/canopy/ There are several other distributions that contain the key packages you need for scientific computing. See the following link for a list: http://scipy.org/install.html Requirements ============ GraphViz -------- To use PyGraphviz you need GraphViz version 2.16 or later. Some versions have known bugs that have been fixed; get the latest release available for best results. - Official site: http://www.graphviz.org pygraphviz-1.3.1/setup_extra.py0000644000175000017500000001243312573042175016523 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Setup helpers for PyGraphviz. """ # Copyright (C) 2006-2010 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import print_function from __future__ import absolute_import import subprocess as S import sys def _b2str(buffer): result = u'' if sys.version_info >= (3, 0): encoding = sys.getfilesystemencoding() if not encoding: # can be run without stdout if sys.stdout and sys.stdout.encoding: # encoding is nont None only staring Python 3.2 encoding = sys.stdout.encoding else: # fall back to default encoding ( normally it should not happen) encoding = 'utf8' if buffer: result = buffer.decode(encoding) return result else: return buffer def _pkg_config(): # attempt to find graphviz installation with pkg-config # should work with modern versions of graphviz library_path=None include_path=None try: output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph']) output = _b2str(output) if output: library_path=output.strip()[2:] output = S.check_output(['pkg-config', '--cflags-only-I', 'libcgraph']) output = _b2str(output) if output: include_path=output.strip()[2:] except OSError: print("Failed to find pkg-config") return include_path, library_path def _dotneato_config(): # find graphviz configuration with dotneato-config # works with older versions of graphviz # attempt to find graphviz installation with pkg-config # should work with modern versions of graphviz library_path=None include_path=None try: output = S.check_output(['dotneato-config', '--ldflags', '--cflags']) output = _b2str(output) if output: include_path, library_path = output.split() library_path = library_path.strip()[2:] include_path = include_path.strip()[2:] except OSError: print("Failed to find dotneato-config") # fall through and test the other syntax if not include_path and not library_path: try: output = S.check_output(['dotneato-config', '--libs', '--cflags']) output = _b2str(output) if output: include_path, library_path = output.split('\n',1) library_path = library_path.strip()[2:] include_path = include_path.strip()[2:] except OSError: print("Failed to find dotneato-config") return include_path, library_path def get_graphviz_dirs(): """ First try to read include_dirs from :return: tuple of lists ([include_dirs], [library_dirs], [define_macros]) """ # If the setup script couldn't find your graphviz installation you can # specify it here by uncommenting these lines or providing your own: # You must set both 'library_dirs' and 'include_dirs' # Linux, generic UNIX #library_dirs='/usr/lib/graphviz' #include_dirs='/usr/include/graphviz' # OSX, Linux, alternate location #library_dirs='/usr/local/lib/graphviz' #include_dirs='/usr/local/include/graphviz' # OSX (Fink) #library_dirs='/sw/lib/graphviz' #include_dirs='/sw/include/graphviz' # OSX (MacPorts) #library_dirs='/opt/local/lib/graphviz' #include_dirs='/opt/local/include/graphviz' # Windows # Unknown - use command line -I and -L switches to set include_dirs = None library_dirs = None if sys.platform != "win32": # Attempt to find Graphviz installation if library_dirs is None and include_dirs is None: print("Trying pkg-config") include_dirs, library_dirs = _pkg_config() if library_dirs is None and include_dirs is None: print("Trying dotneato-config") include_dirs, library_dirs = _dotneato_config() if library_dirs is None or include_dirs is None: print() print("""Your Graphviz installation could not be found. 1) You don't have Graphviz installed: Install Graphviz (http://graphviz.org) 2) Your Graphviz package might incomplete. Install the binary development subpackage (e.g. libgraphviz-dev or similar.) 3) You are using Windows There are no PyGraphviz binary packages for Windows but you might be able to build it from this source. See http://networkx.lanl.gov/pygraphviz/reference/faq.html If you think your installation is correct you will need to manually change the include_dirs and library_dirs variables in setup.py to point to the correct locations of your graphviz installation. The current setting of library_dirs and include_dirs is:""") print("library_dirs=%s"%library_dirs) print("include_dirs=%s"%include_dirs) print() raise OSError("Error locating graphviz.") print("include_dirs=%s" % include_dirs) print("library_dirs=%s" % library_dirs) return include_dirs, library_dirs pygraphviz-1.3.1/setup.py0000644000175000017500000000516012573042175015317 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Setup script for PyGraphviz """ from __future__ import absolute_import from __future__ import print_function from __future__ import division from glob import glob import os from setuptools import setup, Extension import sys from setup_commands import AddExtensionDevelopCommand, AddExtensionInstallCommand from setup_extra import get_graphviz_dirs if os.path.exists('MANIFEST'): os.remove('MANIFEST') if sys.argv[-1] == 'setup.py': print("To install, run 'python setup.py install'") print() if sys.version_info[:2] < (2, 6): print("PyGraphviz requires Python version 2.6 or later (%d.%d detected)." % sys.version_info[:2]) sys.exit(-1) # Write the version information. #TODO rework this import hack with import graphviz.release or import graphviz.version ( doesn't work now because of code in the __init__) sys.path.insert(0, 'pygraphviz') import release release.write_versionfile() sys.path.pop(0) packages = ["pygraphviz", "pygraphviz.tests"] docdirbase = 'share/doc/pygraphviz-%s' % release.version data = [ (docdirbase, glob("*.txt")), (os.path.join(docdirbase, 'examples'), glob("examples/*.py")), (os.path.join(docdirbase, 'examples'), glob("examples/*.dat")), (os.path.join(docdirbase, 'examples'), glob("examples/*.dat.gz")), ] package_data = {'': ['*.txt'], } if __name__ == "__main__": define_macros = [] if sys.platform == "win32": define_macros = define_macros.append(('GVDLL', None)) extension = [ Extension( "pygraphviz._graphviz", ["pygraphviz/graphviz_wrap.c"], include_dirs=[], library_dirs=[], libraries=["cgraph", "cdt"], define_macros=define_macros ) ] setup( name=release.name, version=release.version, author=release.authors['Hagberg'][0], author_email=release.authors['Hagberg'][1], description=release.description, keywords=release.keywords, long_description=release.long_description, license=release.license, platforms=release.platforms, url=release.url, download_url=release.download_url, classifiers=release.classifiers, packages=packages, data_files=data, ext_modules=extension, cmdclass={ 'install': AddExtensionInstallCommand, 'develop': AddExtensionDevelopCommand, }, package_data=package_data, include_package_data = True, test_suite='nose.collector', tests_require=['nose>=0.10.1', 'doctest-ignore-unicode>=0.1.0',], ) pygraphviz-1.3.1/pystrings.swg0000644000175000017500000000441612573042175016374 0ustar aricaric00000000000000/* Fixed fragments for work with bytes in Python 3. */ %fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { %#if PY_VERSION_HEX>=0x03000000 if (PyBytes_Check(obj)) %#else if (PyString_Check(obj)) %#endif { char *cstr; Py_ssize_t len; %#if PY_VERSION_HEX>=0x03000000 PyBytes_AsStringAndSize(obj, &cstr, &len); if(alloc) *alloc = SWIG_NEWOBJ; %#else PyString_AsStringAndSize(obj, &cstr, &len); %#endif if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner string representation. To warranty that, if you define SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string buffer is always returned. The default behavior is just to return the pointer value, so, be careful. */ %#if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) %#else if (*alloc == SWIG_NEWOBJ) %#endif { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { if (cptr) *cptr = (char *) vptr; if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; if (alloc) *alloc = SWIG_OLDOBJ; return SWIG_OK; } } } return SWIG_TypeError; } } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); } else { %#if PY_VERSION_HEX >= 0x03000000 return PyBytes_FromStringAndSize(carray, %numeric_cast(size,int)); %#else return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); %#endif } } else { return SWIG_Py_Void(); } } } pygraphviz-1.3.1/examples/0000755000175000017500000000000012573042274015421 5ustar aricaric00000000000000pygraphviz-1.3.1/examples/simple.py0000644000175000017500000000163212573042175017266 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ A simple example to create a graphviz dot file and draw a graph. """ # Copyright (C) 2006 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division __author__ = """Aric Hagberg (hagberg@lanl.gov)""" import pygraphviz as pgv A=pgv.AGraph() A.add_edge(1,2) A.add_edge(2,3) A.add_edge(1,3) print(A.string()) # print to screen print("Wrote simple.dot") A.write('simple.dot') # write to simple.dot B=pgv.AGraph('simple.dot') # create a new graph from file B.layout() # layout with default (neato) B.draw('simple.png') # draw png print("Wrote simple.png") pygraphviz-1.3.1/examples/subgraph.py0000644000175000017500000000077412573042175017616 0ustar aricaric00000000000000#!/usr/bin/env python from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division import pygraphviz as pgv A=pgv.AGraph() # add some edges A.add_edge(1,2) A.add_edge(2,3) A.add_edge(1,3) A.add_edge(3,4) A.add_edge(3,5) A.add_edge(3,6) A.add_edge(4,6) # make a subgraph with rank='same' B=A.add_subgraph([4,5,6],name='s1',rank='same') B.graph_attr['rank']='same' print(A.string()) # print dot file to standard output pygraphviz-1.3.1/examples/miles.py0000644000175000017500000000602312573042175017105 0ustar aricaric00000000000000#!/usr/bin/env python """ An example that shows how to add your own positions to nodes and have graphviz "neato" position the edges. miles_graph() returns an undirected graph over the 128 US cities from the datafile miles_dat.txt. This example is described in Section 1.1 in Knuth's book [1][2]. The data used in this example is copied from [2]. The filename and header have been modified to adhere to the request of the author to not corrupt the original source file content and name. References. ----------- [1] Donald E. Knuth, "The Stanford GraphBase: A Platform for Combinatorial Computing", ACM Press, New York, 1993. [2] http://www-cs-faculty.stanford.edu/~knuth/sgb.html """ from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division import fileinput __author__ = """Aric Hagberg (aric.hagberg@gmail.com)""" def miles_graph(): """Return a graph from the data in miles_dat.txt. Edges are made between cities that are less then 300 miles apart. """ import math import re import gzip G=pgv.AGraph(name='miles_dat') G.node_attr['shape']='circle' G.node_attr['fixedsize']='true' G.node_attr['fontsize']='8' G.node_attr['style']='filled' G.graph_attr['outputorder']='edgesfirst' G.graph_attr['label']="miles_dat" G.graph_attr['ratio']='1.0' G.edge_attr['color']='#1100FF' G.edge_attr['style']='setlinewidth(2)' cities=[] for line in gzip.open("miles_dat.txt.gz",'rt'): if line.startswith("*"): # skip comments continue numfind=re.compile("^\d+") if numfind.match(line): # this line is distances dist=line.split() for d in dist: if float(d) < 300: # connect if closer then 300 miles G.add_edge(city,cities[i]) i=i+1 else: # this line is a city, position, population i=1 (city,coordpop)=line.split("[") cities.insert(0,city) (coord,pop)=coordpop.split("]") (y,x)=coord.split(",") G.add_node(city) n=G.get_node(city) # assign positions, scale to be something reasonable in points n.attr['pos']="%f,%f)"%(-(float(x)-7000)/10.0,(float(y)-2000)/10.0) # assign node size, in sqrt of 1,000,000's of people d=math.sqrt(float(pop)/1000000.0) n.attr['height']="%s"%(d/2) n.attr['width']="%s"%(d/2) # assign node color n.attr['fillcolor']="#0000%2x"%(int(d*256)) # empty labels n.attr['label']=' ' return G if __name__ == '__main__': import warnings import pygraphviz as pgv # ignore Graphviz warning messages warnings.simplefilter('ignore', RuntimeWarning) G=miles_graph() print("Loaded miles_dat.txt containing 128 cities.") G.write("miles.dot") print("Wrote miles.dot") G.draw("miles.png",prog='neato',args='-n2') print("Wrote miles.png") pygraphviz-1.3.1/examples/utf8_encoding.py0000644000175000017500000000167212573042175020535 0ustar aricaric00000000000000# -*- coding: utf-8 -*- """ Example showing use of unicode and UTF-8 encoding. """ from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division import pygraphviz as pgv # specify UTF-8 encoding (it is the default) A=pgv.AGraph(encoding='UTF-8') # nodes, attributes, etc can be strings or unicode A.add_node(1,label='plain string') A.add_node(2,label='unicode') # you can enter unicode text as hello='Здравствуйте!' A.add_node(3,label=hello) # or using unicode code points hello='\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435!' A.add_node(hello) # unicode node label goodbye="До свидания" A.add_edge(1,hello,key=goodbye) A.add_edge("שלום",hello) #A.add_edge(1,3,hello="こんにちは / コンニチハ") A.add_edge(1,"こんにちは") print(A) # print to screen A.write('utf8.dot') # write to simple.dot pygraphviz-1.3.1/examples/django_simple.py0000644000175000017500000000255012573042175020610 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Simple example for rendering a graph with the Django web framework. See http://www.djangoproject.com/ and http://www.djangobook.com/en/beta/chapter11/ """ # Copyright (C) 2007 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division __author__ = """Aric Hagberg (hagberg@lanl.gov)""" try: from django.http import HttpResponse except ImportError: # this won't run without Django, print message print("Django not found.") def pygraphviz_graph(request): import pygraphviz as P A=P.AGraph() # init empty graph # set some default node attributes A.node_attr['style']='filled' A.node_attr['shape']='circle' # Add edges (and nodes) A.add_edge(1,2) A.add_edge(2,3) A.add_edge(1,3) A.layout() # layout with default (neato) png=A.draw(format='png') # draw png return HttpResponse(png, mimetype='image/png') if __name__ == '__main__': print("""This code works with the Django web framework and should run as a django "view". See djangoproject.com for info. """) pygraphviz-1.3.1/examples/attributes.py0000644000175000017500000000133412573042175020162 0ustar aricaric00000000000000#!/usr/bin/env python from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division import pygraphviz as pgv # strict (no parallel edges) # digraph # with attribute rankdir set to 'LR' A=pgv.AGraph(directed=True,strict=True,rankdir='LR') # add node 1 with color red A.add_node(1,color='red') A.add_node(5,color='blue') # add some edges A.add_edge(1,2,color='green') A.add_edge(2,3) A.add_edge(1,3) A.add_edge(3,4) A.add_edge(3,5) A.add_edge(3,6) A.add_edge(4,6) # adjust a graph parameter A.graph_attr['epsilon']='0.001' print(A.string()) # print dot file to standard output A.layout('dot') # layout with dot A.draw('foo.ps') # write to file pygraphviz-1.3.1/examples/miles_dat.txt.gz0000644000175000017500000004741412573042175020554 0ustar aricaric00000000000000DIFmێdqy"FW{ 9rup" lF UɮDWg6*H{ӟ?=,|ۇۇǧwϯOc?O+?OŇ<_޾<O/^g?sq??>>E}=wy{>˻|~}zyΛsӧǏ=}|x3dR${__?>_^)K\v]><}o_/O^:ŚUكnϷ6aѾOW)!E>~pWߴW*/K=z)6Ɠxnްض-r#nڥlq5}|?6x8{9uK%ksV.RX?=[sxQ[_Z| Xbm◗z{<˾J'8s빖XnZ+[Wpbں_}Pv$-$ "c+gV]z_z,O/y?|z{6vxs]mk]|\^#Vb%K,(ŵ//oy^k e_7ovWxm.}~e=˥-Sh_ߴXѷq[C,sCv3|ņPָkKOopylÕu Yڃ*^m^9 0.ȶgY纔zzby5^x#~y-Tb~ 5S巷_~x{g{h!6>wEM`AFHf1.{k<~m(=+7|&= ĊB[Fh@V! W ePgBl emqN:}Ԑ8@ΐfVxO#tV:Y3{w^^CGXap 446/^/X7laN040~(lqR\!![~~}N빅adnft#G=/!gHe@w'm^yz$8@5>Cb=~{ U/ηml5zW5U+0p?k=v%A W Bz,j({;8q0pT|r-acWʴ6_,c*aHײMDyN5+lK|SʥF`5z0!wq1އϢ-S\{7?c*qs3,VC0F.[ 3ROO%vOBe$\;5V|ոac5u;ZB.f]G(ہfn|?cCqkxaC8Jْ~\Kq\[h 5۹]kl|~]wsW qO\B}f[nr窋){xj}{5$#C|5Ȅ}]RO7EG|Ԭ"ne0b޽FBcXP2%猭QweBZuxWb?,L= ߱ : i,x<]]׎9X_c_:$c5Цχg[N/DBڱrZ'`{$q[bC:;>]B$0WE?>{{ts!CJ,Zz ĸ|"C䧒AjOm b+॰3Ogxl@ q|h.9װ*DY4<e!n*[<7vfhR5 }u,#d @?fбWDXC9x0P؂CoF+zW:`\Amt?*ǰ?^7ԈCNm8X Jn`!AF6ÈEHBġ?|qg+$Mì$bO1֏k>̶(=_^É)dĞP؜x;/Qj!-CgṾ L*aAsDT3D+BbS*9PFG:x~. XPCޞf QJ?S= A,80aK2ɗ+ _e:IGӹ%KxkrnldsHB.sh&(īO/ 832kkY-s? Xkcߴͤjx'Dj3/"Hlm=LfApt$FB1^m `ߙ jWUX~G 9Fibg†p;;.iuƛ\HÖ;t A32L3SMBW~Z>3&oO\8 ?5 P+H vRV!:f2X9lwCێ-u@;B>ǸUڵi&pE_F"_ ^ ed($lzfU:qN ;8(ywUbXaE1W]3|wB6Q-7#hk{ئq< bȁC/Sme|\ =#&cGf *[&VA-0BHBIa@f8;E>N@wX ^ 6by*OѱM%\8 Pv&bdG:[ Y sճɻPS%C( ЏpK.kN槧7`|:bЇTSѴy]j5s@?Ub `Lqbr ~9¼rÀ{O j0]fHw69M^#2'ZXՎXxVRI෱iՏiaaŗ[wR[z$ c[!gkDG$N9Fhd|遡`"5F׼Qxݯ0:f\Cv.qA]PfcȗKƟ^Nl.w_E?1!80b=Z{A-]m<vlg@*bQ'Rz#]~$ѯ)'q~BfSgُ̠OL"WZ{pDfwT}AI<Mz>K>cރh7JD7??B[A_L =&.$ qR;)P)AanSWӺog>- iDF2- Sp?{D7hU[:Z)x _0оowb.m<y0$N\%6M PdՖ$1.Y ܆OCUz̨XQwI-:t>}w{*F|ii, 7-ZؘfBKcG3xZdڶb9QF `œbkW6#ԀH7\) ,ya/z>$?~xo p+#}9pv$^I$^^ YA+QܶeE~g+>E\PC~7!t9@ =@p+W#"p#J$%LnYH![Y⢋>R_dnBЭfJU4.ۈ'WSQ) 09v飈 0y!jPVVQ YhgIͰMki&&:\2eJ2^&r+:RKow0fK2>]ɓQ9#L^ khO08'qy7|QN: ֘ ƺ k,JŞGF&a|tIAs-Xw/Y7\~wZpg FV8j.ԬZ[K -*=GjbkG.UqXN+5Y[@RDrS/(A8[Fq j" e]Lyq@clj G_P#/( dNΝcFKFMh_]\[6PlY svPG=e]||:3"*8 CV 8AVX] $*VaDCݞ_S"gXWn0u!jʑA: ޭ)bru$܏AEiHmh@itD˛&'0Ѫyg E, [{`b(ft5|-gu&-V e{|*-to X'@^ArS'H2Ua 7B=Le[--JmyJ)&XZ)ֶXӶ`X|~?y Ze5ѾmV^’\r{F^} I/:fZmŨTk^/ wv&V0:f9T۰IN`7a.y.V3I#P%m?U:]2 O96 yB'BIJF C03< py"7fgK5)adS(-lVx< i*{iE+;[JMPK.D8K:BBщ׋gC $Vi2Iĥt7z}|~mrPq!DtX}]Z:%*sHeKu젱orZZΉڢ:؉9MA<6RqXm>pbX&hx]a *;>2͍p\IdDGbB}_>~|4h.[(4nJD[$Yy*R!iJ[-Cpp 1 (kf3Y*%Ưg e$%v(qI)88EPQPE.˩YNd9mE%/,ce>%[WJܥk@ڬ'ȅnu: ʫ.x% [#: ࡃ?'Dcqtqs)$QAMHEJ"..(Rx5mZo#D:D ><õ]#Eϩa KMslD̞fG!]\{-ទ1)xO@ 5%t/JȠ.Cՠ$e#GSHH+Ti;-ҹ>kYGDI!Ur*|ç<=~|RA w=Cb4i$dA@xEQ]D'O 9V\,r'-V/kI%DM ,B+L4[1Ȼ G߼ ` 9? چa~\CD&^*Qj3PX9~!2LE+' ,)ʳe=T5*8;L7w}j9<-$}neO2[<|ROi(['nkw A+CZ,^x Xjt j8`]ş4Y׳ZlK%(C8˶''g9DKii.d4qcR/*/)"M.BT 2!NE lAJS0GrQ 'FEyP޾¦̶B n.Їa֭"zDh 5^XEےx:8Ǧ0T}ll.0nPQ O", *=-{n5ʑK4~-8l א*%%4ik" .R!\jB-s={,"*+g X[)4J+΂5a4!d1a!k ĺY1r%iP/,ߓՀMMz5fZTsc1ވWe!e/JFۈmک/8OaD2Gg)Լ &WKV1B*jڿ9'|ؘ5DŚ0l03`gHY_*h`G %-J߫7ƭvLK[k4Y>Em7KK~"?Cii4HD+t׀j|Q`6qߞ909eLD0]{H8ZH,)C9$eҋN6<Ȫ\(=rJ[\t e${Ma ><~m(׶R"#( }SzCN!"`k(BȠnAG$sLCiB]7,@a% bn/5(4lt8Ф5igXnNW\^NGu\$X9߭SҶ"eҹf{5D_%R=+&rqNRa "*1:&fc')j,Q^$6)jU)$(5fd+`!ɐƔU}&{eE):,nuG!i՛9>Ud晴U4+e!UM oN28d< X1\' Y~E߾iw e͐un`gFyRWtx$G/ $TQ ֒.@1+<)zĞ}]bߒY@¦(ۤP%{b[\e6Ҋ<8Ҿ26pjn5i-Ar.EVJǏO c`)HpJXG/%@-L3!ZS2VL|ڒN$hمo{[8NPm?VcWV-= bE&XV6'{+ݽ, ;?$9U쥵{0{p3|rӳ3  CfH:i9pV=)C)ДlKo)!> "ݤGnF7`]ZTacSINNIIBe֯Nc5$Ca?U!_4N.B:lBmKrqR@Y#Fn¤A๨e"MC,6M(T0V+ƉLI`n*E-,a>U}K$s7g+i|& WtQ,aNnDdu5,pJ([vV4n,wn|^pH#뤎F8Vm;TQ 9o! `P{]rOgD=sP=.yy3z'${-(IMڞb*_γgkv#Ya!:ٛTؾd%Vp4"B#Ώ,{y{{Bi}8*5SRN9ͺ5%= r9hNRp͓ئ5[&EݶH6}e=Sz[Uqgow ^&A'am+tOj\Z̪lg1(Qʦf5L +vE>+ )r$xnV a,tU><>?{1 !ZakTZC2 5hewIa\F( Y d R5]oR'z Uh6N{ cvНw Z0q97ZVl/NB%ov)Fk|8QF]:F&P/d Y8RSǸS|9%4xdGX,Q5r!{^X2KQ%:\lݷmigqQ6x 0ۈȞ_HLSI>[w[LȹZ4+)d۪@U+C,v1lf ;/4Yd$sۧdG`],}d)QDjDC!^ho<VTVdC*^dB{dUW=Y͛T6G9q5 {k«}+gAU9E ճĮÀ΂27Y7XAɬfcs9n/owVh".pw&6Yz &S|9I%/Yr{NM/6Տє ?W:f0FԱjpJHf7I3- ͫDBV`|+6B9ȹI[aT.~ۜLM0cԙ* (E#jo.c3m%U1G15Q,/Ykv7n=.o BPR^{+M~9XT&U ls2)ihVΛ3 QIql oT2=(H7]]a¸سgwv"ӌev6T&\=V~3,| jfNz1vaŀ&R!ʒS M ` pF# %V$zC{8$bǗWx&B@f}ڛI+eGvxW "@H ?퇝1M4ng)B,uM0PikViji j!ch$RZ >* oV~fݲ/GFa6 )+eRmP tx@v6قԅZ7#kRk0i]ӟVmpx=C#7 AwCpk3\O/6eV:S%AFMfjǽMג%jƂIRI#*S2vKۛL+'Pjl.i W%{6*qQ'LQ6l1K9v6rOuwFKd"TLWn+жRqzZ_uLH$"6s/#妼+/Jybx#̸j f0ޥtW0;X./bކ-qUwrTXS Ԇe9%M^.^uvű2J% k{Om zKfsl9C2=ϯkޖ*!Y#E ?d3$rȐ–j]hYk{U>YzEBdž^ t|I bu=3bLUA|`6ILm&5b$8a`#DyZ[33gWVq$n8aB_qXdze <8M3sfhvt'a,ZHye?G$r`%-Eڹai_gY-!rgy!14PV']ͫ2s*S(݂<Ŧ߁w8pF1y;]!C-Dz" lRԆu{q"$\L"%L)[`ymȃ 1@F;?=~;U/v XkبЮA}cN;o*'h́_RmQX-OƝ)KFUUQYU.-K@b@[[ɻE7{41_7A3C/cBundlq0)r5N$Jմ=)o.Т+QojuJ{T$j[l/l=7go?=]@]n <5bsl (i4Ym6kBUu-Q4C~>oqJSv/fs19=n˕8ڽکYd#9W=&ZqHΟǧל}"nδpB &ʖPAm6wblS[;T"Z8ɖØ}f#GI-ˡk!D1Qt1pH %zeGBSՔYvn=GL3Ficv6җ`NjGhv*{eN])tОȳQqL!f¶ϩY,9(ԖUrPbcoi43R]lFGuo{I4cR߄$-bKҬ-c$m4u2vϜP-OFW^#*X8dq _ .LVlHs^ i;Ṅ C|d4?߳tسSa$ yQk,wc9wv40^k(l$w&aIδ&M)V:gId*K Sǩtz3!g_6ſ(<5,IƄ68HN뛪Ӻ7;;+CI[e=3"ϖNVfq8d\#u`dmXl熘Aj?=XHP hYs>y}s!k q@r536QCkvXr1;]t%T9}BF0m nnq,9!zqoW~!ˋ:.6el!D& `N 4 h5~(,vDc[2?528P xْXx8SMzI65+4EP"Qi` is`ˑ2Lja,=mC/RW.}ٯ!J%9!W'Y%'M UɒAꔬ93`m>ds;Jb@ĚUp Eƪ`JE$?*8::9꘭Ǚמ$`Ik%z[zj,3rXv5eٖ M>2X$^|'$j& /;y[8o)&~)50"b9Ne4[˗O}ԇql7bc1n$m!7o]twCJYLQ=kvc3wN]%kX]i9[Yp ׄ?Or懲6=ot - Kr'yHzNIl]b9m;nlz8Yr[)H M Mtuqw1a,R1Cnaa)Uh=rgML]A1AXSruq@2䏖<aחJUg܍ChAq59? '@vGEc$#$;j}hl-fnGhSFRN|t#V统v6nvQ=:Hlia j(T`´ F\Ej=_\~l: hlY8owa Q"" Nan^}2" k5۹a[ӿsZY>/l w٢{O[.9Q"W]X9t:G }MTSD2mP"zݵ<V!jy(}>DRPsźXح*B֨J۶9LXh61PkYNr*9RLvE'NQԴB!6a`TdJI7Ddmxeu:u >3ad9 mho)'ui$AebA6PUaR&:5\1 KiLa#Ir08blIfe>yluJW_>m߱r8Ӊs<a= O OasƜòhd߿?׬eg'Efuž 3jH9#A2qxٱi F8r|?u"NtQD $;oshfrXA}NNz4)j32_BكG>Qa&w8=f1hJYd\qغ# G/)Jb{tƘՂxȩC6{ƾ8qK'ZĚQv2'{M/wIGɌe1 KvfS}=ߜ 6߽h72ˬjȞiñu:rL(F:OL2s#}!C(_L|s>;my) QZ^HCd.ZkXɤGK N={bݑ};-,$=_2 z)-n.NKQf.wK a$؟۞R_X, J!VDƏ68fdx.˯^>3sK?DR^7RjlMu2voq'<Ѻ+4?<@s&݄$3lrr܉Pq,nܼɃc)kS^|BjɁ P$jc/ ɚJFVCsjG{Y)u8 qhfDZ-RWa]b_(FG ¤L$h\"rlCL'b؃7-@4k4m7n9'zhI ~c57O]}}>GmFt54O #:)\&f6Pn #>I'Pm[ J6C-:mL9'qsCPWS=6JUrJ`|vqfh١K>?cUؗM蹴L4DyQ]dmD^wc &Pz Ny.#Kq$B찭l<(g8Μk䀭>I RZ'R$̏nSKsŲaT<nAl"j-q|6]FD}<.G= QeR*9ʃ3 61MJ;':श<6CyZԈKχ[1p6] w__^r?}ퟖfWpygraphviz-1.3.1/examples/star.py0000644000175000017500000000217712573042175016753 0ustar aricaric00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Create and draw a star with varying node properties. """ # Copyright (C) 2006 by # Aric Hagberg # Dan Schult # Manos Renieris, http://www.cs.brown.edu/~er/ # Distributed with BSD license. # All rights reserved, see LICENSE for details. from __future__ import absolute_import from __future__ import unicode_literals from __future__ import print_function from __future__ import division __author__ = """Aric Hagberg (hagberg@lanl.gov)""" from pygraphviz import * A=AGraph() # set some default node attributes A.node_attr['style']='filled' A.node_attr['shape']='circle' A.node_attr['fixedsize']='true' A.node_attr['fontcolor']='#FFFFFF' # make a star in shades of red for i in range(16): A.add_edge(0,i) n=A.get_node(i) n.attr['fillcolor']="#%2x0000"%(i*16) n.attr['height']="%s"%(i/16.0+0.5) n.attr['width']="%s"%(i/16.0+0.5) print(A.string()) # print to screen A.write("star.dot") # write to simple.dot print("Wrote star.dot") A.draw('star.png',prog="circo") # draw to png using circo print("Wrote star.png") pygraphviz-1.3.1/Makefile0000644000175000017500000000065412573042175015250 0ustar aricaric00000000000000all: swig: swig -python pygraphviz/graphviz.i # DOS endings to not corrupt the diff. @unix2dos pygraphviz/graphviz.py @unix2dos pygraphviz/graphviz_wrap.c # Clean all build and test artifacts. clean c: rm -rf build *.pyc *.egg-info MANIFEST .noseids __pycache__ .tox find pygraphviz -name '*.pyc' -delete find pygraphviz -name '*.so' -delete find pygraphviz -name '__pycache__' -type d | xargs --no-run-if-empty rm -r pygraphviz-1.3.1/README.rst0000644000175000017500000000103112573042175015265 0ustar aricaric00000000000000PyGraphviz ---------- PyGraphviz is a Python interface to the Graphviz graph layout and visualization package. With PyGraphviz you can create, edit, read, write, and draw graphs using Python to access the Graphviz graph data structure and layout algorithms. PyGraphviz is distributed with a BSD license. Copyright (C) 2006-2015 by Aric Hagberg Dan Schult Manos Renieris, http://www.cs.brown.edu/~er/ Distributed with BSD license. All rights reserved, see LICENSE.txt for details.