pax_global_header00006660000000000000000000000064146172065610014522gustar00rootroot0000000000000052 comment=d8f0fa24ee4eb20d64e06f57fe2791f6a1b3680d pygraphviz-pygraphviz-1.13/000077500000000000000000000000001461720656100160525ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/.circleci/000077500000000000000000000000001461720656100177055ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/.circleci/config.yml000066400000000000000000000021111461720656100216700ustar00rootroot00000000000000# See: https://circleci.com/docs/2.0/language-python/ version: 2.0 jobs: build: working_directory: ~/repo docker: - image: cimg/python:3.10 steps: - checkout - run: name: Update apt-get command: sudo apt-get update - run: name: Install Graphviz command: sudo apt-get install graphviz libgraphviz-dev - run: name: Install TeX command: sudo apt-get install texlive texlive-latex-extra latexmk imagemagick - run: name: Install Python dependencies command: | python3 -m venv venv source venv/bin/activate pip install --upgrade pip wheel setuptools pip install -U -r requirements/doc.txt pip list - run: name: Install command: | source venv/bin/activate pip install . - run: name: Build docs command: | source venv/bin/activate make -C doc/ html - store_artifacts: path: doc/build/html pygraphviz-pygraphviz-1.13/.coveragerc000066400000000000000000000000761461720656100201760ustar00rootroot00000000000000[run] source = pygraphviz omit = setup.py, pygraphviz/tests/* pygraphviz-pygraphviz-1.13/.github/000077500000000000000000000000001461720656100174125ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/.github/dependabot.yml000066400000000000000000000004371461720656100222460ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "monthly" labels: - "type: Maintenance" - package-ecosystem: "pip" directory: "/" schedule: interval: "monthly" labels: - "type: Maintenance" pygraphviz-pygraphviz-1.13/.github/workflows/000077500000000000000000000000001461720656100214475ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/.github/workflows/circleci.yml000066400000000000000000000007101461720656100237450ustar00rootroot00000000000000on: [status] jobs: circleci_artifacts_redirector_job: runs-on: ubuntu-latest name: Run CircleCI artifact redirector steps: - name: GitHub Action step uses: larsoner/circleci-artifacts-redirector-action@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} api-token: ${{ secrets.CIRCLECI_ARTIFACT_REDIRECTOR_TOKEN }} artifact-path: 0/doc/build/html/index.html circleci-jobs: build pygraphviz-pygraphviz-1.13/.github/workflows/conda-macos.yml000066400000000000000000000020151461720656100243540ustar00rootroot00000000000000name: conda-forge-macos on: schedule: # Run this workflow once a week - cron: "0 0 * * 0" workflow_dispatch: jobs: install: runs-on: macos-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Setup conda with mambaforge uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-variant: Mambaforge miniforge-version: latest use-mamba: true python-version: ${{ matrix.python-version }} - name: Conda info shell: bash -l {0} run: conda info - name: Conda list shell: bash -l {0} run: conda list - name: Install and Test shell: bash -l {0} run: | mamba create -n pgv-testenv python=${{ matrix.python-version }} conda activate pgv-testenv mamba install --channel conda-forge pygraphviz mamba install --channel conda-forge pytest pytest --pyargs pygraphviz pygraphviz-pygraphviz-1.13/.github/workflows/conda-ubuntu.yml000066400000000000000000000020171461720656100245760ustar00rootroot00000000000000name: conda-forge-ubuntu on: schedule: # Run this workflow once a week - cron: "0 0 * * 0" workflow_dispatch: jobs: install: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Setup conda with mambaforge uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-variant: Mambaforge miniforge-version: latest use-mamba: true python-version: ${{ matrix.python-version }} - name: Conda info shell: bash -l {0} run: conda info - name: Conda list shell: bash -l {0} run: conda list - name: Install and Test shell: bash -l {0} run: | mamba create -n pgv-testenv python=${{ matrix.python-version }} conda activate pgv-testenv mamba install --channel conda-forge pygraphviz mamba install --channel conda-forge pytest pytest --pyargs pygraphviz pygraphviz-pygraphviz-1.13/.github/workflows/conda-windows.yml000066400000000000000000000020211461720656100247410ustar00rootroot00000000000000name: conda-forge-windows on: schedule: # Run this workflow once a week - cron: "0 0 * * 0" workflow_dispatch: jobs: install: runs-on: windows-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Setup conda with mambaforge uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-variant: Mambaforge miniforge-version: latest use-mamba: true python-version: ${{ matrix.python-version }} - name: Conda info shell: bash -l {0} run: conda info - name: Conda list shell: bash -l {0} run: conda list - name: Install and Test shell: bash -l {0} run: | mamba create -n pgv-testenv python=${{ matrix.python-version }} conda activate pgv-testenv mamba install --channel conda-forge pygraphviz mamba install --channel conda-forge pytest pytest --pyargs pygraphviz pygraphviz-pygraphviz-1.13/.github/workflows/coverage.yml000066400000000000000000000016141461720656100237670ustar00rootroot00000000000000name: coverage on: [push, pull_request] jobs: ubuntu: runs-on: Ubuntu-22.04 strategy: matrix: python-version: ["3.10"] steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Update apt-get run: sudo apt-get update - name: Install graphviz run: sudo apt-get install graphviz graphviz-dev - name: Install packages run: | pip install --upgrade pip wheel setuptools pip install -r requirements/doc.txt pip install -r requirements/test.txt pip install -e . pip list - name: Coverage report for pygraphviz run: | pytest --cov=pygraphviz --doctest-modules --durations=10 --pyargs pygraphviz codecov pygraphviz-pygraphviz-1.13/.github/workflows/deploy-docs.yml000066400000000000000000000037351461720656100244240ustar00rootroot00000000000000name: deploy on: push: branches: [ main ] jobs: documentation: # Do not attempt to deploy documentation in forks if: github.repository_owner == 'pygraphviz' runs-on: Ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' - name: Update apt-get run: sudo apt-get update - name: Install Graphviz run: sudo apt-get install graphviz graphviz-dev - name: Install TeX run: sudo apt-get install texlive texlive-latex-extra latexmk imagemagick ghostscript libfreetype6-dev gsfonts libmagickwand-dev - name: Install packages run: | pip install --upgrade pip wheel setuptools pip install -r requirements/doc.txt -r requirements/test.txt pip install . pip list # To set up a cross-repository deploy key: # 1. Create a key pair: # `ssh-keygen -t ed25519 -C "pgz_doc_deploy_ci_bot@nomail"` # 2. Add the public key to the pygraphviz/documentation repo # Settings -> Deploy keys -> Add new # Make sure to check the "writeable" checkbox # 3. Add private key as a secret to pygraphviz/pygraphviz # Settings -> Secrets -> New Repository Secret # Make sure the name is the same as below, e.g. CI_DEPLOY_KEY - name: Install SSH agent if: github.ref == 'refs/heads/main' uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.CI_DEPLOY_KEY }} - name: Build docs if: github.ref == 'refs/heads/main' run: make -C doc/ html - name: Deploy docs if: github.ref == 'refs/heads/main' uses: JamesIves/github-pages-deploy-action@releases/v3 with: GIT_CONFIG_NAME: gh-deploy-bot GIT_CONFIG_EMAIL: gh-deploy-bot@nomail FOLDER: doc/build/html REPOSITORY_NAME: pygraphviz/documentation BRANCH: gh-pages TARGET_FOLDER: latest SSH: true pygraphviz-pygraphviz-1.13/.github/workflows/label-check.yaml000066400000000000000000000005231461720656100244650ustar00rootroot00000000000000name: Labels on: pull_request: types: - opened - labeled - unlabeled env: LABELS: ${{ join( github.event.pull_request.labels.*.name, ' ' ) }} jobs: check-type-label: name: ensure type label runs-on: ubuntu-latest steps: - if: "contains( env.LABELS, 'type: ' ) == false" run: exit 1 pygraphviz-pygraphviz-1.13/.github/workflows/lint.yml000066400000000000000000000011561461720656100231430ustar00rootroot00000000000000name: style on: [push, pull_request] jobs: format: runs-on: ubuntu-22.04 strategy: matrix: python-version: ["3.10"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install packages run: | pip install --upgrade pip wheel setuptools pip install -r requirements/developer.txt pip list - name: Lint run: pre-commit run --all-files --show-diff-on-failure --color always pygraphviz-pygraphviz-1.13/.github/workflows/milestone-merged-prs.yaml000066400000000000000000000005711461720656100264000ustar00rootroot00000000000000name: Milestone on: pull_request_target: types: - closed branches: - "main" jobs: milestone_pr: name: attach to PR runs-on: ubuntu-latest steps: - uses: scientific-python/attach-next-milestone-action@bc07be829f693829263e57d5e8489f4e57d3d420 with: token: ${{ secrets.MILESTONE_LABELER_TOKEN }} force: true pygraphviz-pygraphviz-1.13/.github/workflows/release.yml000066400000000000000000000017021461720656100236120ustar00rootroot00000000000000name: Build Wheel and Release on: push: tags: - pygraphviz-* jobs: pypi-publish: name: upload release to PyPI if: github.repository_owner == 'pygraphviz' && startsWith(github.ref, 'refs/tags/pygraphviz-') && github.actor == 'jarrodmillman' && always() runs-on: ubuntu-latest # Specifying a GitHub environment is optional, but strongly encouraged environment: release permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-python@v5 name: Install Python with: python-version: "3.11" - name: Build wheels run: | git clean -fxd pip install -U build twine wheel python -m build --sdist - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 pygraphviz-pygraphviz-1.13/.github/workflows/test.yml000066400000000000000000000132721461720656100231560ustar00rootroot00000000000000name: test on: [push, pull_request] env: WIN_GRAPHVIZ_URL: "https://gitlab.com/graphviz/graphviz/-/package_files/6164164/download" WIN_GRAPHVIZ_EXE: "C:\\Temp\\graphviz-install-2.46.0-win64.exe" WIN_GRAPHVIZ_DIR: "C:\\Program Files\\Graphviz" jobs: ubuntu: runs-on: Ubuntu-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12", "pypy-3.10"] steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Update apt-get run: sudo apt-get update - name: Install graphviz run: sudo apt-get install graphviz graphviz-dev - name: Install packages run: | pip install --upgrade pip pip install -r requirements/test.txt pip install . pip list - name: Test pygraphviz run: | pytest --doctest-modules --durations=10 --pyargs pygraphviz fedora: strategy: matrix: release: - 39 - 40 runs-on: Ubuntu-latest container: 'fedora:${{ matrix.release }}' steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Install graphviz run: sudo dnf install --nogpg -y graphviz graphviz-devel - name: Install Python developer tools run: sudo dnf install --nogpg -y python3-devel - name: Install gcc run: sudo dnf install -y --nogpg gcc - name: Install packages run: | pip install --upgrade pip pip install -r requirements/test.txt pip install . pip list - name: Test pygraphviz run: | pytest --doctest-modules --durations=10 --pyargs pygraphviz brew: runs-on: macOS-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install graphviz run: brew install graphviz - name: Install packages run: | pip install --upgrade pip pip install -r requirements/test.txt pip install --config-settings="--global-option=build_ext" \ --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \ --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \ . pip list - name: Test pygraphviz run: | pytest --doctest-modules --durations=10 --pyargs pygraphviz macports: runs-on: macOS-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Download macports pkg run: wget https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-14-Sonoma.pkg - name: Install macports run: sudo installer -pkg MacPorts-2.9.3-14-Sonoma.pkg -target / - name: Install graphviz run: sudo /opt/local/bin/port install graphviz - name: Install packages run: | pip install --upgrade pip setuptools pip install -r requirements/test.txt pip install --config-settings="--global-option=build_ext" \ --config-settings="--global-option=-I/opt/local/include/" \ --config-settings="--global-option=-L/opt/local/lib/" \ . pip list - name: Test pygraphviz run: | export PATH=/opt/local/bin:/opt/local/sbin:$PATH pytest --doctest-modules --durations=10 --pyargs pygraphviz windows: runs-on: windows-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Checkout pygraphviz uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} # This and the following step need to be changed when Graphviz has new releases. - name: Download graphviz source run: Invoke-WebRequest -Uri $env:WIN_GRAPHVIZ_URL -OutFile $env:WIN_GRAPHVIZ_EXE - name: Install exe run: Start-Process -Wait -FilePath $env:WIN_GRAPHVIZ_EXE -ArgumentList '/S' -PassThru - name: Update path run: echo "$($env:WIN_GRAPHVIZ_DIR)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append # We need ``python -m pip install -U pip`` b/c Windows won't modify running programs. - name: Install packages run: | python -m pip install --upgrade pip python -m pip install -r requirements/test.txt python -m pip install --config-settings="--global-option=build_ext" ` --config-settings="--global-option=-I$($env:WIN_GRAPHVIZ_DIR)\include" ` --config-settings="--global-option=-L$($env:WIN_GRAPHVIZ_DIR)\lib" ` . python -m pip list # We are leaving this in to help us remember some useful PowerShell syntax. # The following commands are also helpful for debugging: Copy-Item, Get-Content - name: List run: Get-ChildItem "$($env:WIN_GRAPHVIZ_DIR)\bin" # Set PY_IGNORE_IMPORTMISMATCH b/c otherwise --doctest-modules is confused. - name: Test pygraphviz run: | [Environment]::SetEnvironmentVariable("PY_IGNORE_IMPORTMISMATCH", 1) pytest --doctest-modules --durations=10 --pyargs pygraphviz pygraphviz-pygraphviz-1.13/.gitignore000066400000000000000000000011151461720656100200400ustar00rootroot00000000000000*.pyc __pycache__ *~ .DS_Store build/* doc/source/pygraphviz-documentation.zip doc/source/pygraphviz.pdf doc/source/auto_examples/* doc/gh-pages doc/build # Generated while building documentation. doc/source/static/examples/* doc/source/reference/generated/* doc/source/examples/* # Generated when 'python setup_egg.py' pygraphviz.egg-info/ # Testing .coverage # Dotfiles generated when running gallery examples examples/*.dot dist/ *.pyd *.dll pygraphviz/version.py _b/ .idea/ file *.ps pygraphviz/_graphviz*.so .tox/ MANIFEST .eggs/ # Virtual environment directory pygraphviz-dev pygraphviz-pygraphviz-1.13/.pre-commit-config.yaml000066400000000000000000000017531461720656100223410ustar00rootroot00000000000000# Install pre-commit hooks via # pre-commit install exclude: (graphviz.py|graphviz_wrap.c) repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: debug-statements - id: check-ast - id: mixed-line-ending - id: check-yaml args: [--allow-multiple-documents] - id: check-json - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black rev: 3702ba224ecffbcec30af640c149f231d90aebdb # frozen: 24.4.2 hooks: - id: black - repo: https://github.com/adamchainz/blacken-docs rev: 960ead214cd1184149d366c6d27ca6c369ce46b6 # frozen: 1.16.0 hooks: - id: blacken-docs - repo: https://github.com/asottile/pyupgrade rev: 12af25eb252deaaecb6b259df40d01f42e716dc3 # frozen: v3.15.2 hooks: - id: pyupgrade args: [--py310-plus] pygraphviz-pygraphviz-1.13/CONTRIBUTING.rst000066400000000000000000000222331461720656100205150ustar00rootroot00000000000000.. _contributor_guide: Contributor Guide ================= .. note:: This document assumes some familiarity with contributing to open source scientific Python projects using GitHub pull requests. .. _dev_workflow: Development Workflow -------------------- 1. If you are a first-time contributor: * You'll need to install GraphViz on your local computer, if you haven't already. For OS-specific installation instructions, refer to `INSTALL.txt `_. * Go to `https://github.com/pygraphviz/pygraphviz `_ and click the "fork" button to create your own copy of the project. * Clone the project to your local computer:: git clone git@github.com:your-username/pygraphviz.git * Navigate to the folder pygraphviz and add the upstream repository:: git remote add upstream git@github.com:pygraphviz/pygraphviz.git * Now, you have remote repositories named: - ``upstream``, which refers to the ``pygraphviz`` repository - ``origin``, which refers to your personal fork * Next, you need to set up your build environment. Here are instructions using ``venv``: * ``venv`` (pip based) :: # Create a virtualenv named ``pygraphviz-dev`` that lives in the directory of # the same name python -m venv pygraphviz-dev # Activate it source pygraphviz-dev/bin/activate # Install main development and runtime dependencies of pygraphviz pip install -r requirements/test.txt -r requirements/developer.txt # # Build and install pygraphviz from source pip install -e . # Test your installation PYTHONPATH=. pytest pygraphviz * Finally, we recommend you use a pre-commit hook, which runs black when you type ``git commit``:: pre-commit install 2. Develop your contribution: * Pull the latest changes from upstream:: git checkout main git pull upstream main * Create a branch for the feature you want to work on. Since the branch name will appear in the merge message, use a sensible name such as 'bugfix-for-issue-1480':: git checkout -b bugfix-for-issue-1480 * Commit locally as you progress (``git add`` and ``git commit``) 3. Test your contribution: * Run the test suite locally (see `Testing`_ for details):: PYTHONPATH=. pytest pygraphviz * Running the tests locally *before* submitting a pull request helps catch problems early and reduces the load on the continuous integration system. 4. Submit your contribution: * Push your changes back to your fork on GitHub:: git push origin bugfix-for-issue-1480 * Go to GitHub. The new branch will show up with a green Pull Request button---click it. * If you want, post on the `mailing list `_ to explain your changes or to ask for review. 5. Review process: * Every Pull Request (PR) update triggers a set of `continuous integration `_ services that check that the code is up to standards and passes all our tests. These checks must pass before your PR can be merged. If one of the checks fails, you can find out why by clicking on the "failed" icon (red cross) and inspecting the build and test log. * Reviewers (the other developers and interested community members) will write inline and/or general comments on your PR to help you improve its implementation, documentation, and style. Every single developer working on the project has their code reviewed, and we've come to see it as friendly conversation from which we all learn and the overall code quality benefits. Therefore, please don't let the review discourage you from contributing: its only aim is to improve the quality of project, not to criticize (we are, after all, very grateful for the time you're donating!). * To update your PR, make your changes on your local repository and commit. As soon as those changes are pushed up (to the same branch as before) the PR will update automatically. .. note:: If the PR closes an issue, make sure that GitHub knows to automatically close the issue when the PR is merged. For example, if the PR closes issue number 1480, you could use the phrase "Fixes #1480" in the PR description or commit message. To reviewers: make sure the merge message also has a brief description of the change(s). Divergence from ``upstream main`` --------------------------------- If GitHub indicates that the branch of your Pull Request can no longer be merged automatically, merge the main branch into yours:: git fetch upstream main git merge upstream/main If any conflicts occur, they need to be fixed before continuing. See which files are in conflict using:: git status Which displays a message like:: Unmerged paths: (use "git add ..." to mark resolution) both modified: file_with_conflict.txt Inside the conflicted file, you'll find sections like these:: <<<<<<< HEAD The way the text looks in your branch ======= The way the text looks in the main branch >>>>>>> main Choose one version of the text that should be kept, and delete the rest:: The way the text looks in your branch Now, add the fixed file:: git add file_with_conflict.txt Once you've fixed all merge conflicts, do:: git commit .. note:: Advanced Git users may want to rebase instead of merge, but we squash and merge PRs either way. Guidelines ---------- * All code should have tests. * All code should be documented, to the same `standard `_ as NumPy and SciPy. * All changes are reviewed. Ask on the `mailing list `_ if you get no response to your pull request. Testing ------- To run all tests:: $ PYTHONPATH=. pytest pygraphviz Or tests from a specific file:: $ PYTHONPATH=. pytest pygraphviz/tests/test_readwrite.py Use ``--doctest-modules`` to run doctests. For example, run all tests and all doctests using:: $ PYTHONPATH=. pytest --doctest-modules pygraphviz Tests for a module should ideally cover all code in that module, i.e., statement coverage should be at 100%. To measure the test coverage, run:: $ PYTHONPATH=. pytest --cov=pygraphviz pygraphviz This will print a report with one line for each file in `pygraphviz`, detailing the test coverage:: Name Stmts Miss Cover -------------------------------------------- pygraphviz/__init__.py 12 4 67% pygraphviz/agraph.py 1022 196 81% pygraphviz/graphviz.py 179 42 77% pygraphviz/scraper.py 26 18 31% pygraphviz/testing.py 16 0 100% -------------------------------------------- TOTAL 1255 260 79% Adding tests ------------ If you're **new to testing**, see existing test files for examples of things to do. **Don't let the tests keep you from submitting your contribution!** If you're not sure how to do this or are having trouble, submit your pull request anyway. We will help you create the tests and sort out any kind of problem during code review. Adding examples --------------- The gallery examples are managed by `sphinx-gallery `_. The source files for the example gallery are ``.py`` scripts in ``examples/`` that generate one or more figures. They are executed automatically by sphinx-gallery when the documentation is built. The output is gathered and assembled into the gallery. You can **add a new** plot by placing a new ``.py`` file in one of the directories inside the ``examples`` directory of the repository. See the other examples to get an idea for the format. .. note:: Gallery examples should start with ``plot_``, e.g. ``plot_new_example.py`` General guidelines for making a good gallery plot: * Examples should highlight a single feature/command. * Try to make the example as simple as possible. * Data needed by examples should be included in the same directory and the example script. * Add comments to explain things are aren't obvious from reading the code. * Describe the feature that you're showcasing and link to other relevant parts of the documentation. SWIG Wrapper ------------ ``pygraphviz`` uses SWIG to generate wrappers around the graphviz C code. Any modifications to C source code should be made in the SWIG wrapper file, ``graphviz.i``, not ``graphviz_wrap.c`` as this file is auto-generated by SWIG and any manual changes will be overwritten. The wrappers can be generated with: ``swig -python pygraphviz/graphviz.i``. This requires SWIG to be installed. .. note:: The wrappers must be generated from the top-level directory, i.e. :: swig -python pygraphviz/graphviz.i Attempting to regenerate the wrappers from another directory will result in broken builds. Bugs ---- Please `report bugs on GitHub `_. pygraphviz-pygraphviz-1.13/INSTALL.txt000066400000000000000000000117601461720656100177260ustar00rootroot00000000000000******* Install ******* PyGraphviz requires: - Python (version 3.10, 3.11, or 3.12) - `Graphviz `_ (version 2.46 or later) - C/C++ Compiler .. note:: These instructions assume you have Python and a C/C++ Compiler on your computer. .. warning:: Do not use the default channels to install pygraphviz with ``conda``. The conda-forge channel should be used instead:: conda install --channel conda-forge pygraphviz - |conda-forge-ubuntu-badge| - |conda-forge-macos-badge| - |conda-forge-windows-badge| .. |conda-forge-ubuntu-badge| image:: https://github.com/pygraphviz/pygraphviz/workflows/conda-forge-ubuntu/badge.svg .. |conda-forge-macos-badge| image:: https://github.com/pygraphviz/pygraphviz/workflows/conda-forge-macos/badge.svg .. |conda-forge-windows-badge| image:: https://github.com/pygraphviz/pygraphviz/workflows/conda-forge-windows/badge.svg Recommended =========== We recommend installing Python packages using `pip and virtual environments `_. Linux ----- We recommend installing Graphviz using your Linux system's package manager. Below are examples for some popular distributions. Ubuntu and Debian ~~~~~~~~~~~~~~~~~ .. code-block:: console $ sudo apt-get install graphviz graphviz-dev $ pip install pygraphviz Fedora and Red Hat ~~~~~~~~~~~~~~~~~~ You may need to replace ``dnf`` with ``yum`` in the example below. .. code-block:: console $ sudo dnf install graphviz graphviz-devel $ pip install pygraphviz macOS ----- We recommend installing Graphviz using the Homebrew package manager or MacPorts for macOS. Homebrew ~~~~~~~~ .. code-block:: console $ brew install graphviz $ pip install pygraphviz .. note:: Graphviz may be installed in a location that is not on the default search path. In this case, it may be necessary to manually specify the path to the graphviz include and/or library directories, e.g. :: pip install --config-settings="--global-option=build_ext" \ --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \ --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \ pygraphviz See the Advanced section for details. MacPorts ~~~~~~~~ .. code-block:: console $ port install graphviz $ pip install pygraphviz $ pip install --config-settings="--global-option=build_ext" \ --config-settings="--global-option=-I/opt/local/include/" \ --config-settings="--global-option=-L/opt/local/lib/" \ pygraphviz Advanced ======== The two main difficulties are 1. installing Graphviz and 2. informing pip where Graphviz is installed. Providing path to Graphviz -------------------------- If you've installed Graphviz and ``pip`` is unable to find Graphviz, then you need to provide ``pip`` with the path(s) where it can find Graphviz. To do this, you first need to figure out where the binary files, includes files, and library files for Graphviz are located on your file system. Once you know where you've installed Graphviz, you will need to do something like the following. There is an additional example using Chocolatey on Windows further down the page. .. _windows-install: Windows ------- Historically, installing Graphviz and PyGraphviz on Windows has been challenging. Fortunately, the Graphviz developers are working to fix this and their recent releases have much improved the situation. For this reason, PyGraphviz 1.7 only supports Graphviz 2.46.0 or higher on Windows. We recommend either manually installing the official binary release of Graphviz or using `Chocolatey `_, which has been updated to Graphviz 2.46.0. You may also need to install Visual C/C++, e.g. from here: https://visualstudio.microsoft.com/visual-cpp-build-tools/ Assuming you have Python and Visual C/C++ installed, we believe the following should work on Windows 10 (64 bit) using PowerShell. Manual download ~~~~~~~~~~~~~~~ 1. Download and install 2.46.0 for Windows 10 (64-bit): `stable_windows_10_cmake_Release_x64_graphviz-install-2.46.0-win64.exe `_. 2. Install PyGraphviz via .. code-block:: console PS C:\> python -m pip install --config-settings="--global-option=build_ext" ` --config-settings="--global-option=-IC:\Program Files\Graphviz\include" ` --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" ` pygraphviz Chocolatey ~~~~~~~~~~ .. code-block:: console PS C:\> choco install graphviz PS C:\> python -m pip install --config-settings="--global-option=build_ext" ` --config-settings="--global-option="-IC:\Program Files\Graphviz\include" ` --config-settings="--global-option="-LC:\Program Files\Graphviz\lib" ` pygraphviz .. include:: reference/faq.rst pygraphviz-pygraphviz-1.13/LICENSE000066400000000000000000000032761461720656100170670ustar00rootroot00000000000000PyGraphviz is distributed with the 3-clause BSD license. :: Copyright (C) 2004-2024, PyGraphviz Developers Aric Hagberg Dan Schult Manos Renieris All rights reserved. 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 PyGraphviz Developers 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-pygraphviz-1.13/MANIFEST.in000066400000000000000000000005451461720656100176140ustar00rootroot00000000000000include MANIFEST.in include INSTALL.txt include README.rst include LICENSE include *.py include *.swg include Makefile 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-pygraphviz-1.13/Makefile000066400000000000000000000006431461720656100175150ustar00rootroot00000000000000all: 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 __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-pygraphviz-1.13/README.rst000066400000000000000000000027431461720656100175470ustar00rootroot00000000000000PyGraphviz ========== .. image:: https://github.com/pygraphviz/pygraphviz/workflows/test/badge.svg?branch=main :target: https://github.com/pygraphviz/pygraphviz/actions?query=workflow%3Atest+branch%3Amain .. image:: https://codecov.io/gh/pygraphviz/pygraphviz/branch/main/graph/badge.svg :target: https://app.codecov.io/gh/pygraphviz/pygraphviz/branch/main 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 (https://networkx.org). - **Website (including documentation):** https://pygraphviz.github.io - **Mailing list:** https://groups.google.com/forum/#!forum/pygraphviz-discuss - **Source:** https://github.com/pygraphviz/pygraphviz - **Bug reports:** https://github.com/pygraphviz/pygraphviz/issues Simple example -------------- .. code:: pycon >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_node("a") >>> G.add_edge("b", "c") >>> print(G) strict graph "" { a; b -- c; } Install ------- PyGraphviz requires Graphviz. Please see `INSTALL.txt` for details. License ------- Released under the 3-Clause BSD license (see ``LICENSE``):: Copyright (C) 2006-2024 PyGraphviz Developers Aric Hagberg Dan Schult Manos Renieris pygraphviz-pygraphviz-1.13/RELEASE.rst000066400000000000000000000051451461720656100176710ustar00rootroot00000000000000Release process for ``pygraphviz`` ================================ Introduction ------------ Example ``version number`` - 1.8.dev0 # development version of 1.8 (release candidate 1) - 1.8rc1 # 1.8 release candidate 1 - 1.8rc2.dev0 # development version of 1.8 release candidate 2 - 1.8 # 1.8 release - 1.9.dev0 # development version of 1.9 (release candidate 1) Process ------- - Set release variables:: export VERSION= export PREVIOUS= export ORG="pygraphviz" export REPO="pygraphviz" If this is a prerelease: export NOTES="doc/source/release/release_dev.rst" If this is release: export NOTES="doc/source/release/release_${VERSION}.rst" git rm doc/source/release/release_dev.rst - Autogenerate release notes:: changelist ${ORG}/${REPO} pygraphviz-${PREVIOUS} main --version ${VERSION} --out ${NOTES} --format rst - Edit ``doc/source/_static/version_switcher.json`` in order to add the release, move the key value pair `"preferred": true` to the most recent stable version, and commit. - Update ``version`` in ``pygraphviz/__init__.py``. - Commit changes:: git add pygraphviz/__init__.py ${NOTES} doc/source/_static/version_switcher.json git commit -m "Designate ${VERSION} release" - Tag the release in git:: git tag -s pygraphviz-${VERSION} -m "signed ${VERSION} tag" If you do not have a gpg key, use -u instead; it is important for Debian packaging that the tags are annotated - Push the new meta-data to github:: git push --tags origin main where ``origin`` is the name of the ``github.com:pygraphviz/pygraphviz`` repository - Review the github release page:: https://github.com/pygraphviz/pygraphviz/tags - Update documentation on the web: The documentation is kept in a separate repo: pygraphviz/documentation - Wait for the CI service to deploy to GitHub Pages - Sync your branch with the remote repo: ``git pull``. - Copy the documentation built by the CI service. Assuming you are at the top-level of the ``documentation`` repo:: # FIXME - use eol_banner.html cp -a latest ../pygraphviz-${VERSION} git reset --hard mv ../pygraphviz-${VERSION} . rm -rf stable cp -rf pygraphviz-${VERSION} stable git add pygraphviz-${VERSION} stable git commit -m "Add ${VERSION} docs" git push # force push---be careful! - Update ``version`` in ``pygraphviz/__init__.py``. - Commit changes:: git add pygraphviz/__init__.py git commit -m 'Bump version' git push origin main pygraphviz-pygraphviz-1.13/doc/000077500000000000000000000000001461720656100166175ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/Makefile000066400000000000000000000032531461720656100202620ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. ALLSPHINXOPTS = -d build/doctrees $(SPHINXOPTS) source .PHONY: help clean html dirhtml linkcheck doctest 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 " 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 -rm -rf source/auto_examples generate: build/generate-stamp build/generate-stamp: $(wildcard source/reference/*.rst) mkdir -p build touch build/generate-stamp html: generate #make latex #make -C build/latex all-pdf #cp build/latex/pygraphviz.pdf source/. $(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." 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." pygraphviz-pygraphviz-1.13/doc/source/000077500000000000000000000000001461720656100201175ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/_static/000077500000000000000000000000001461720656100215455ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/_static/version_switcher.json000066400000000000000000000006761461720656100260460ustar00rootroot00000000000000[ { "name": "latest", "version": "latest", "url": "https://pygraphviz.github.io/documentation/latest/" }, { "name": "1.13 (stable)", "version":"1.13", "url": "https://pygraphviz.github.io/documentation/stable/", "preferred": true }, { "name": "1.12", "version":"1.12", "url": "https://pygraphviz.github.io/documentation/pygraphviz-1.12/" } ] pygraphviz-pygraphviz-1.13/doc/source/conf.py000066400000000000000000000111551461720656100214210ustar00rootroot00000000000000from datetime import date from warnings import filterwarnings filterwarnings( "ignore", message="Matplotlib is currently using agg", category=UserWarning ) # 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.autosummary", "sphinx.ext.autodoc", "sphinx.ext.imgmath", "sphinx.ext.doctest", "sphinx.ext.intersphinx", "sphinx.ext.mathjax", "sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.imgconverter", "sphinx_gallery.gen_gallery", "numpydoc", ] # General substitutions. project = "PyGraphviz" copyright = f"2004-{date.today().year}, PyGraphviz Developers" # Sphinx gallery configuration sphinx_gallery_conf = { "examples_dirs": "../../examples", "gallery_dirs": "auto_examples", "ignore_pattern": "skip_", "image_scrapers": ("pygraphviz",), } # 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' # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # Options for HTML output # ----------------------- html_baseurl = "https://pygraphviz.github.io/documentation/stable" html_theme = "pydata_sphinx_theme" html_theme_options = { "navigation_depth": 3, "icon_links": [ { "name": "Home Page", "url": "https://pygraphviz.github.io/", "icon": "fas fa-home", }, { "name": "GitHub", "url": "https://github.com/pygraphviz/pygraphviz", "icon": "fab fa-github-square", }, ], "logo": { "text": "PyGraphviz", }, "navbar_end": ["theme-switcher", "navbar-icon-links", "version-switcher"], "show_prev_next": False, "show_version_warning_banner": True, "switcher": { "json_url": ( "https://pygraphviz.github.io/documentation/latest/_static/version_switcher.json" ), "version_match": "latest" if "dev" in version else version, }, } # 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 = [] pygraphviz-pygraphviz-1.13/doc/source/developer/000077500000000000000000000000001461720656100221045ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/developer/contribute.rst000066400000000000000000000000471461720656100250150ustar00rootroot00000000000000.. include:: ../../../CONTRIBUTING.rst pygraphviz-pygraphviz-1.13/doc/source/developer/index.rst000066400000000000000000000002001461720656100237350ustar00rootroot00000000000000.. _developer: Developer ********* :Release: |version| :Date: |today| .. toctree:: :maxdepth: 2 contribute release pygraphviz-pygraphviz-1.13/doc/source/developer/release.rst000066400000000000000000000000421461720656100242520ustar00rootroot00000000000000.. include:: ../../../RELEASE.rst pygraphviz-pygraphviz-1.13/doc/source/index.rst000066400000000000000000000015521461720656100217630ustar00rootroot00000000000000.. _contents: Python interface to Graphviz ============================ .. only:: html :Release: |version| :Date: |today| 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 (https://networkx.org). Example ------- .. code:: pycon >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_node("a") >>> G.add_edge("b", "c") >>> print(G) strict graph "" { a; b -- c; } License ------- .. include:: ../../LICENSE .. toctree:: :maxdepth: 1 :hidden: install tutorial auto_examples/index reference/index developer/index release/index pygraphviz-pygraphviz-1.13/doc/source/install.rst000077700000000000000000000000001461720656100246072../../INSTALL.txtustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/reference/000077500000000000000000000000001461720656100220555ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/reference/agraph.rst000066400000000000000000000002121461720656100240440ustar00rootroot00000000000000.. _agraph: ************ AGraph Class ************ .. currentmodule:: pygraphviz .. autoclass:: AGraph :members: :undoc-members: pygraphviz-pygraphviz-1.13/doc/source/reference/credits.rst000066400000000000000000000013241461720656100242440ustar00rootroot00000000000000Credits ======= 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-pygraphviz-1.13/doc/source/reference/faq.rst000066400000000000000000000041071461720656100233600ustar00rootroot00000000000000FAQ === :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. On \*nix systems, the preferred way to do this is by setting the appropriate flags when building/installing ``pygraphviz``. For example, if the Graphviz libraries are installed in ``/opt/lib/mygviz/`` on your system: .. code-block:: bash pip install --global-option=build_ext \ --global-option="-L/opt/lib/mygviz/" \ --global-option="-R/opt/lib/mygviz/" \ pygraphviz In this example, the ``-L`` and ``-R`` flags tell the linker where to look for the required Graphviz libraries at build time and run time, respectively. :Q: **How do I compile pygraphviz under Windows?** :A: See :ref:`windows-install` for the latest on how to install Graphviz and pygraphviz on Windows. :Q: **Why don't you distribute a pygraphviz Windows installer?** :A: We would very much like to make binary wheels available for ``pygraphviz``, but there are several complications. ``pygraphviz`` is a wrapper around Graphviz, which means that Graphviz must be installed, and Graphviz header files, libraries *and* command line executables must all be accessible for the wrapper. The recommended use of the `Graphviz CLI`_ poses challenges for wheel packaging. .. seealso:: This `GitHub issue `__ for further discussion on wheels and packaging. .. _Graphviz CLI: https://gitlab.com/graphviz/graphviz/-/issues/1808#note_403608643 pygraphviz-pygraphviz-1.13/doc/source/reference/history.rst000066400000000000000000000002321461720656100243050ustar00rootroot00000000000000History ------- The original concept was developed and implemented by Manos Renieris at Brown University: http://www.cs.brown.edu/~er/software/ pygraphviz-pygraphviz-1.13/doc/source/reference/index.rst000066400000000000000000000001771461720656100237230ustar00rootroot00000000000000.. _reference: ********* Reference ********* .. toctree:: :maxdepth: 2 agraph faq related history credits pygraphviz-pygraphviz-1.13/doc/source/reference/related.rst000066400000000000000000000004331461720656100242270ustar00rootroot00000000000000Related Packages ---------------- - 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-pygraphviz-1.13/doc/source/release/000077500000000000000000000000001461720656100215375ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/doc/source/release/index.rst000066400000000000000000000001741461720656100234020ustar00rootroot00000000000000.. _releases: ******** Releases ******** .. toctree:: :maxdepth: 2 release_1.13 release_1.12 old_release_log pygraphviz-pygraphviz-1.13/doc/source/release/old_release_log.rst000066400000000000000000000175201461720656100254150ustar00rootroot00000000000000.. -*- coding: utf-8 -*- News ==== pygraphviz-1.12 --------------- Release date: TBD - Drop Python 3.8 (SPEC 0) pygraphviz-1.11 --------------- Release date: 1 June 2023 - Update to SWIG 4.1.1 - Require Graphviz 2.46+ - Fix passthrough of graph attributes when copying - Update install instructions pygraphviz-1.10 --------------- Release date: 19 August 2022 - Add Python 3.11 support - Fix gvRenderData bytes output - Fix FILE* resource leak in agread() wrapper - Close all references to fname before calling unlink(fname) pygraphviz-1.9 -------------- Release date: 9 February 2022 - Drop Python 3.7 support - Add Python 3.10 support - Add osage and patchwork to progs list - Add IPython rich display hook to AGraph class - Add contributor guide - Fixed directed nature of AGraph.copy() - Minor documentation and code fixes pygraphviz-1.8 -------------- Release date: 20 January 2022 This release was pulled because the install was broken with pip 22 and python 3.7. pygraphviz-1.7 -------------- Release date: 1 February 2021 - Drop Python 3.6 support - Add Python 3.9 support - Require Graphviz 2.42+, (Graphviz 2.46+ recommended) - Improve installation process and documentation - Switch from nose to pytest - Remove old Python 2 code - AGraph.eq includes attribute comparison (PR #246) pygraphviz-1.6 -------------- Release date: 05 September 2020 - Add Python 3.8 support - Drop Python 2.7 support - Update to SWIG 4.0.1 pygraphviz-1.5 -------------- Release date: 10 September 2018 - Python 3.7 support 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 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 pygraphviz-1.0.0 ----------------- Release date: 30 July 2010 - 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 - 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 pygraphviz-0.37 --------------- Release date: 17 August 2008 - Handle default attributes for subgraphs - 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 - 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 - 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 - 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. This version now inter-operates with many of the NetworkX algorithms and graph generators. 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-pygraphviz-1.13/doc/source/release/release_1.12.rst000066400000000000000000000070151461720656100243550ustar00rootroot00000000000000pygraphviz 1.12 =============== We're happy to announce the release of pygraphviz 1.12! Enhancements ------------ - Add Python 3.12 support (`#486 `_). Bug Fixes --------- - Copy edges keys when copying a graph (`#473 `_). - Windows Manual Installation Fix (`#468 `_). Documentation ------------- - Windows Manual Installation Fix (`#468 `_). - Use pydata-sphinx-theme (`#494 `_). - Add version switcher (`#495 `_). - Move release notes (`#506 `_). Maintenance ----------- - Drop Python 3.8 support per SPEC 0 (`#465 `_). - Update release process (`#464 `_). - Test on Python 3.12.0-beta.2 (`#466 `_). - Update pre-commit (`#467 `_). - Use label-check and attach-next-milestone-action (`#469 `_). - Drop Python 3.9 support (`#487 `_). - Update documentation building requirements (`#488 `_). - Add pyproject.toml (`#471 `_). - Use dependabot (`#496 `_). - Bump actions/setup-python from 3 to 5 (`#501 `_). - Bump scientific-python/attach-next-milestone-action from f94a5235518d4d34911c41e19d780b8e79d42238 to bc07be829f693829263e57d5e8489f4e57d3d420 (`#500 `_). - Bump actions/checkout from 3 to 4 (`#498 `_). - Bump conda-incubator/setup-miniconda from 2 to 3 (`#499 `_). - Bump webfactory/ssh-agent from 0.5.4 to 0.8.0 (`#497 `_). - Update the year (`#502 `_). - Update license information (`#504 `_). - Stop building pdf of the docs (`#503 `_). - Use trusted publisher for PyPI uploads (`#505 `_). Other ----- - Update INSTALL.txt (`#484 `_). Contributors ------------ 6 authors added to this release (alphabetically): - `@dependabot[bot] `_ - Eli Shalom (`@elishapiiro `_) - Jarrod Millman (`@jarrodmillman `_) - Javier Rodrigo López (`@Javiolonchelo `_) - Moamen Abdelrazek (`@moemen95 `_) - Ross Barnowski (`@rossbar `_) 3 reviewers added to this release (alphabetically): - Dan Schult (`@dschult `_) - Jarrod Millman (`@jarrodmillman `_) - Ross Barnowski (`@rossbar `_) _These lists are automatically generated, and may not be complete or may contain duplicates._ pygraphviz-pygraphviz-1.13/doc/source/release/release_1.13.rst000066400000000000000000000036731461720656100243640ustar00rootroot00000000000000pygraphviz 1.13 =============== We're happy to announce the release of pygraphviz 1.13! Bug Fixes --------- - Remove outdated pystrings.swg (`#508 `_). - Fix segfault from repr attempting to access attrs on uninitialized instance (`#520 `_). Maintenance ----------- - Remove outdated pystrings.swg (`#508 `_). - Update CI tests (`#509 `_). - Update pre-commit repos (`#510 `_). - Bump webfactory/ssh-agent from 0.8.0 to 0.9.0 (`#517 `_). - Update tests for macOS Sonoma v14 (`#525 `_). - Update doc requirements (`#526 `_). - Update pre-commit repos (`#527 `_). - Remove unnecessary pip flags (`#528 `_). - Test on fedora 40 (`#529 `_). Contributors ------------ 5 authors added to this release (alphabetically): - `@dependabot[bot] `_ - Aaron Z. (`@aaronzo `_) - Jarrod Millman (`@jarrodmillman `_) - Ross Barnowski (`@rossbar `_) - William S Fulton (`@wsfulton `_) 4 reviewers added to this release (alphabetically): - Aaron Z. (`@aaronzo `_) - Dan Schult (`@dschult `_) - Jarrod Millman (`@jarrodmillman `_) - Mridul Seth (`@MridulS `_) _These lists are automatically generated, and may not be complete or may contain duplicates._ pygraphviz-pygraphviz-1.13/doc/source/tutorial.rst000066400000000000000000000051361461720656100225210ustar00rootroot00000000000000Tutorial ======== The API is very similar to that of NetworkX. Much of the NetworkX tutorial at https://networkx.org/documentation/latest/tutorial.html is applicable to PyGraphviz. Start-up -------- Import PyGraphviz with >>> import pygraphviz as pgv 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 initializing 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-pygraphviz-1.13/examples/000077500000000000000000000000001461720656100176705ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/examples/README.txt000066400000000000000000000001261461720656100213650ustar00rootroot00000000000000.. _examples_gallery: Gallery ======= Graph visualization examples with pygraphviz. pygraphviz-pygraphviz-1.13/examples/miles_dat.txt.gz000066400000000000000000000474141461720656100230230ustar00rootroot00000000000000DIFmێ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-pygraphviz-1.13/examples/plot_attributes.py000066400000000000000000000012671461720656100234740ustar00rootroot00000000000000""" Attributes ---------- Example illustrating how to set node, edge, and graph attributes for visualization. """ 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.png") # write to file pygraphviz-pygraphviz-1.13/examples/plot_miles.py000066400000000000000000000057441461720656100224230ustar00rootroot00000000000000""" Knuth Miles =========== 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 """ __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(r"^\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"{-(float(x) - 7000) / 10.0:f},{(float(y) - 2000) / 10.0:f}" ) # assign node size, in sqrt of 1,000,000's of people d = math.sqrt(float(pop) / 1000000.0) n.attr["height"] = f"{d / 2}" n.attr["width"] = f"{d / 2}" # assign node color n.attr["fillcolor"] = f"#0000{int(d * 256):2x}" # 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-pygraphviz-1.13/examples/plot_simple.py000066400000000000000000000012661461720656100225760ustar00rootroot00000000000000""" Basic ===== 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. __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 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 pygraphviz-pygraphviz-1.13/examples/plot_star.py000066400000000000000000000016701461720656100222550ustar00rootroot00000000000000""" Star ==== 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. __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(1, 16): A.add_edge(0, i) n = A.get_node(i) n.attr["fillcolor"] = f"#{i * 16:2x}0000" n.attr["height"] = f"{i / 16.0 + 0.5}" n.attr["width"] = f"{i / 16.0 + 0.5}" print(A.string()) # print to screen A.write("star.dot") # write to simple.dot A.draw("star.png", prog="circo") # draw to png using circo layout pygraphviz-pygraphviz-1.13/examples/plot_subgraph.py000066400000000000000000000007041461720656100231140ustar00rootroot00000000000000""" Subgraph ======== Specify a subgraph in pygraphviz. """ 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 A.draw("subgraph.png", prog="neato") pygraphviz-pygraphviz-1.13/examples/skip_django_simple.py000066400000000000000000000023241461720656100241040ustar00rootroot00000000000000#!/usr/bin/env python """ 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. __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-pygraphviz-1.13/examples/skip_utf8_encoding.py000066400000000000000000000014401461720656100240230ustar00rootroot00000000000000""" Example showing use of unicode and UTF-8 encoding. """ 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-pygraphviz-1.13/pygraphviz/000077500000000000000000000000001461720656100202555ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/pygraphviz/__init__.py000066400000000000000000000015301461720656100223650ustar00rootroot00000000000000""" PyGraphviz ========== A Python wrapper for the graphviz Agraph data structure. See https://pygraphviz.github.io for complete documentation. See pygraphviz.AGraph for detailed documentation. """ import sys # https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew if sys.version_info >= (3, 8, 0) and sys.platform == "win32": import os for path in os.environ["PATH"].split(os.pathsep): if "graphviz" in path.lower() and os.path.exists(path): os.add_dll_directory(path) __version__ = "1.13" from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError __all__ = ["AGraph", "Node", "Edge", "Attribute", "ItemAttribute", "DotError"] from . import testing # Per contract with Sphinx-Gallery, this method must be available at top level from pygraphviz.scraper import _get_sg_image_scraper del sys pygraphviz-pygraphviz-1.13/pygraphviz/agraph.py000066400000000000000000002105071461720656100220760ustar00rootroot00000000000000""" A Python interface to Graphviz. """ import os import re import shlex import subprocess import sys import threading import warnings from collections.abc import MutableMapping import tempfile import io from . import graphviz as gv _DEFAULT_ENCODING = "UTF-8" 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: find, create = 0, 1 class DotError(ValueError): """Dot data parsing error""" class AGraph: """Class for Graphviz agraph type. Example use >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G = pgv.AGraph(directed=True) >>> G = pgv.AGraph("file.dot") # doctest: +SKIP Graphviz graph keyword parameters are processed so you may add them like >>> G = pgv.AGraph(landscape="true", ranksep="0.1") or alternatively >>> G = pgv.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 = pgv.AGraph(d) >>> s = A.to_string() >>> B = pgv.AGraph(s) >>> h = B.handle >>> C = pgv.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 self._owns_handle = True # 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.pop("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 isinstance(thing, str): pattern = re.compile(r"(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 elif hasattr(thing, "open"): filename = thing # assume this is a file name (in a path obj) else: raise TypeError(f"Unrecognized input {thing}") if handle is not None: # if handle was specified, reference it self.handle = handle self._owns_handle = False 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 if type(item) is not bytes else item.decode("utf-8") ) 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(f"Graph name must be a string: {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) # 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): pass def __str__(self): return self.string() def __repr__(self): if self.handle is None: return super().__repr__() if (name := gv.agnameof(self.handle)) is None: return f"" return f"" def _svg_repr(self): return self.draw(format="svg").decode(self.encoding) def _repr_mimebundle_(self, include=None, exclude=None): if self.has_layout: repr_dict = {"image/svg+xml": self._svg_repr()} else: repr_dict = {"text/plain": self.__repr__()} return repr_dict def __eq__(self, other): # two graphs are equal if they have exact same nodes and edges # and attributes. This is not graph isomorphism. if sorted(self.nodes()) != sorted(other.nodes()): return False if sorted(self.edges()) != sorted(other.edges()): return False # check attributes self_all_nodes_attr = {n: n.attr.to_dict() for n in sorted(self.nodes_iter())} other_all_nodes_attr = {n: n.attr.to_dict() for n in sorted(other.nodes_iter())} if self_all_nodes_attr != other_all_nodes_attr: return False self_all_edges_attr = {e: e.attr.to_dict() for e in sorted(self.edges_iter())} other_all_edges_attr = {e: e.attr.to_dict() for e in sorted(other.edges_iter())} if self_all_edges_attr != other_all_edges_attr: return False # All checks pass. They are equal return True def __hash__(self): # include nodes and edges in hash # Could do attributes too, but hash should be fast return hash( ( tuple(sorted(self.nodes_iter())), tuple(sorted(self.edges_iter())), ) ) 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 __del__(self): self._close_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) 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). >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_node("a") >>> G.nodes() ['a'] >>> G.add_node(1) # will be converted to a string >>> G.nodes() ['a', '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 isinstance(n, str): 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 >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> nlist = ["a", "b", 1, "spam"] >>> G.add_nodes_from(nlist) >>> sorted(G.nodes()) ['1', 'a', 'b', '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. >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_node("a") >>> G.remove_node("a") """ if not isinstance(n, str): 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(f"Node {n.decode(self.encoding)} not in graph.") 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 >>> import pygraphviz as pgv >>> G = pgv.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) try: nh = gv.agnxtnode(self.handle, nh) except StopIteration: return 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. >>> import pygraphviz as pgv >>> G = pgv.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. >>> import pygraphviz as pgv >>> G = pgv.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). >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edge("a", "b") >>> G.edges() [('a', '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 = pgv.AGraph(strict=False) >>> G.add_edge("a", "b", "first") >>> G.add_edge("a", "b", "second") >>> sorted(G.edges(keys=True)) [('a', 'b', 'first'), ('a', 'b', '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 isinstance(key, str): 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. >>> import pygraphviz as pgv >>> G = pgv.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). >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edge("a", "b") >>> edge = G.get_edge("a", "b") >>> print(edge) ('a', '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(f"Edge {u}-{v} not in graph.") 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. >>> import pygraphviz as pgv >>> G = pgv.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. >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edge("a", "b") >>> G.add_edge("c", "d") >>> print(sorted(G.edges())) [('a', 'b'), ('c', 'd')] >>> print(G.edges("a")) [('a', '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. >>> import pygraphviz as pgv >>> G = pgv.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) try: eh = gv.agnxtedge(self.handle, eh, nh) except StopIteration: return 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 try: eh = gv.agnxtout(self.handle, eh) except StopIteration: break try: nh = gv.agnxtnode(self.handle, nh) except StopIteration: return 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 try: eh = gv.agnxtout(self.handle, eh) except StopIteration: return 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 try: eh = gv.agnxtout(self.handle, eh) except StopIteration: break 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 try: eh = gv.agnxtin(self.handle, eh) except StopIteration: break try: nh = gv.agnxtnode(self.handle, nh) except StopIteration: return 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 try: eh = gv.agnxtin(self.handle, eh) except StopIteration: break 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 try: eh = gv.agnxtin(self.handle, eh) except StopIteration: break 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) try: eh = gv.agnxtin(self.handle, eh) except StopIteration: return 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) try: eh = gv.agnxtout(self.handle, eh) except StopIteration: return 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 pairs of (node,degree). """ for n in self._prepare_nbunch(nbunch): 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 pairs 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 pairs 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)) 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 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 self._close_handle() self.handle = gv.agraphnew(name, strict, directed) self._owns_handle = True self._update_handle_references() def close(self): self._close_handle() def _close_handle(self): # may be useful to clean up graphviz data # this should completely remove all of the existing graphviz data if self._owns_handle: if self.handle is not None: gv.agclose(self.handle) self.handle = None self._owns_handle = False else: self.handle = None def copy(self): """Return a copy of the graph. Notes ===== Versions <=1.6 made a copy by writing and the reading a dot string. This version loads a new graph with nodes, edges and attributes. """ G = self.__class__( directed=self.is_directed(), strict=self.strict, name=self.name ) for node in self.nodes(): G.add_node(node) G.get_node(node).attr.update(self.get_node(node).attr) for edge in self.edges(keys=True): G.add_edge(*edge) G.get_edge(*edge).attr.update(self.get_edge(*edge).attr) G.graph_attr.update(self.graph_attr) G.node_attr.update(self.node_attr) G.edge_attr.update(self.edge_attr) return G 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( f"Subgraph name must be a string: {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(f"Subgraph name must be a string: {name}") if handle is None: raise KeyError(f"Subgraph {name} not in graph.") 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(f"Subgraph name must be a string: {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 ) try: handle = gv.agnxtsubg(handle) except StopIteration: return 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: self._close_handle() try: self.handle = gv.agread(fh, None) except ValueError: raise DotError("Invalid Input") else: self._owns_handle = True self._update_handle_references() except OSError: print("IO error reading file") finally: if hasattr(fh, "close") and not hasattr(path, "write"): fh.close() 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") # NOTE: TemporaryFile objects are not instances of IOBase on windows. if not isinstance(fh, (io.IOBase, tempfile._TemporaryFileWrapper)): raise TypeError(f"{fh} is not a file handle") try: gv.agwrite(self.handle, fh) except OSError: print("IO error writing file") finally: if hasattr(fh, "close") and not hasattr(path, "write"): fh.close() 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 representation of graph in dot format. `to_string()` uses "agwrite" to produce "dot" format w/o rendering. The function `string_nop()` layouts with "nop" and renders to "dot". """ fh = tempfile.TemporaryFile() 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 >>> import pygraphviz as pgv >>> s = "digraph {1 -> 2}" >>> A = pgv.AGraph() >>> t = A.from_string(s) >>> A = pgv.AGraph(string=s) # specify s is a string >>> A = pgv.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) 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", "osage", "patchwork", "gc", "acyclic", "gvpr", "gvcolor", "ccomps", "sccmap", "tred", "sfdp", "unflatten", } if prog not in progs: raise ValueError(f"Program {prog} is not one of: {', '.join(progs)}.") try: # user must pick one of the graphviz programs... runprog = self._which(prog) except: raise ValueError(f"Program {prog} not found in path.") return runprog def _run_prog(self, prog="nop", args=""): """Apply graphviz program to graph and return the result as a string. >>> import pygraphviz as pgv >>> A = pgv.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() p.wait() if not data: raise OSError(b"".join(errors).decode(self.encoding)) if len(errors) > 0: warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning) return b"".join(data) def unflatten(self, args=""): """Adjust directed graphs to improve layout aspect ratio. >>> import pygraphviz as pgv >>> A = pgv.AGraph() >>> A_unflattened = A.unflatten("-f -l 3") >>> A.unflatten("-f -l 1").layout() Use keyword args to add additional arguments to graphviz programs. """ data = self._run_prog("unflatten", args) self.from_string(data) return self def tred(self, args="", copy=False): """Transitive reduction of graph. Modifies existing graph. To create a new graph use >>> import pygraphviz as pgv >>> A = pgv.AGraph(directed=True) >>> B = A.tred(copy=True) # doctest: +SKIP See the graphviz "tred" program for details of the algorithm. """ if not self.directed: raise TypeError("tred requires a directed graph") data = self._run_prog("tred", args) if copy: return self.__class__(string=data.decode(self.encoding)) 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 >>> import pygraphviz as pgv >>> A = pgv.AGraph(directed=True) >>> B = A.acyclic(copy=True) # doctest: +SKIP See the graphviz "acyclic" program for details of the algorithm. """ if not self.directed: raise TypeError("acyclic requires a directed graph") data = self._run_prog("acyclic", args) if copy: return self.__class__(string=data.decode(self.encoding)) else: return self.from_string(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. >>> import pygraphviz as pgv >>> A = pgv.AGraph() >>> A.add_edge(1, 2) >>> A.layout() >>> A.layout(prog="neato", args="-Nshape=box -Efontsize=8") Use keyword args to add additional arguments to graphviz programs. The layout might take a long time on large graphs. """ output_fmt = "dot" data = self._run_prog(prog, " ".join([args, "-T", output_fmt])) self.from_string(data) self.has_layout = True return def _layout(self, prog="neato", args=""): """Assign positions to nodes in graph. .. caution:: EXPERIMENTAL This version of the layout command uses libgvc for layout instead of command line GraphViz tools like in versions <1.6 and the default. Optional prog=['neato'|'dot'|'twopi'|'circo'|'fdp'|'nop'] will use specified graphviz layout method. >>> import pygraphviz as pgv >>> A = pgv.AGraph() >>> A.add_edge(1, 2) >>> A.layout() >>> A.layout(prog="neato", args="-Nshape=box -Efontsize=8") Use keyword args to add additional arguments to graphviz programs. The layout might take a long time on large graphs. Note: attaching positions in the AGraph usually doesn't affect the next rendering. The positions are recomputed. But if you use prog="nop" when rendering, it will take node positions from the AGraph attributes. If you use prog="nop2" it will take node and edge positions from the AGraph when rendering. """ _, prog = self._manually_parse_args(args, None, prog) # convert input strings to type bytes (encode it) if isinstance(prog, str): prog = prog.encode(self.encoding) gvc = gv.gvContext() gv.gvLayout(gvc, self.handle, prog) gv.gvRender(gvc, self.handle, format=b"dot", output_file=None) gv.gvFreeLayout(gvc, self.handle) gv.gvFreeContext(gvc) self.has_layout = True return 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'. If path is None, the result is returned as a Bytes object. 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. >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edges_from([(0, 1), (1, 2), (2, 0), (2, 3)]) >>> G.layout() # use current node positions, output pdf in 'file.pdf' >>> G.draw("file.pdf") # 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.pdf", prog="twopi", args="-Gepsilon=1") >>> G.draw("test2.pdf", args="-Nshape=box -Edir=forward -Ecolor=red ") The layout might take a long time on large graphs. """ # 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 isinstance(p, str): 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 isinstance(path, str): fh.close() d = None else: d = data return d def _draw(self, path=None, format=None, prog=None, args=""): """Output graph to path in specified format. .. caution:: EXPERIMENTAL This version of the draw command uses libgvc for drawing instead of command line GraphViz tools like in versions <1.6 and the default. 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'. If path is None, the result is returned as a Bytes object. 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. >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edges_from([(0, 1), (1, 2), (2, 0), (2, 3)]) >>> G.layout() # use current node positions, output pdf in 'file.pdf' >>> G.draw("file.pdf") # 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.pdf", prog="twopi", args="-Gepsilon=1") >>> G.draw("test2.pdf", args="-Nshape=box -Edir=forward -Ecolor=red ") The layout might take a long time on large graphs. """ # 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 isinstance(p, str): 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() ) # process args format, prog = self._manually_parse_args(args, format, prog) # convert input strings to type bytes (encode it) if isinstance(format, str): format = format.encode(self.encoding) if isinstance(prog, str): prog = prog.encode(self.encoding) # Start the drawing gvc = gv.gvContext() G = self.handle # Layout err = gv.gvLayout(gvc, G, prog) if err: if err != -1: raise ValueError("Graphviz raised a layout error.") prog = prog.decode(self.encoding) raise ValueError(f"Can't find prog={prog} in this graphviz installation") # Render if path is None: out = gv.gvRenderData(gvc, G, format) if out[0]: raise ValueError(f"Graphviz Error creating dot representation:{out[0]}") err, dot_string = out gv.gvFreeLayout(gvc, G) gv.gvFreeContext(gvc) return dot_string # path is string holding the filename, a file handle, or pathlib.Path fh = self._get_fh(path, "wb") err = gv.gvRender(gvc, G, format, fh) if err: raise ValueError("Graphviz raised a render error. Maybe bad format?") if isinstance(path, str): fh.close() gv.gvFreeLayout(gvc, G) gv.gvFreeContext(gvc) # some private helper functions def _manually_parse_args(self, args, format=None, prog=None): """Experimental code to parse args relevant for libgvc drawing and layout""" arg_list = shlex.split(args) for arg in arg_list: value = arg[2:] if arg[:2] == "-T": if format and format != value: raise ValueError("format doesnt match in args and format inputs") format = value if arg[:2] == "-K": if prog and prog != value: prog = value # raise ValueError("prog doesnt match in args and prog inputs") prog = value if arg[:2] == "-G": key, val = value.split("=") self.graph_attr[key] = val if arg[:2] == "-N": key, val = value.split("=") self.node_attr[key] = val if arg[:2] == "-E": key, val = value.split("=") self.edge_attr[key] = val return format, prog def _get_fh(self, path, mode="r"): """Return a file handle for given path. Path can be a string, pathlib.Path, or a file handle. Attempt to uncompress/compress files ending in '.gz' and '.bz2'. """ import os if isinstance(path, str): 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 elif hasattr(path, "open"): fh = path.open(mode=mode) else: raise TypeError("path must be a string, path, or file handle.") return fh def _which(self, name): """Searches for name in exec path and returns full path""" import glob import platform if platform.system() == "Windows": name += ".exe" paths = os.environ["PATH"] for path in paths.split(os.pathsep): match = glob.glob(os.path.join(path, name)) if match: return match[0] raise ValueError(f"No prog {name} in path.") def _update_handle_references(self): try: self.graph_attr.handle = self.handle self.node_attr.handle = self.handle self.edge_attr.handle = self.handle except AttributeError: pass # ignore as likely still in __init__() class Node(str): """Node object based on unicode. If G is a graph >>> import pygraphviz as pgv >>> G = pgv.AGraph() then >>> G.add_node(1) will create a node object labeled by the string "1". To get the object use >>> node = pgv.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().__new__(self, gv.agnameof(nh), graph.encoding) else: n = super().__new__(self, name) try: nh = gv.agnode(graph.handle, n.encode(graph.encoding), _Action.find) except KeyError: raise KeyError(f"Node {n} not in graph.") 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 >>> import pygraphviz as pgv >>> G = pgv.AGraph() then >>> G.add_edge(1, 2) will add the edge 1-2 to the graph. >>> edge = pgv.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 = pgv.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 isinstance(key, str): 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(f"Edge {source}-{target} not in graph.") 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(MutableMapping): """Default attributes for graphs. Assigned on initialization of AGraph class. and manipulated through the class data. >>> import pygraphviz as pgv >>> G = pgv.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: item = gv.agattrdefval(gv.agattr(root_handle, 0, b"charset", None)) self.encoding = item if type(item) is not bytes else item.decode("utf-8") 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 isinstance(value, str): 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(list(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 except StopIteration: # gv.agnxtattr is done, as are we return class ItemAttribute(Attribute): """Attributes for individual nodes and edges. Assigned on initialization of Node or Edge classes and manipulated through the class data. >>> import pygraphviz as pgv >>> G = pgv.AGraph() >>> G.add_edge("a", "b") >>> n = pgv.Node(G, "a") >>> n.attr["shape"] = "circle" >>> e = pgv.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: item = gv.agattrdefval(gv.agattr(root_handle, 0, b"charset", None)) self.encoding = item if type(item) is not bytes else item.decode("utf-8") except KeyError: self.encoding = _DEFAULT_ENCODING def __setitem__(self, name, value): if not isinstance(value, str): 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 except StopIteration: # gv.agnxtattr is done, as are we return def to_dict(self): ah = None attrdict = {} while 1: try: ah = gv.agnxtattr(self.ghandle, self.type, ah) except StopIteration: # gv.agnxtattr is done, as are we break key = gv.agattrname(ah).decode(self.encoding) value = gv.agxget(self.handle, ah).decode(self.encoding) attrdict[key] = value return attrdict pygraphviz-pygraphviz-1.13/pygraphviz/graphviz.i000066400000000000000000000226541461720656100222720ustar00rootroot00000000000000%module graphviz %begin %{ #define SWIG_PYTHON_STRICT_BYTE_CHAR %} %{ #include "graphviz/cgraph.h" #include "graphviz/gvc.h" %} %typemap(in) FILE* input_file (int fd, PyObject *mode_obj, PyObject *mode_byte_obj, char *mode) { if ($input == Py_None) { $1 = NULL; } else { // 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(dup(fd), mode); Py_XDECREF(mode_obj); Py_XDECREF(mode_byte_obj); } } %typemap(in) FILE* output_file (int fd, PyObject *mode_obj, PyObject *mode_byte_obj, char *mode) { if ($input == Py_None) { $1 = NULL; } else { // 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); } } %typemap(freearg) FILE* input_file { fclose($1); } %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 *input_file, Agdisc_t *); int agwrite(Agraph_t *g, FILE *output_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 %{ Agsym_t *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 */ /**************** GVC ******************/ /* Could do the whole gvc.h file here. */ /* But gvParseArgs code is "a mess" (their comment in source code) */ /* It uses global variables to set default attributes */ /* It doesn't update current nodes with these defaults yet it sets */ /* any future nodes to these defaults even if in a different graph */ /* and a different gvContext. */ /* The result is that you can set a default for one graph and it doesnt */ /* do anything to that graph, but then all future graphs have that default */ // /* This code only uses a small portion of the libgvc functions. */ /* The focus is on layout and render operations. */ /* set up a graphviz context - and init graph - retaining old API */ GVC_t *gvContext(void); int gvFreeContext(GVC_t *gvc); /* Compute a layout using a specified engine */ int gvLayout(GVC_t *gvc, Agraph_t *g, char* prog); int gvFreeLayout(GVC_t *gvc, Agraph_t *g); /* Render layout in a specified format to an open FILE */ int gvRender(GVC_t *gvc, Agraph_t* g, char *format, FILE *output_file=NULL); int gvRenderFilename(GVC_t *gvc, Agraph_t* g, char *format, char *filename); /* Render layout in a specified format to an external context */ /*-------------------------------------------------------------*/ /* Writing a dot file to a string involves some pointer crazy stuff */ /* (the input strings are changed by the function... this magic makes */ /* python return the strings instead of changing the input. The next */ /* three lines are straight from the SWIG manual. */ %include %include %cstring_output_allocate_size(char **result, unsigned int* size, free(*$1)); int gvRenderData(GVC_t *gvc, Agraph_t* g, char *format, char **result, unsigned int *size); /* Free memory allocated and pointed to by *result in gvRenderData */ extern void gvFreeRenderData (char* data); pygraphviz-pygraphviz-1.13/pygraphviz/graphviz.py000066400000000000000000000153301461720656100224630ustar00rootroot00000000000000# This file was automatically generated by SWIG (https://www.swig.org). # Version 4.1.1 # # 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 as _swig_python_version_info # Import the low-level C/C++ module if __package__ or "." in __name__: from . import _graphviz else: import _graphviz try: import builtins as __builtin__ except ImportError: import __builtin__ def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except __builtin__.Exception: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) def _swig_setattr_nondynamic_instance_variable(set): def set_instance_attr(self, name, value): if name == "this": set(self, name, value) elif name == "thisown": self.this.own(value) elif hasattr(self, name) and isinstance(getattr(type(self), name), property): set(self, name, value) else: raise AttributeError("You cannot add instance attributes to %s" % self) return set_instance_attr def _swig_setattr_nondynamic_class_variable(set): def set_class_attr(cls, name, value): if hasattr(cls, name) and not isinstance(getattr(cls, name), property): set(cls, name, value) else: raise AttributeError("You cannot add class attributes to %s" % cls) return set_class_attr def _swig_add_metaclass(metaclass): """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" def wrapper(cls): return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) return wrapper class _SwigNonDynamicMeta(type): """Meta class to enforce nondynamic attributes (no new attributes) for a class""" __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) def agopen(name, kind, disc): return _graphviz.agopen(name, kind, disc) 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(g): return _graphviz.agclose(g) def agread(input_file, arg2): return _graphviz.agread(input_file, arg2) def agwrite(g, output_file): return _graphviz.agwrite(g, output_file) def agisundirected(g): return _graphviz.agisundirected(g) def agisdirected(g): return _graphviz.agisdirected(g) def agisstrict(g): return _graphviz.agisstrict(g) def agnode(g, name, createflag): return _graphviz.agnode(g, name, createflag) def agidnode(g, id, createflag): return _graphviz.agidnode(g, id, createflag) def agsubnode(g, n, createflag): return _graphviz.agsubnode(g, n, createflag) def agfstnode(g): return _graphviz.agfstnode(g) def agnxtnode(g, n): return _graphviz.agnxtnode(g, n) def aglstnode(g): return _graphviz.aglstnode(g) def agprvnode(g, n): return _graphviz.agprvnode(g, n) def agedge(g, t, h, name, createflag): return _graphviz.agedge(g, t, h, name, createflag) def agidedge(g, t, h, id, createflag): return _graphviz.agidedge(g, t, h, id, createflag) def agsubedge(g, e, createflag): return _graphviz.agsubedge(g, e, createflag) def agfstin(g, n): return _graphviz.agfstin(g, n) def agnxtin(g, e): return _graphviz.agnxtin(g, e) def agfstout(g, n): return _graphviz.agfstout(g, n) def agnxtout(g, e): return _graphviz.agnxtout(g, e) def agfstedge(g, n): return _graphviz.agfstedge(g, n) def agnxtedge(g, e, n): return _graphviz.agnxtedge(g, e, n) def aghead(e): return _graphviz.aghead(e) def agtail(e): return _graphviz.agtail(e) def agattr(g, kind, name, value): return _graphviz.agattr(g, kind, name, value) def agattrsym(obj, name): return _graphviz.agattrsym(obj, name) def agnxtattr(g, kind, attr): return _graphviz.agnxtattr(g, kind, attr) def agget(obj, name): return _graphviz.agget(obj, name) def agxget(obj, sym): return _graphviz.agxget(obj, sym) def agset(obj, name, value): return _graphviz.agset(obj, name, value) def agxset(obj, sym, value): return _graphviz.agxset(obj, sym, value) def agsafeset(obj, name, value, _def): return _graphviz.agsafeset(obj, name, value, _def) def agattrname(atsym): return _graphviz.agattrname(atsym) def agattrdefval(atsym): return _graphviz.agattrdefval(atsym) def agsafeset_label(g, obj, name, val, _def): return _graphviz.agsafeset_label(g, obj, name, val, _def) def agattr_label(g, kind, name, val): return _graphviz.agattr_label(g, kind, name, val) def agsubg(g, name, createflag): return _graphviz.agsubg(g, name, createflag) def agfstsubg(g): return _graphviz.agfstsubg(g) def agnxtsubg(subg): return _graphviz.agnxtsubg(subg) def agparent(g): return _graphviz.agparent(g) def agroot(g): return _graphviz.agroot(g) def agdelsubg(g, sub): return _graphviz.agdelsubg(g, sub) def agnnodes(g): return _graphviz.agnnodes(g) def agnedges(g): return _graphviz.agnedges(g) def agdegree(g, n, _in, out): return _graphviz.agdegree(g, n, _in, out) def agraphof(arg1): return _graphviz.agraphof(arg1) def agnameof(arg1): return _graphviz.agnameof(arg1) def agdelnode(g, arg_n): return _graphviz.agdelnode(g, arg_n) def agdeledge(g, arg_e): return _graphviz.agdeledge(g, arg_e) 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 def gvContext(): return _graphviz.gvContext() def gvFreeContext(gvc): return _graphviz.gvFreeContext(gvc) def gvLayout(gvc, g, prog): return _graphviz.gvLayout(gvc, g, prog) def gvFreeLayout(gvc, g): return _graphviz.gvFreeLayout(gvc, g) def gvRender(gvc, g, format, output_file=None): return _graphviz.gvRender(gvc, g, format, output_file) def gvRenderFilename(gvc, g, format, filename): return _graphviz.gvRenderFilename(gvc, g, format, filename) def gvRenderData(gvc, g, format): return _graphviz.gvRenderData(gvc, g, format) def gvFreeRenderData(data): return _graphviz.gvFreeRenderData(data) cvar = _graphviz.cvar Agdirected = cvar.Agdirected Agstrictdirected = cvar.Agstrictdirected Agundirected = cvar.Agundirected Agstrictundirected = cvar.Agstrictundirected pygraphviz-pygraphviz-1.13/pygraphviz/graphviz_wrap.c000066400000000000000000005603301461720656100233130ustar00rootroot00000000000000/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (https://www.swig.org). * Version 4.1.1 * * Do not make changes to this file unless you know what you are doing - modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ #define SWIG_PYTHON_STRICT_BYTE_CHAR #define SWIG_VERSION 0x040101 #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 defined(__GNUC__) # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif # 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 /* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 #endif /* Intel's compiler complains if a variable which was never initialised is * cast to void, which is a common idiom which we use to indicate that we * are aware a variable isn't used. So we just silence that warning. * See: https://github.com/swig/swig/issues/192 for more discussion. */ #ifdef __INTEL_COMPILER # pragma warning disable 592 #endif #if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) /* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ # include #endif #if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN) #define PY_SSIZE_T_CLEAN #endif #if __GNUC__ >= 7 #pragma GCC diagnostic push #if defined(__cplusplus) && __cplusplus >=201703L #pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */ #endif #endif #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ #if defined(_MSC_VER) && _MSC_VER >= 1929 /* Workaround compilation errors when redefining _DEBUG in MSVC 2019 version 16.10 and later * See https://github.com/swig/swig/issues/2090 */ # include #endif # undef _DEBUG # include # define _DEBUG 1 #else # include #endif #if __GNUC__ >= 7 #pragma GCC diagnostic pop #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 #define SWIG_POINTER_NO_NULL 0x4 #define SWIG_POINTER_CLEAR 0x8 #define SWIG_POINTER_RELEASE (SWIG_POINTER_CLEAR | SWIG_POINTER_DISOWN) /* 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 returning 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) /* Runtime errors are < 0 */ #define SWIG_ERROR (-1) /* Errors in range -1 to -99 are in swigerrors.swg (errors for all languages including those not using the runtime) */ /* Errors in range -100 to -199 are language specific errors defined in *errors.swg */ /* Errors < -200 are generic runtime specific errors */ #define SWIG_ERROR_RELEASE_NOT_OWNED (-200) #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 object 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(const 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. Choose the last name. It should be the most specific; a fully resolved name but not necessarily with default template parameters expanded. */ 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 = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (unsigned char)(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 /* SWIG Errors applicable to all language modules, values are reserved from -1 to -99 */ #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 _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 SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03030000 return (char *)PyUnicode_AsUTF8(str); #else return PyString_AsString(str); #endif } /* Was useful for Python 3.0.x-3.2.x - now provided only for compatibility * with any uses in user interface files. */ #define SWIG_Python_str_DelForPy3(x) SWIGINTERN PyObject* SWIG_Python_str_FromChar(const char *c) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromString(c); #else return PyString_FromString(c); #endif } #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */ # define SWIGPY_USE_CAPSULE #ifdef SWIGPYTHON_BUILTIN # define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule_builtin" SWIG_TYPE_TABLE_NAME #else # define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule" SWIG_TYPE_TABLE_NAME #endif # define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION "." SWIGPY_CAPSULE_ATTR_NAME) #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) #define Py_hash_t long #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) { PyObject *old_str = PyObject_Str(value); const char *tmp = SWIG_Python_str_AsChar(old_str); PyErr_Clear(); Py_XINCREF(type); if (tmp) PyErr_Format(type, "%s %s", tmp, mesg); else PyErr_Format(type, "%s", mesg); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } SWIGRUNTIME int SWIG_Python_TypeErrorOccurred(PyObject *obj) { PyObject *error; if (obj) return 0; error = PyErr_Occurred(); return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); } SWIGRUNTIME void SWIG_Python_RaiseOrModifyTypeError(const char *message) { if (SWIG_Python_TypeErrorOccurred(NULL)) { /* Use existing TypeError to preserve stacktrace and enhance with given message */ PyObject *newvalue; PyObject *type = NULL, *value = NULL, *traceback = NULL; PyErr_Fetch(&type, &value, &traceback); #if PY_VERSION_HEX >= 0x03000000 newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); #else newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); #endif if (newvalue) { Py_XDECREF(value); PyErr_Restore(type, newvalue, traceback); } else { PyErr_Restore(type, value, traceback); } } else { /* Raise TypeError using given message */ PyErr_SetString(PyExc_TypeError, message); } } #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) # define SWIG_PYTHON_USE_GIL # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # if PY_VERSION_HEX < 0x03070000 # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # else # define SWIG_PYTHON_INITIALIZE_THREADS # endif # 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; const char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; #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. * * ----------------------------------------------------------------------------- */ #if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ # error "This version of SWIG only supports Python >= 2.7" #endif #if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03030000 # error "This version of SWIG only supports Python 3 >= 3.3" #endif /* 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) { PyDict_SetItemString(d, name, obj); Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); } #else SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { PyDict_SetItemString(d, name, obj); Py_DECREF(obj); } #endif /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { 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); if (result) { PyList_SET_ITEM(result, 0, o2); } else { Py_DECREF(obj); return o2; } } PyList_Append(result,obj); Py_DECREF(obj); } return result; } /* Unpack the argument tuple */ SWIGINTERN Py_ssize_t 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) { Py_ssize_t 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 { Py_ssize_t i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } SWIGINTERN int SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { int no_kwargs = 1; if (kwargs) { assert(PyDict_Check(kwargs)); if (PyDict_Size(kwargs) > 0) { PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); no_kwargs = 0; } } return no_kwargs; } /* A functor is a function object with one single object argument */ #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); /* 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 #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(PyObject *SWIGUNUSEDPARM(v)) { #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_InternFromString(""); #else return PyString_FromString(""); #endif } SWIGINTERN PyObject * swig_varlink_str(PyObject *o) { swig_varlinkobject *v = (swig_varlinkobject *) o; #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 void swig_varlink_dealloc(PyObject *o) { swig_varlinkobject *v = (swig_varlinkobject *) o; swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(PyObject *o, char *n) { swig_varlinkobject *v = (swig_varlinkobject *) o; 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(PyObject *o, char *n, PyObject *p) { swig_varlinkobject *v = (swig_varlinkobject *) o; 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 = { #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 (printfunc)0, /*tp_print*/ #else (Py_ssize_t)0, /*tp_vectorcall_offset*/ #endif (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 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ 0, /* tp_del */ 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ 0, /* tp_prev */ 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; if (PyType_Ready(&varlink_type) < 0) return NULL; } 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, const 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) { memcpy(gv->name, name, size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } static PyObject *Swig_Globals_global = NULL; SWIGINTERN PyObject * SWIG_globals(void) { if (Swig_Globals_global == NULL) { Swig_Globals_global = SWIG_newvarlink(); } return Swig_Globals_global; } #ifdef __cplusplus } #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 /* 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; int fail = data ? data->implicitconv : 0; if (fail) PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); return fail; } 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; Py_INCREF(obj); data->newargs = obj; } else { data->newraw = PyObject_GetAttrString(data->klass, "__new__"); if (data->newraw) { data->newargs = PyTuple_New(1); if (data->newargs) { Py_INCREF(obj); PyTuple_SET_ITEM(data->newargs, 0, obj); } else { Py_DECREF(data->newraw); Py_DECREF(data->klass); free(data); return 0; } } else { Py_INCREF(obj); data->newargs = obj; } } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O); } else { data->delargs = 0; } data->implicitconv = 0; data->pytype = 0; return data; } } SWIGRUNTIME void SwigPyClientData_Del(SwigPyClientData *data) { Py_XDECREF(data->klass); Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); free(data); } /* =============== SwigPyObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; #ifdef SWIGPYTHON_BUILTIN PyObject *dict; #endif } SwigPyObject; #ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME PyObject * SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *)v; if (!sobj->dict) sobj->dict = PyDict_New(); Py_XINCREF(sobj->dict); return sobj->dict; } #endif 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) { PyObject *val = SwigPyObject_long(v); if (val) { PyObject *ofmt; PyTuple_SET_ITEM(args, 0, val); 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 * SwigPyObject_repr(SwigPyObject *v) { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (repr && v->next) { PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); if (nrep) { # 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 } else { Py_DecRef(repr); repr = NULL; } } return repr; } /* We need a version taking two PyObject* parameters so it's a valid * PyCFunction to use in swigobject_methods[]. */ SWIGRUNTIME PyObject * SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { return SwigPyObject_repr((SwigPyObject*)v); } 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); static PyObject* Swig_Capsule_global = NULL; 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; /* PyObject_CallFunction() has the potential to silently drop the active exception. In cases of unnamed temporary variable or where we just finished iterating over a generator StopIteration will be active right now, and this needs to remain true upon return from SwigPyObject_dealloc. So save and restore. */ PyObject *type = NULL, *value = NULL, *traceback = NULL; PyErr_Fetch(&type, &value, &traceback); if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); if (tmp) { res = SWIG_Python_CallFunctor(destroy, tmp); } else { res = 0; } Py_XDECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } if (!res) PyErr_WriteUnraisable(destroy); PyErr_Restore(type, value, traceback); 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(Swig_Capsule_global); } Py_XDECREF(next); #ifdef SWIGPYTHON_BUILTIN Py_XDECREF(sobj->dict); #endif PyObject_DEL(v); } SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; if (!SwigPyObject_Check(next)) { PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; } ((SwigPyObject *)next)->next = sobj->next; sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) { 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 (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { return NULL; } else { SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { if (PyObject_IsTrue(val)) { Py_DECREF(SwigPyObject_acquire(v,args)); } else { Py_DECREF(SwigPyObject_disown(v,args)); } } return obj; } } static PyMethodDef swigobject_methods[] = { {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, {0, 0, 0, 0} }; 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 >= 0x03050000 /* 3.5 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ #elif 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 */ #else 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #endif }; static PyTypeObject swigpyobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { #if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 (printfunc)0, /*tp_print*/ #else (Py_ssize_t)0, /*tp_vectorcall_offset*/ #endif (getattrfunc)0, /* tp_getattr */ (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 */ 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 */ 0, /* tp_del */ 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ 0, /* tp_prev */ 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; if (PyType_Ready(&swigpyobject_type) != 0) return NULL; } 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; #ifdef SWIGPYTHON_BUILTIN sobj->dict = 0; #endif if (own == SWIG_POINTER_OWN) { /* Obtain a reference to the Python capsule wrapping the module information, so that the * module information is correctly destroyed after all SWIG python objects have been freed * by the GC (and corresponding destructors invoked) */ Py_XINCREF(Swig_Capsule_global); } } 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 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((const char *)v->pack, (const 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 = { #if PY_VERSION_HEX>=0x03000000 PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif "SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ #if PY_VERSION_HEX < 0x030800b4 (printfunc)0, /*tp_print*/ #else (Py_ssize_t)0, /*tp_vectorcall_offset*/ #endif (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 */ 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 */ 0, /* tp_del */ 0, /* tp_version_tag */ #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif #if PY_VERSION_HEX >= 0x03080000 0, /* tp_vectorcall */ #endif #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ 0, /* tp_prev */ 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; if (PyType_Ready(&swigpypacked_type) != 0) return NULL; } 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 * ----------------------------------------------------------------------------- */ static PyObject *Swig_This_global = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { if (Swig_This_global == NULL) Swig_This_global = SWIG_Python_str_FromChar("this"); return Swig_This_global; } /* #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) 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 (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : 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 (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !sobj->own) { res = SWIG_ERROR_RELEASE_NOT_OWNED; } else { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } if (flags & SWIG_POINTER_CLEAR) { sobj->ptr = 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; swig_cast_info *tc; /* 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; 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; } return SWIG_OK; } } /* Convert a packed pointer 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) { 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; } if (dict) { PyDict_SetItem(dict, SWIG_This(), swig_this); } else{ Py_DECREF(inst); inst = 0; } } #else if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { Py_DECREF(inst); inst = 0; } #endif } } else { #if PY_VERSION_HEX >= 0x03000000 PyObject *empty_args = PyTuple_New(0); if (empty_args) { PyObject *empty_kwargs = PyDict_New(); if (empty_kwargs) { inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); Py_DECREF(empty_kwargs); if (inst) { if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { Py_DECREF(inst); inst = 0; } else { PyType_Modified(Py_TYPE(inst)); } } } Py_DECREF(empty_args); } #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; } SWIGRUNTIME int SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { #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; } if (dict) { return PyDict_SetItem(dict, SWIG_This(), swig_this); } else{ return -1; } } #endif return PyObject_SetAttr(inst, SWIG_This(), swig_this); } 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) { Py_DECREF(SwigPyObject_append((PyObject*) sthis, obj[1])); } else { if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) return NULL; } 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; #ifdef SWIGPYTHON_BUILTIN newobj->dict = 0; #endif } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); #ifdef SWIGPYTHON_BUILTIN if (newobj) { newobj->dict = 0; } #endif } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; 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 static PyObject *Swig_TypeCache_global = NULL; /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { if (Swig_TypeCache_global == NULL) { Swig_TypeCache_global = PyDict_New(); } return Swig_TypeCache_global; } SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { #ifdef SWIG_LINK_RUNTIME static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { type_pointer = SWIG_ReturnGlobalTypeList((void *)0); } #else void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif return (swig_module_info *) type_pointer; } static int interpreter_counter = 0; // how many (sub-)interpreters are using swig_module's types SWIGRUNTIME void SWIG_Python_DestroyModule(PyObject *obj) { swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); swig_type_info **types = swig_module->types; size_t i; if (--interpreter_counter != 0) // another sub-interpreter may still be using the swig_module's types return; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; ty->clientdata = 0; if (data) SwigPyClientData_Del(data); } } Py_DECREF(SWIG_This()); Swig_This_global = NULL; Py_DECREF(SWIG_globals()); Swig_Globals_global = NULL; Py_DECREF(SWIG_Python_TypeCache()); Swig_TypeCache_global = NULL; Swig_Capsule_global = 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("swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { ++interpreter_counter; Swig_Capsule_global = pointer; } else { Py_DECREF(pointer); } } else { Py_XDECREF(pointer); } } 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) { descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { obj = PyCapsule_New((void*) descriptor, NULL, NULL); if (obj) { 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) { PyObject *old_str = PyObject_Str(value); const char *tmp = SWIG_Python_str_AsChar(old_str); const char *errmesg = tmp ? tmp : "Invalid error message"; Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, errmesg); } else { PyErr_Format(type, "%s %s", errmesg, mesg); } 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); } 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(); } 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); if (!encoded_name) goto done; } 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) do { if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } } while (0) /* -------- 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_GVC_t swig_types[7] #define SWIGTYPE_p_char swig_types[8] #define SWIGTYPE_p_p_char swig_types[9] #define SWIGTYPE_p_unsigned_int swig_types[10] static swig_type_info *swig_types[12]; static swig_module_info swig_module = {swig_types, 11, 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) -------- */ #ifdef SWIG_TypeQuery # undef SWIG_TypeQuery #endif #define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(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 SWIG_as_voidptr(a) (void *)((const void *)(a)) #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include "graphviz/cgraph.h" #include "graphviz/gvc.h" 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 defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (PyBytes_Check(obj)) #else if (PyUnicode_Check(obj)) #endif #else if (PyString_Check(obj)) #endif { char *cstr; Py_ssize_t len; int ret = SWIG_OK; #if PY_VERSION_HEX>=0x03000000 #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError; if (alloc) *alloc = SWIG_NEWOBJ; #endif if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) return SWIG_TypeError; #else if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) return SWIG_TypeError; #endif if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); *alloc = SWIG_NEWOBJ; } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { #if PY_VERSION_HEX>=0x03000000 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) *cptr = PyBytes_AsString(obj); #else assert(0); /* Should never reach here with Unicode strings in Python 3 */ #endif #else *cptr = SWIG_Python_str_AsChar(obj); if (!*cptr) ret = SWIG_TypeError; #endif } } if (psize) *psize = len + 1; #if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) Py_XDECREF(obj); #endif return ret; } else { #if defined(SWIG_PYTHON_2_UNICODE) #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) #error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" #endif #if PY_VERSION_HEX<0x03000000 if (PyUnicode_Check(obj)) { char *cstr; Py_ssize_t len; if (!alloc && cptr) { return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError; if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { if (cptr) { if (alloc) *alloc = SWIG_NEWOBJ; *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); } if (psize) *psize = len + 1; Py_XDECREF(obj); return SWIG_OK; } else { Py_XDECREF(obj); } } #endif #endif 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; #if PY_VERSION_HEX < 0x03000000 } else if (PyInt_Check(obj)) { if (val) *val = (double) PyInt_AsLong(obj); return SWIG_OK; #endif } 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 PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else #endif if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); return SWIG_OverflowError; } } #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(); return SWIG_OverflowError; } } #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 #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); #else return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); #endif #else return PyString_FromStringAndSize(carray, (Py_ssize_t)(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); } Agsym_t *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 PyInt_FromLong #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_agopen(PyObject *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 *swig_obj[3] ; Agraph_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agopen", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[2] ; Agraph_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agread", 2, 2, swig_obj)) SWIG_fail; { if (swig_obj[0] == Py_None) { arg1 = NULL; } else { // work around to get hold of FILE* fd1 = PyObject_AsFileDescriptor(swig_obj[0]); mode_obj1 = PyObject_GetAttrString(swig_obj[0], "mode"); mode_byte_obj1 = PyUnicode_AsUTF8String(mode_obj1); mode1 = PyBytes_AsString(mode_byte_obj1); arg1 = fdopen(dup(fd1), mode1); Py_XDECREF(mode_obj1); Py_XDECREF(mode_byte_obj1); } } res2 = SWIG_ConvertPtr(swig_obj[1], &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 ); { fclose(arg1); } return resultobj; fail: { fclose(arg1); } return NULL; } SWIGINTERN PyObject *_wrap_agwrite(PyObject *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 *swig_obj[2] ; int result; if (!SWIG_Python_UnpackTuple(args, "agwrite", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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 (swig_obj[1] == Py_None) { arg2 = NULL; } else { // work around to get hold of FILE* fd2 = PyObject_AsFileDescriptor(swig_obj[1]); mode_obj2 = PyObject_GetAttrString(swig_obj[1], "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); } } result = (int)agwrite(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_agisundirected(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[3] ; Agnode_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnode", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[3] ; Agnode_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agidnode", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[3] ; Agnode_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agsubnode", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agnode_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[2] ; Agnode_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnxtnode", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agnode_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[2] ; Agnode_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agprvnode", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[5] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agedge", 5, 5, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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(swig_obj[4], &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 *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 *swig_obj[5] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agidedge", 5, 5, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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(swig_obj[4], &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 *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 *swig_obj[3] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agsubedge", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[2] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agfstin", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[2] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnxtin", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[2] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agfstout", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[2] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnxtout", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[2] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agfstedge", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[3] ; Agedge_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnxtedge", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agedge_t *arg1 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agnode_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agedge_t *arg1 = (Agedge_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agnode_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[4] ; Agsym_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agattr", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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 *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 *swig_obj[2] ; Agsym_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agattrsym", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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 *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 *swig_obj[3] ; Agsym_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agnxtattr", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[2] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agget", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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 *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 *swig_obj[2] ; char *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agxget", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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 *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 *swig_obj[3] ; int result; if (!SWIG_Python_UnpackTuple(args, "agset", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[3] ; int result; if (!SWIG_Python_UnpackTuple(args, "agxset", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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(swig_obj[2], &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 *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 *swig_obj[4] ; int result; if (!SWIG_Python_UnpackTuple(args, "agsafeset", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agsym_t *arg1 = (Agsym_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agsym_t *arg1 = (Agsym_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[5] ; int result; if (!SWIG_Python_UnpackTuple(args, "agsafeset_label", 5, 5, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1],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(swig_obj[2], &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(swig_obj[3], &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(swig_obj[4], &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 *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 *swig_obj[4] ; Agsym_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agattr_label", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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 = (Agsym_t *)agattr_label(arg1,arg2,arg3,arg4); if (!result) { PyErr_SetString(PyExc_KeyError,"agattr_label: 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_agsubg(PyObject *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 *swig_obj[3] ; Agraph_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "agsubg", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agraph_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agraph_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agraph_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; Agraph_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[2] ; long result; if (!SWIG_Python_UnpackTuple(args, "agdelsubg", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *self, PyObject *args) { PyObject *resultobj = 0; Agraph_t *arg1 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &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 *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 *swig_obj[4] ; int result; if (!SWIG_Python_UnpackTuple(args, "agdegree", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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(swig_obj[2], &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(swig_obj[3], &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 *self, PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject *swig_obj[1] ; Agraph_t *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0],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 *self, PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; int res1 ; PyObject *swig_obj[1] ; char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0],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 *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 *swig_obj[2] ; int result; if (!SWIG_Python_UnpackTuple(args, "agdelnode", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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 *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 *swig_obj[2] ; int result; if (!SWIG_Python_UnpackTuple(args, "agdeledge", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &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(swig_obj[1], &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; } SWIGINTERN PyObject *_wrap_gvContext(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *result = 0 ; if (!SWIG_Python_UnpackTuple(args, "gvContext", 0, 0, 0)) SWIG_fail; result = (GVC_t *)gvContext(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GVC_t, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gvFreeContext(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; int result; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvFreeContext" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); result = (int)gvFreeContext(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gvLayout(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; char *arg3 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; PyObject *swig_obj[3] ; int result; if (!SWIG_Python_UnpackTuple(args, "gvLayout", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvLayout" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gvLayout" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "gvLayout" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); result = (int)gvLayout(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_gvFreeLayout(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject *swig_obj[2] ; int result; if (!SWIG_Python_UnpackTuple(args, "gvFreeLayout", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvFreeLayout" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gvFreeLayout" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); result = (int)gvFreeLayout(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gvRender(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; char *arg3 = (char *) 0 ; FILE *arg4 = (FILE *) NULL ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int fd4 ; PyObject *mode_obj4 ; PyObject *mode_byte_obj4 ; char *mode4 ; PyObject *swig_obj[4] ; int result; if (!SWIG_Python_UnpackTuple(args, "gvRender", 3, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvRender" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gvRender" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "gvRender" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); if (swig_obj[3]) { { if (swig_obj[3] == Py_None) { arg4 = NULL; } else { // work around to get hold of FILE* fd4 = PyObject_AsFileDescriptor(swig_obj[3]); mode_obj4 = PyObject_GetAttrString(swig_obj[3], "mode"); mode_byte_obj4 = PyUnicode_AsUTF8String(mode_obj4); mode4 = PyBytes_AsString(mode_byte_obj4); arg4 = fdopen(fd4, mode4); Py_XDECREF(mode_obj4); Py_XDECREF(mode_byte_obj4); } } } result = (int)gvRender(arg1,arg2,arg3,arg4); 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_gvRenderFilename(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; int res4 ; char *buf4 = 0 ; int alloc4 = 0 ; PyObject *swig_obj[4] ; int result; if (!SWIG_Python_UnpackTuple(args, "gvRenderFilename", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvRenderFilename" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gvRenderFilename" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "gvRenderFilename" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "gvRenderFilename" "', argument " "4"" of type '" "char *""'"); } arg4 = (char *)(buf4); result = (int)gvRenderFilename(arg1,arg2,arg3,arg4); 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_gvRenderData(PyObject *self, PyObject *args) { PyObject *resultobj = 0; GVC_t *arg1 = (GVC_t *) 0 ; Agraph_t *arg2 = (Agraph_t *) 0 ; char *arg3 = (char *) 0 ; char **arg4 = (char **) 0 ; unsigned int *arg5 = (unsigned int *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; char *temp4 = 0 ; unsigned int tempn4 ; PyObject *swig_obj[3] ; int result; arg4 = &temp4; arg5 = &tempn4; if (!SWIG_Python_UnpackTuple(args, "gvRenderData", 3, 3, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_GVC_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvRenderData" "', argument " "1"" of type '" "GVC_t *""'"); } arg1 = (GVC_t *)(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Agraph_t, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gvRenderData" "', argument " "2"" of type '" "Agraph_t *""'"); } arg2 = (Agraph_t *)(argp2); res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "gvRenderData" "', argument " "3"" of type '" "char *""'"); } arg3 = (char *)(buf3); result = (int)gvRenderData(arg1,arg2,arg3,arg4,arg5); resultobj = SWIG_From_int((int)(result)); if (*arg4) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg4,*arg5)); free(*arg4); } if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return resultobj; fail: if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); return NULL; } SWIGINTERN PyObject *_wrap_gvFreeRenderData(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gvFreeRenderData" "', argument " "1"" of type '" "char *""'"); } arg1 = (char *)(buf1); gvFreeRenderData(arg1); resultobj = SWIG_Py_Void(); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; fail: if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return NULL; } static PyMethodDef SwigMethods[] = { { "agopen", _wrap_agopen, METH_VARARGS, NULL}, { "agclose", _wrap_agclose, METH_O, NULL}, { "agread", _wrap_agread, METH_VARARGS, NULL}, { "agwrite", _wrap_agwrite, METH_VARARGS, NULL}, { "agisundirected", _wrap_agisundirected, METH_O, NULL}, { "agisdirected", _wrap_agisdirected, METH_O, NULL}, { "agisstrict", _wrap_agisstrict, METH_O, NULL}, { "agnode", _wrap_agnode, METH_VARARGS, NULL}, { "agidnode", _wrap_agidnode, METH_VARARGS, NULL}, { "agsubnode", _wrap_agsubnode, METH_VARARGS, NULL}, { "agfstnode", _wrap_agfstnode, METH_O, NULL}, { "agnxtnode", _wrap_agnxtnode, METH_VARARGS, NULL}, { "aglstnode", _wrap_aglstnode, METH_O, NULL}, { "agprvnode", _wrap_agprvnode, METH_VARARGS, NULL}, { "agedge", _wrap_agedge, METH_VARARGS, NULL}, { "agidedge", _wrap_agidedge, METH_VARARGS, NULL}, { "agsubedge", _wrap_agsubedge, METH_VARARGS, NULL}, { "agfstin", _wrap_agfstin, METH_VARARGS, NULL}, { "agnxtin", _wrap_agnxtin, METH_VARARGS, NULL}, { "agfstout", _wrap_agfstout, METH_VARARGS, NULL}, { "agnxtout", _wrap_agnxtout, METH_VARARGS, NULL}, { "agfstedge", _wrap_agfstedge, METH_VARARGS, NULL}, { "agnxtedge", _wrap_agnxtedge, METH_VARARGS, NULL}, { "aghead", _wrap_aghead, METH_O, NULL}, { "agtail", _wrap_agtail, METH_O, NULL}, { "agattr", _wrap_agattr, METH_VARARGS, NULL}, { "agattrsym", _wrap_agattrsym, METH_VARARGS, NULL}, { "agnxtattr", _wrap_agnxtattr, METH_VARARGS, NULL}, { "agget", _wrap_agget, METH_VARARGS, NULL}, { "agxget", _wrap_agxget, METH_VARARGS, NULL}, { "agset", _wrap_agset, METH_VARARGS, NULL}, { "agxset", _wrap_agxset, METH_VARARGS, NULL}, { "agsafeset", _wrap_agsafeset, METH_VARARGS, NULL}, { "agattrname", _wrap_agattrname, METH_O, NULL}, { "agattrdefval", _wrap_agattrdefval, METH_O, NULL}, { "agsafeset_label", _wrap_agsafeset_label, METH_VARARGS, NULL}, { "agattr_label", _wrap_agattr_label, METH_VARARGS, NULL}, { "agsubg", _wrap_agsubg, METH_VARARGS, NULL}, { "agfstsubg", _wrap_agfstsubg, METH_O, NULL}, { "agnxtsubg", _wrap_agnxtsubg, METH_O, NULL}, { "agparent", _wrap_agparent, METH_O, NULL}, { "agroot", _wrap_agroot, METH_O, NULL}, { "agdelsubg", _wrap_agdelsubg, METH_VARARGS, NULL}, { "agnnodes", _wrap_agnnodes, METH_O, NULL}, { "agnedges", _wrap_agnedges, METH_O, NULL}, { "agdegree", _wrap_agdegree, METH_VARARGS, NULL}, { "agraphof", _wrap_agraphof, METH_O, NULL}, { "agnameof", _wrap_agnameof, METH_O, NULL}, { "agdelnode", _wrap_agdelnode, METH_VARARGS, NULL}, { "agdeledge", _wrap_agdeledge, METH_VARARGS, NULL}, { "gvContext", _wrap_gvContext, METH_NOARGS, NULL}, { "gvFreeContext", _wrap_gvFreeContext, METH_O, NULL}, { "gvLayout", _wrap_gvLayout, METH_VARARGS, NULL}, { "gvFreeLayout", _wrap_gvFreeLayout, METH_VARARGS, NULL}, { "gvRender", _wrap_gvRender, METH_VARARGS, NULL}, { "gvRenderFilename", _wrap_gvRenderFilename, METH_VARARGS, NULL}, { "gvRenderData", _wrap_gvRenderData, METH_VARARGS, NULL}, { "gvFreeRenderData", _wrap_gvFreeRenderData, METH_O, 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_GVC_t = {"_p_GVC_t", "GVC_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "unsigned int *", 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_GVC_t, &_swigt__p_char, &_swigt__p_p_char, &_swigt__p_unsigned_int, }; 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_GVC_t[] = { {&_swigt__p_GVC_t, 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 _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 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_GVC_t, _swigc__p_char, _swigc__p_p_char, _swigc__p_unsigned_int, }; /* -------- 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 #ifndef SWIG_INIT_CLIENT_DATA_TYPE #define SWIG_INIT_CLIENT_DATA_TYPE void * #endif SWIGRUNTIME void SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) { size_t i; swig_module_info *module_head, *iter; int 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); } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ iter=module_head; do { if (iter==&swig_module) { /* Our module is already in the list, so there's nothing more to do. */ return; } iter=iter->next; } while (iter!= module_head); /* otherwise we must add our 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 %lu\n", (unsigned long)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 %lu %s\n", (unsigned long)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 %lu %s\n", (unsigned long)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 /* ----------------------------------------------------------------------------- * 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); } } } /* ----------------------------------------------------------------------------- * Patch %callback methods' docstrings to hold the callback ptrs * -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, const 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) continue; c = strstr(c, "swig_ptr: "); if (c) { int j; const 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; memcpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; memcpy(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, *globals; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, 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 = { SwigPyObject_own, SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure }; PyTypeObject *builtin_pytype; int builtin_base_count; swig_type_info *builtin_basetype; PyObject *tuple; PyGetSetDescrObject *static_getset; PyTypeObject *metatype; PyTypeObject *swigpyobject; SwigPyClientData *cd; PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; PyObject *self = 0; int i; (void)builtin_pytype; (void)builtin_base_count; (void)builtin_basetype; (void)tuple; (void)static_getset; (void)self; /* Metaclass is used to implement static member variables */ metatype = SwigPyObjectType(); assert(metatype); #endif (void)globals; /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ SWIG_This(); SWIG_Python_TypeCache(); SwigPyPacked_type(); #ifndef SWIGPYTHON_BUILTIN SwigPyObject_type(); #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(SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); (void)md; SWIG_InitializeModule(0); #ifdef SWIGPYTHON_BUILTIN swigpyobject = SwigPyObject_TypeOnce(); 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; } else if (swigpyobject->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); globals = SWIG_globals(); if (!globals) { PyErr_SetString(PyExc_TypeError, "Failure to create SWIG globals."); #if PY_VERSION_HEX >= 0x03000000 return NULL; #else return; #endif } PyDict_SetItemString(md, "cvar", globals); SWIG_addvarlink(globals, "Agdirected", Swig_var_Agdirected_get, Swig_var_Agdirected_set); SWIG_addvarlink(globals, "Agstrictdirected", Swig_var_Agstrictdirected_get, Swig_var_Agstrictdirected_set); SWIG_addvarlink(globals, "Agundirected", Swig_var_Agundirected_get, Swig_var_Agundirected_set); SWIG_addvarlink(globals, "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-pygraphviz-1.13/pygraphviz/scraper.py000066400000000000000000000053271461720656100222750ustar00rootroot00000000000000import os from glob import glob import shutil def _get_sg_image_scraper(): """Return the callable scraper to be used by Sphinx-Gallery. It allows PyGraphviz users to just use strings as they already can for 'matplotlib' and 'mayavi'. Details on this implementation can be found in `sphinx-gallery/sphinx-gallery/494`_ .. _sphinx-gallery/sphinx-gallery/494: https://github.com/sphinx-gallery/sphinx-gallery/pull/494 """ return PNGScraper() class PNGScraper: """A callable image scraper for png outputs from pygraphviz examples for sphinx-gallery. Can be used to collect `.png` files generated by pygraphviz in sphinx-gallery examples by adding the following to the ``conf.py``:: sphinx_gallery_conf = { ... 'image_scrapers': ('matplotlib', 'pygraphviz'), } This class is based on the recipe provide in [1]_. References ---------- .. [1] sphinx-gallery documentation - custom image scraper. https://sphinx-gallery.github.io/stable/advanced.html """ def __init__(self): self.seen = set() def __repr__(self): return "PNGScraper" def __call__(self, block, block_vars, gallery_conf): """ Scrape .png images created by pygraphviz examples. Invoked by sphinx-gallery. Parameters ---------- block : tuple A tuple containing the (label, content, line_number of the block. block_vars : dict Dict of block variables gallery_conf : dict Mapping of sphinx-gallery configuration values Returns ------- str : rST-formatted string containing the generated images. This will be rendered to HTML during the ``sphinx-build`` process. """ try: from sphinx_gallery.scrapers import figure_rst except ImportError as e: raise ImportError("You must install `sphinx_gallery`") from e # Find all PNG files in the directory of this example path_current_example = os.path.dirname(block_vars["src_file"]) pngs = sorted(glob(os.path.join(path_current_example, "*.png"))) # Iterate through PNGs and copy them to sphinx-gallery output dir image_names = [] image_path_iterator = block_vars["image_path_iterator"] for png in pngs: if png not in self.seen: self.seen |= set(png) this_image_path = next(image_path_iterator) image_names.append(this_image_path) shutil.move(png, this_image_path) # Use figure_rst to generate rST for image files return figure_rst(image_names, gallery_conf["src_dir"]) pygraphviz-pygraphviz-1.13/pygraphviz/testing.py000066400000000000000000000011161461720656100223030ustar00rootroot00000000000000def stringify(agraph): result = agraph.string().split() if '""' in result: result.remove('""') some = " ".join(result) while " ]" in some: some = some.replace(" ]", "]") if "\\N" in some: num_nattrs = len(agraph.node_attr) if num_nattrs == 1: some = some.replace('node [label="\\N"];', "") else: if "[label" in some: some = some.replace('[label="\\N", ', "[") else: some = some.replace(', label="\\N"', "") result = some.split() return " ".join(result) pygraphviz-pygraphviz-1.13/pygraphviz/tests/000077500000000000000000000000001461720656100214175ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/pygraphviz/tests/__init__.py000066400000000000000000000000001461720656100235160ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_attribute_defaults.py000066400000000000000000000052231461720656100267240ustar00rootroot00000000000000import pygraphviz as pgv stringify = pgv.testing.stringify def test_default_attributes(): A = pgv.AGraph() A.graph_attr["label"] = "test" A.graph_attr["spam"] = "eggs" assert "label" in A.graph_attr assert A.graph_attr["label"] == "test" assert A.graph_attr.keys() == ["label", "spam"] graph_attrs = [("label", "test"), ("spam", "eggs")] assert sorted(list(A.graph_attr.iteritems())) == graph_attrs ans = """strict graph { graph [label=test, spam=eggs]; }""" assert stringify(A) == " ".join(ans.split()) A.graph_attr["label"] = "" A.graph_attr["spam"] = "" ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) A.graph_attr["label"] = "test" del A.graph_attr["label"] ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) def test_graph_defaults(): A = pgv.AGraph(rankdir="LR", pack="true") ans = """strict graph { graph [pack=true, rankdir=LR]; }""" assert stringify(A) == " ".join(ans.split()) def test_node_defaults(): A = pgv.AGraph() A.node_attr["label"] = "test" assert "label" in A.node_attr assert A.node_attr["label"] == "test" assert A.node_attr.keys() == ["label"] assert A.node_attr == {"label": "test"} assert list(A.node_attr.iteritems()) == [("label", "test")] ans = """strict graph { node [label=test]; }""" assert stringify(A) == " ".join(ans.split()) A.node_attr["label"] = "" ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) A.node_attr["label"] = "test" del A.node_attr["label"] ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) A.graph_attr["fontname"] = "graph font" A.node_attr["fontname"] = "node font" A.edge_attr["fontname"] = "edge font" ans = """strict graph { graph [fontname="graph font"]; node [fontname="node font"]; edge [fontname="edge font"]; }""" assert stringify(A) == " ".join(ans.split()) def test_edge_defaults(): A = pgv.AGraph() A.edge_attr["label"] = "test" assert "label" in A.edge_attr assert A.edge_attr["label"] == "test" assert A.edge_attr.keys() == ["label"] assert A.edge_attr == {"label": "test"} assert list(A.edge_attr.iteritems()) == [("label", "test")] ans = """strict graph { edge [label=test]; } """ assert stringify(A) == " ".join(ans.split()) A.edge_attr["label"] = "" ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) A.edge_attr["label"] = "test" del A.edge_attr["label"] ans = """strict graph { }""" assert stringify(A) == " ".join(ans.split()) pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_clear.py000066400000000000000000000015601461720656100241200ustar00rootroot00000000000000import 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 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 len(A) == 0 assert A.nodes() == [] assert A.node_attr.keys() in ([], ["label"]) 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 len(A) == 0 assert A.nodes() == [] assert A.node_attr.keys() in ([], ["label"]) assert A.graph_attr.keys() == [] pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_close.py000066400000000000000000000003751461720656100241420ustar00rootroot00000000000000import pygraphviz as pgv def test_context_manager(): with pgv.AGraph() as ag: ag0 = ag assert ag0.handle != None def test_double_close(): ag = pgv.AGraph() ag.close() assert ag.handle is None ag.close() pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_drawing.py000066400000000000000000000113411461720656100244630ustar00rootroot00000000000000from tempfile import TemporaryFile import pygraphviz as pgv import pytest def test_drawing_error(): with pytest.raises(AttributeError): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) d = A.draw() def test_name_error(): with pytest.raises(ValueError): A = pgv.AGraph(name="test graph") A.draw("foo", prog="foo") def test_drawing_no_error_with_no_layout(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) d = A.draw(prog="nop") A.string_nop() def test_drawing_makes_file(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) with TemporaryFile() as fh: A.draw(fh, format="png", prog="twopi") assert fh.tell() > 0 with TemporaryFile() as fh: A.draw(path=fh, prog="circo", format="png") assert fh.tell() > 0 def test_drawing_to_create_dot_string(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) A.layout() dot_rep = A.to_string() assert "test graph" in dot_rep assert "strict graph" in dot_rep assert "pos" in dot_rep assert "height" in dot_rep assert "width" in dot_rep assert "1 -- 2" in dot_rep assert "2 -- 3" in dot_rep assert "3 -- 4" in dot_rep # unfortunately, the layout and dot outcomes vary # with system and graphviz version. One example is # shown here, the numbers can be very different. expected = """strict graph "test graph" { graph [bb="0,0,70.071,250.3"]; node [label="\\N"]; 1 [height=0.5, pos="27,18", width=0.75]; 2 [height=0.5, pos="43.071,88.469", width=0.75]; 1 -- 2 [pos="31.139,36.148 33.557,46.75 36.596,60.077 39.002,70.627"]; 3 [height=0.5, pos="41.467,160.69", width=0.75]; 2 -- 3 [pos="42.666,106.69 42.423,117.64 42.115,131.52 41.872,142.47"]; 4 [height=0.5, pos="32.966,232.3", width=0.75]; 3 -- 4 [pos="39.322,178.76 38.043,189.53 36.424,203.17 35.14,213.98"]; } """ # print("dot representation:", dot_rep) # assert expected == dot_rep class TestExperimentalGraphvizLibInterface: def test_drawing_error(self): with pytest.raises(AttributeError): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) d = A._draw() def test_name_error(self): with pytest.raises(ValueError): A = pgv.AGraph(name="test graph") A._draw("foo", prog="foo") def test_drawing_no_error_with_no_layout(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) d = A._draw(prog="nop") A.string_nop() def test_drawing_png_output_with_NULL_smoketest(self): """The PNG format can contain NULL bytes, which can cause cstring allocation problems if the size isn't handled correctly. See gh-424. """ A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) d = A._draw(prog="dot", format="png") def test_drawing_to_create_dot_string(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) A._layout() dot_rep = A.to_string() assert "test graph" in dot_rep assert "strict graph" in dot_rep assert "pos" in dot_rep assert "height" in dot_rep assert "width" in dot_rep assert "1 -- 2" in dot_rep assert "2 -- 3" in dot_rep assert "3 -- 4" in dot_rep # unfortunately, the layout and dot outcomes vary # with system and graphviz version. One example is # shown here, the numbers can be very different. expected = """strict graph "test graph" { graph [bb="0,0,70.071,250.3"]; node [label="\\N"]; 1 [height=0.5, pos="27,18", width=0.75]; 2 [height=0.5, pos="43.071,88.469", width=0.75]; 1 -- 2 [pos="31.139,36.148 33.557,46.75 36.596,60.077 39.002,70.627"]; 3 [height=0.5, pos="41.467,160.69", width=0.75]; 2 -- 3 [pos="42.666,106.69 42.423,117.64 42.115,131.52 41.872,142.47"]; 4 [height=0.5, pos="32.966,232.3", width=0.75]; 3 -- 4 [pos="39.322,178.76 38.043,189.53 36.424,203.17 35.14,213.98"]; } """ # print("dot representation:", dot_rep) # assert expected == dot_rep def test_drawing_makes_file(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) with TemporaryFile() as fh: A._draw(fh, format="png", prog="twopi") assert fh.tell() > 0 def test_drawing_makes_file1(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) with TemporaryFile() as fh: A._draw(path=fh, prog="circo", format="png") assert fh.tell() > 0 pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_edge_attributes.py000066400000000000000000000036541461720656100262120ustar00rootroot00000000000000import pygraphviz as pgv stringify = pgv.testing.stringify def test_edge_attributes(): A = pgv.AGraph() A.add_edge(1, 2, label="test", spam="eggs") ans = """strict graph { 1 -- 2 [label=test, spam=eggs]; }""" assert stringify(A) == " ".join(ans.split()) 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 "label" in one.attr assert one.attr["label"] == "test" assert sorted(one.attr.keys()) == ["label", "spam"] ans = """strict graph { 1 -- 2 [label=test, spam=eggs]; }""" assert stringify(A) == " ".join(ans.split()) one.attr["label"] = "" one.attr["spam"] = "" ans = """strict graph { 1 -- 2; }""" assert stringify(A) == " ".join(ans.split()) one.attr["label"] = "test" del one.attr["label"] ans = """strict graph { 1 -- 2; }""" assert stringify(A) == " ".join(ans.split()) def test_anonymous_edges(): text_graph = ( b"""graph test {\n a -- b [label="edge1"];\n a -- b [label="edge2"];\n }""" ) import os import tempfile fd, fname = tempfile.mkstemp() os.write(fd, text_graph) os.close(fd) A = pgv.AGraph(fname) ans = """graph test { a -- b [label=edge1]; a -- b [label=edge2]; }""" assert stringify(A) == " ".join(ans.split()) 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="") ans = """strict graph { 1 -- 2 [label=update]; }""" assert stringify(A) == " ".join(ans.split()) 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") ans = """graph { 1 -- 2 [key=one, label=update]; }""" assert stringify(A) == " ".join(ans.split()) pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_graph.py000066400000000000000000000426371461720656100241450ustar00rootroot00000000000000import pytest import unittest import pygraphviz as pgv stringify = pgv.testing.stringify class TestGraph(unittest.TestCase): 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 A.is_strict() assert A.nodes() == [] def test_data(self): d = {"a": "b", "b": "c"} A = pgv.AGraph(data=d) # with data assert sorted(A.nodes()) == ["a", "b", "c"] assert sorted(A.edges()) == [("a", "b"), ("b", "c")] def test_str(self): A = pgv.AGraph(name="test") assert stringify(A) == "strict graph test { }" A = pgv.AGraph() assert stringify(A) == "strict graph { }" def test_repr(self): A = pgv.AGraph() assert repr(A).startswith(" 2; 2 -> 3; }""" assert stringify(A) == ans ans = """strict digraph { 2 -> 1; 3 -> 2; }""" assert stringify(A.reverse()) == ans def test_name(self): A = pgv.AGraph(name="test") assert A.name == "test" B = A.reverse() assert B.name == "test" @pytest.mark.parametrize( "d", ( {0: {1: {}}, 1: {0: {}, 2: {}}, 2: {1: {}}}, # Dict-of-dicts {0: [1], 1: [0, 2], 2: [1]}, # Dict-of-lists ), ) def test_agraph_constructor_dict_input(d): """Test AGraph constructor with thing = dod or dol.""" # d is a dod or dol representation of a path graph with 3 nodes A = pgv.AGraph(d) assert sorted(A.nodes()) == ["0", "1", "2"] assert sorted(A.edges()) == [("0", "1"), ("1", "2")] def test_agraph_constructor_handle_input(): """Test AGraph constructor with thing= a Swig pointer - graph handle.""" base = pgv.AGraph({0: [1], 1: [0, 2], 2: [1]}) child = pgv.AGraph(base.handle) assert base == child # AGraphs created from handle reference original graph base.remove_node(2) assert sorted(child.nodes()) == ["0", "1"] def test_agraph_constructor_bad_input(): """AGraph constructor does not support edge lists.""" with pytest.raises(TypeError, match="Unrecognized input"): pgv.AGraph([(0, 1), (1, 2)]) def test_agraph_constructor_string_non_standard_encoding(): """AGraph constructor with a string specifying non-utf8-encoding.""" # A path graph string in .dot format with charset specified dotstring = 'strict graph "" {\n\tcharset="latin1";\n\t0 -- 1;\n\t1 -- 2;\n}\n' A = pgv.AGraph(string=dotstring) assert A.encoding == "latin1" assert sorted(A.edges()) == [("0", "1"), ("1", "2")] def test_agraph_equality_node_attrs(): """Graphs are not equal if node attributes differ.""" nodes = [0, 1] # Create graphs with the same nodes A, B = pgv.AGraph(), pgv.AGraph() A.add_nodes_from(nodes) B.add_nodes_from(nodes) # Set default attributes for all nodes in each graph A.node_attr["color"] = "red" B.node_attr["color"] = "red" assert A.get_node(1).attr["color"] == "red" assert A == B # Change attribute of a single node in B B.get_node(1).attr["color"] = "blue" # Graphs are no longer considered equal assert A != B # See #284 A and C should be different C = pgv.AGraph() A.add_nodes_from(nodes) assert A != C def test_agraph_equality_edge_attrs(): """Graphs are not equal if edge attributes differ.""" A, B = pgv.AGraph(), pgv.AGraph() A.add_edge(0, 1, weight=1.0) B.add_edge(0, 1, weight=1.0) assert A == B # Change edge attribute B.get_edge(0, 1).attr["weight"] = 2.0 assert A != B # See #284 A and C should be different C = pgv.AGraph() A.add_edge(0, 1) assert A != C def test_agraph_has_edge_single_input_parsing(): """If len(args) is 1, args[0] is assumed to be a tuple.""" A = pgv.AGraph({0: [1], 1: [0, 2], 2: [1]}) assert A.has_edge((0, 1)) assert not A.has_edge((0, 3)) def test_repr_on_incomplete_initialization(): """Smoke test to ensure no segfaults from accessing uninitialized attributes in __repr__ when object initialization fails. See gh-519.""" with pytest.raises(TypeError, match="Unrecognized input"): A = pgv.AGraph(object()) pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_html.py000066400000000000000000000037761461720656100240110ustar00rootroot00000000000000import pygraphviz as pgv stringify = pgv.testing.stringify long_html_string = """<
meow
Count 4
Earliest Run yesterday
Latest Run tomorrow
Avg Runtime 4 seconds
Avg Failure Rate 38.1%
>""" def test_long_html_string(): G = pgv.AGraph(label="Graph>") G.add_node("a", label=long_html_string) s = G.add_subgraph("b", label="Subgraph>") s.add_node("sa", label="Subgraph Node b>") G.add_edge("a", "b", label="Edge>") ans = f"""strict graph {{ graph [label=Graph>]; {{ graph [label=Subgraph>]; sa [label=Subgraph Node b>]; }} a [label={long_html_string}]; a -- b [label=Edge>]; }}""" assert stringify(G) == " ".join(ans.split()) 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>") ans = """strict graph { graph [label=Graph>]; { graph [label=Subgraph>]; sa [label=Subgraph Node b>]; } a [label=Node>]; a -- b [label=Edge>]; }""" assert stringify(G) == " ".join(ans.split()) pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_layout.py000066400000000000000000000064441461720656100243550ustar00rootroot00000000000000import pytest import sys import pygraphviz as pgv def test_layout(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) assert [n.attr["pos"] is None for n in A.nodes()] == [True] * 4 A.layout() assert [n.attr["pos"] is not None for n in A.nodes()] == [True] * 4 def test_layout_defaults(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) # print("Pos before",[n.attr["pos"] for n in A.nodes()]) assert [n.attr["pos"] is None for n in A.nodes()] == [True] * 4 A.layout() assert [n.attr["pos"] is not None for n in A.nodes()] == [True] * 4 # print("Pos after",[n.attr["pos"] for n in A.nodes()]) @pytest.mark.parametrize( "prog", ("neato", "dot", "twopi", "circo", "fdp", "osage", "patchwork", "sfdp"), ) def test_layout_prog_arg(prog): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) # No node position before layout assert all(n.attr["pos"] is None for n in A.nodes()) # All nodes should have a position after layout A.layout(prog=prog) assert all(n.attr["pos"] is not None for n in A.nodes()) # Node positions should be different for each of the layouts pos = [n.attr["pos"] for n in A.nodes()] A.layout(prog="dot") # Use dot layout as reference dot_pos = [n.attr["pos"] for n in A.nodes()] assert pos == dot_pos if prog == "dot" else pos != dot_pos def test_bad_prog_arg_raises(): A = pgv.AGraph() A.add_path([1, 2, 3, 4]) with pytest.raises(ValueError, match="Program.*is not one of"): A.layout(prog="not-a-valid-layout") class TestExperimentalGraphvizLibInterface: def test_layout(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) assert [n.attr["pos"] is None for n in A.nodes()] == [True] * 4 A._layout() assert [n.attr["pos"] is not None for n in A.nodes()] == [True] * 4 def test_layout_defaults(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) # print("Pos before",[n.attr["pos"] for n in A.nodes()]) assert [n.attr["pos"] is None for n in A.nodes()] == [True] * 4 A._layout() assert [n.attr["pos"] is not None for n in A.nodes()] == [True] * 4 # print("Pos after",[n.attr["pos"] for n in A.nodes()]) def test_layout_prog_arg(self): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4]) assert [n.attr["pos"] is None for n in A.nodes()] == [True] * 4 A._layout(prog=b"dot") assert [n.attr["pos"] is not None for n in A.nodes()] == [True] * 4 dot_pos = [n.attr["pos"] for n in A.nodes()] A._layout(prog="dot") result = [n.attr["pos"] for n in A.nodes()] assert result == dot_pos A._layout(prog="twopi") result = [n.attr["pos"] for n in A.nodes()] assert result != dot_pos A._layout(prog="neato") result = [n.attr["pos"] for n in A.nodes()] assert result != dot_pos A._layout(prog="circo") result = [n.attr["pos"] for n in A.nodes()] assert result != dot_pos A._layout(prog="fdp") result = [n.attr["pos"] for n in A.nodes()] assert result != dot_pos A._layout(prog="nop") result = [n.attr["pos"] for n in A.nodes()] assert result != dot_pos pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_node_attributes.py000066400000000000000000000027171461720656100262320ustar00rootroot00000000000000import pygraphviz as pgv stringify = pgv.testing.stringify def test_node_attribute(): A = pgv.AGraph() A.add_node(1, label="test", spam="eggs") ans = """strict graph { node [label="\\N"]; 1 [label=test, spam=eggs]; }""" assert stringify(A) == ans 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 "label" in one.attr assert one.attr["label"] == "test" assert sorted(one.attr.keys()) == ["label", "spam"] ans = """strict graph { node [label="\\N"]; 1 [label=test, spam=eggs]; }""" assert stringify(A) == ans one.attr["label"] = "" one.attr["spam"] = "" ans = """strict graph { node [label="\\N"]; 1 [label=""]; }""" assert stringify(A) == ans one.attr["label"] = "test" del one.attr["label"] ans = """strict graph { node [label="\\N"]; 1 [label=""]; }""" assert stringify(A) == ans def test_node_attribute_update(): A = pgv.AGraph() A.add_node(1, label="test", spam="eggs") A.add_node(1, label="updated") ans = """strict graph { node [label="\\N"]; 1 [label=updated, spam=eggs]; }""" assert stringify(A) == ans 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, else '' ans = """strict graph { node [label="\\N"]; 1; }""" assert stringify(A) == ans pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_readwrite.py000066400000000000000000000022111461720656100250120ustar00rootroot00000000000000import pygraphviz as pgv import os import tempfile import pathlib def test_readwrite(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) the_file = tempfile.NamedTemporaryFile(delete=False) fname = the_file.name # Make sure it can be opened for writing again on Win32 the_file.close() # Pass a string to trigger the code paths that close the newly created file handle A.write(fname) B = pgv.AGraph(fname) assert A == B assert B == A assert B is not A os.unlink(fname) def test_readwrite_pathobj(): A = pgv.AGraph(name="test graph") A.add_path([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) the_file = tempfile.NamedTemporaryFile(delete=False) fname = pathlib.Path(the_file.name) # Make sure it can be opened for writing again on Win32 the_file.close() # Pass a string to trigger the code paths that close the newly created file handle A.write(fname) B = pgv.AGraph(fname) assert A == B assert B == A assert B is not A os.unlink(fname) def test_sequential_reads_windows(): for _ in range(512): pgv.AGraph("digraph {1 -> 2}") pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_repr_mimebundle.py000066400000000000000000000012051461720656100261770ustar00rootroot00000000000000import pygraphviz as pgv import pytest def test_repr_output(): A = pgv.AGraph() A.add_path([1, 2, 3, 4]) assert repr(A).startswith("World>]; sa; } a; }""" assert stringify(G) == " ".join(ans.split()) 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" ans = """strict graph { node [foo=baz]; subgraph cluster_a { graph [foo=bar]; } a; }""" assert stringify(G) == " ".join(ans.split()) pygraphviz-pygraphviz-1.13/pygraphviz/tests/test_unicode.py000066400000000000000000000016451461720656100244640ustar00rootroot00000000000000import pygraphviz as pgv import sys def test_name_unicode(): A = pgv.AGraph(name="unicode") assert A.name == "unicode" def test_node_encoding(): A = pgv.AGraph(encoding="UTF-8") hello = "Здравствуйте!" A.add_node(hello) n = A.get_node(hello) assert n.name == hello n.attr["goodbye"] = "До свидания" assert 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 e.name == "1" assert e == (hello, hello) e.attr["hello"] = hello assert e.attr["hello"] == hello def test_from_string(): # test unicode in from_string() t = "测试" G = pgv.AGraph() G.add_node(t) ug = str(G) sg = str(G) G1 = pgv.AGraph(ug) G2 = pgv.AGraph(sg) assert str(G1) == str(G2) pygraphviz-pygraphviz-1.13/pyproject.toml000066400000000000000000000035321461720656100207710ustar00rootroot00000000000000[build-system] build-backend = 'setuptools.build_meta' requires = ['setuptools>=61.2'] [project] name = "pygraphviz" authors = [ {name = "Aric Hagberg", email = "aric.hagberg@gmail.com"}, {name = "Dan Schult", email = "dschult@colgate.edu"}, {name = "Manos Renieris"}, ] description = "Python interface to Graphviz" readme = "README.rst" requires-python = ">=3.10" license = {text = "BSD-3-Clause"} dynamic = ["version"] 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 :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Scientific/Engineering :: Visualization", ] [project.urls] Homepage = "https://pygraphviz.github.io" "Bug Tracker" = "https://github.com/pygraphviz/pygraphviz/issues/" Documentation = "https://pygraphviz.github.io/documentation/stable/" "Source Code" = "https://github.com/pygraphviz/pygraphviz/" Download = "https://pypi.python.org/pypi/pygraphviz" [tool.setuptools] packages = ["pygraphviz", "pygraphviz.tests"] platforms = ["Linux", "Mac OSX", "Windows"] [tool.setuptools.package-data] #"" = ["*.txt"] [tool.setuptools.dynamic.version] attr = "pygraphviz.__version__" pygraphviz-pygraphviz-1.13/requirements/000077500000000000000000000000001461720656100205755ustar00rootroot00000000000000pygraphviz-pygraphviz-1.13/requirements/README.md000066400000000000000000000007431461720656100220600ustar00rootroot00000000000000# pip requirements files ## Index - [`test.txt`](test.txt) Requirements for running test suite - [`doc.txt`](doc.txt) Requirements for building the documentation (see `../doc/`) - [`developer.txt`](developer.txt) Requirements for developers - [`release.txt`](release.txt) Requirements for making releases ## Examples ### Running the tests ```bash $ pip install -U -r requirements/test.txt ``` ### Building the docs ```bash $ pip install -U -r requirements/doc.txt ``` pygraphviz-pygraphviz-1.13/requirements/developer.txt000066400000000000000000000000201461720656100233130ustar00rootroot00000000000000pre-commit>=3.3 pygraphviz-pygraphviz-1.13/requirements/doc.txt000066400000000000000000000001331461720656100221000ustar00rootroot00000000000000sphinx>=7.3 pydata-sphinx-theme>=0.15.2 sphinx-gallery>=0.16 matplotlib>=3.8 numpydoc>=1.7 pygraphviz-pygraphviz-1.13/requirements/release.txt000066400000000000000000000000271461720656100227550ustar00rootroot00000000000000twine>=4.0 wheel>=0.40 pygraphviz-pygraphviz-1.13/requirements/test.txt000066400000000000000000000000541461720656100223140ustar00rootroot00000000000000pytest>=7.3 pytest-cov>=4.0 codecov>=2.1.13 pygraphviz-pygraphviz-1.13/setup.py000066400000000000000000000017601461720656100175700ustar00rootroot00000000000000import sys from setuptools import setup, Extension if __name__ == "__main__": define_macros = [("SWIG_PYTHON_STRICT_BYTE_CHAR", None)] if sys.platform == "win32": define_macros.append(("GVDLL", None)) extension = [ Extension( name="pygraphviz._graphviz", sources=["pygraphviz/graphviz_wrap.c"], include_dirs=[], library_dirs=[], # cdt does not link to cgraph, whereas cgraph links to cdt. # thus, cdt needs to come first in the library list to be sure # that both libraries are linked in the final built .so (if cgraph # is first, the implicit inclusion of cdt can lead to an incomplete # link list, having only cdt and preventing the module from being loaded with # undefined symbol errors. seen under PyPy on Linux.) libraries=["cdt", "cgraph", "gvc"], define_macros=define_macros, ) ] setup(ext_modules=extension)