Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a58f79335 |
@@ -1,16 +0,0 @@
|
||||
BasedOnStyle: WebKit
|
||||
Standard: Cpp03
|
||||
AlignAfterOpenBracket: false
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
BreakBeforeBraces: Allman
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakTemplateDeclarations: Yes
|
||||
ColumnLimit: 80
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
IndentCaseLabels: false
|
||||
SortIncludes: false
|
||||
AlignTrailingComments: false
|
||||
|
||||
SpacesInAngles: true
|
||||
@@ -1,49 +0,0 @@
|
||||
# Use, modification, and distribution are
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE.txt)
|
||||
#
|
||||
# Copyright Rene Rivera 2020.
|
||||
|
||||
# For Drone CI we use the Starlark scripting language to reduce duplication.
|
||||
# As the yaml syntax for Drone CI is rather limited.
|
||||
#
|
||||
#
|
||||
globalenv={'ADD_UBUNTU_TOOLCHAIN_PPA': 'true'}
|
||||
linuxglobalimage="cppalliance/droneubuntu1604:1"
|
||||
windowsglobalimage="cppalliance/dronevs2019"
|
||||
|
||||
def main(ctx):
|
||||
return [
|
||||
linux_cxx("g++-7 14", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("g++-7 17", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("g++-8 14", "g++-8", packages="g++-8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-8', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("g++-8 17", "g++-8", packages="g++-8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-8', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("g++-9 14", "g++-9", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-9', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("g++-9 17", "g++-9", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-9', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
linux_cxx("g++-9 2a", "g++-9", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-9', 'CXXSTD': '2a', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("g++-10 14", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("g++-10 17", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
linux_cxx("g++-10 20", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '20', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("clang++-7 14", "clang++-7", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("clang++-7 17", "clang++-7", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("clang++-8 14", "clang++-8", packages="clang-8", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("clang++-8 17", "clang++-8", packages="clang-8", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("clang++-9 14", "clang++-9", packages="clang-9", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("clang++-9 17", "clang++-9", packages="clang-9", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
|
||||
linux_cxx("clang++-10 14", "clang++-10", packages="clang-10", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
linux_cxx("clang++-10 17", "clang++-10", packages="clang-10", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
linux_cxx("clang++-10 20", "clang++-10", packages="clang-10", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '20', }, globalenv=globalenv),
|
||||
|
||||
osx_cxx("XCode-11.7 14", "clang++", packages="", buildtype="boost", xcode_version="11.7", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '14', }, globalenv=globalenv),
|
||||
osx_cxx("XCode-11.7 17", "clang++", packages="", buildtype="boost", xcode_version="11.7", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '17', }, globalenv=globalenv),
|
||||
]
|
||||
|
||||
# from https://github.com/boostorg/boost-ci
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export DRONE_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
||||
export GIT_COMMIT=$DRONE_COMMIT
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
echo '==================================> BEFORE_INSTALL'
|
||||
|
||||
. .drone/before-install.sh
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
cd ..
|
||||
git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/build
|
||||
git submodule update --init libs/config
|
||||
git submodule update --init tools/boost_install
|
||||
git submodule update --init libs/headers
|
||||
git submodule update --init tools/boostdep
|
||||
cp -r $TRAVIS_BUILD_DIR/* libs/graph
|
||||
python tools/boostdep/depinst/depinst.py graph
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
|
||||
echo '==================================> BEFORE_SCRIPT'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/before-script.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
echo "using $TOOLSET : : $COMPILER : $OPTIONS ;" > ~/user-config.jam
|
||||
(cd libs/config/test && ../../../b2 cxxstd=$CXXSTD config_info_travis_install toolset=$TOOLSET && ./config_info_travis)
|
||||
(cd libs/graph/test && ../../../b2 -j3 cxxstd=$CXXSTD toolset=$TOOLSET define=CI_SUPPRESS_KNOWN_ISSUES)
|
||||
|
||||
echo '==================================> AFTER_SUCCESS'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/after-success.sh
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export DRONE_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
||||
export GIT_COMMIT=$DRONE_COMMIT
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
echo '==================================> BEFORE_INSTALL'
|
||||
|
||||
. .drone/before-install.sh
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
cd ..
|
||||
git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/build
|
||||
git submodule update --init libs/config
|
||||
git submodule update --init tools/boost_install
|
||||
git submodule update --init libs/headers
|
||||
git submodule update --init tools/boostdep
|
||||
cp -r $TRAVIS_BUILD_DIR/* libs/graph
|
||||
python tools/boostdep/depinst/depinst.py graph
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
|
||||
echo '==================================> BEFORE_SCRIPT'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/before-script.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
echo "using $TOOLSET : : $COMPILER : $OPTIONS ;" > ~/user-config.jam
|
||||
(cd libs/config/test && ../../../b2 cxxstd=$CXXSTD config_info_travis_install toolset=$TOOLSET && ./config_info_travis)
|
||||
(cd libs/graph/test && ../../../b2 -j3 cxxstd=$CXXSTD toolset=$TOOLSET define=CI_SUPPRESS_KNOWN_ISSUES)
|
||||
|
||||
echo '==================================> AFTER_SUCCESS'
|
||||
|
||||
. $DRONE_BUILD_DIR/.drone/after-success.sh
|
||||
@@ -1,19 +0,0 @@
|
||||
# Code owners for Boost.Graph
|
||||
#
|
||||
# When a PR is opened, GitHub automatically requests review from the matching
|
||||
# owners listed below. The order of rules matters: later, more specific rules
|
||||
# override earlier, more general ones.
|
||||
#
|
||||
# Authoritative maintainer list: meta/libraries.json
|
||||
# Contact details: CONTRIBUTING.md#maintainers
|
||||
|
||||
# Default reviewers for everything
|
||||
* @jeremy-murphy @becheler
|
||||
|
||||
# Documentation, contributor-facing files, and CI configuration
|
||||
/doc/ @becheler
|
||||
/README.md @becheler
|
||||
/CONTRIBUTING.md @becheler
|
||||
/SECURITY.md @becheler
|
||||
/CODE_OF_CONDUCT.md @becheler
|
||||
/.github/ @becheler
|
||||
@@ -1,84 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a defect or unexpected behavior in Boost.Graph
|
||||
title: ''
|
||||
labels: ''
|
||||
type: Bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
Thank you for taking the time to file a bug report. Please fill in as much
|
||||
of the template below as you can. Reports without a reproducer or
|
||||
environment details are very hard to triage.
|
||||
-->
|
||||
|
||||
### Before filing
|
||||
|
||||
- [ ] I searched the [existing issues](https://github.com/boostorg/graph/issues?q=is%3Aissue) and did not find a duplicate.
|
||||
- [ ] I have reproduced the bug against the `develop` branch or the latest Boost release.
|
||||
- [ ] I have a minimal reproducer (or I will paste my full failing code below).
|
||||
|
||||
### Boost version
|
||||
|
||||
<!--
|
||||
You can find the version number in `<boost/version.hpp>`, or by running
|
||||
`git log -1` in your local Boost.Graph checkout.
|
||||
-->
|
||||
|
||||
### Compiler family
|
||||
|
||||
- [ ] GCC / g++
|
||||
- [ ] Clang / clang++
|
||||
- [ ] MSVC (Visual Studio)
|
||||
- [ ] Intel / oneAPI
|
||||
- [ ] Other (specify below)
|
||||
|
||||
Exact compiler version: <!-- e.g. g++ 13.2.0, clang 17.0.6, MSVC 19.39 -->
|
||||
|
||||
### Standard library
|
||||
|
||||
- [ ] libstdc++
|
||||
- [ ] libc++
|
||||
- [ ] MSVC STL
|
||||
- [ ] Other (specify below)
|
||||
|
||||
### Operating system
|
||||
|
||||
- [ ] Linux
|
||||
- [ ] macOS
|
||||
- [ ] Windows
|
||||
- [ ] Other (specify below)
|
||||
|
||||
### Kind of component affected
|
||||
|
||||
- [ ] Graph data structure (e.g. `adjacency_list`, `adjacency_matrix`)
|
||||
- [ ] Algorithm (e.g. `dijkstra_shortest_paths`, `breadth_first_search`)
|
||||
- [ ] Property map
|
||||
- [ ] I/O or file-format reader (e.g. `read_graphml`, `read_graphviz`)
|
||||
- [ ] Visitor / event hooks
|
||||
- [ ] Other (specify below)
|
||||
|
||||
Exact name of the affected component: <!-- e.g. dijkstra_shortest_paths -->
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
<!--
|
||||
A minimal compiling program that demonstrates the problem is ideal.
|
||||
A [Compiler Explorer](https://godbolt.org/z/9Esszr9Ga) link is even better.
|
||||
-->
|
||||
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
<!--
|
||||
Include compiler error messages or runtime output verbatim, with file and
|
||||
line numbers where applicable.
|
||||
-->
|
||||
|
||||
### Are you willing to help?
|
||||
|
||||
- [ ] I'd like to submit a fix as a pull request.
|
||||
- [ ] I can help diagnose or test a candidate fix.
|
||||
- [ ] I'm only reporting the issue.
|
||||
@@ -1,9 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Design discussion or open-ended question
|
||||
url: https://github.com/boostorg/graph/discussions
|
||||
about: |
|
||||
For "should we...?" questions, design exploration, or anything not
|
||||
yet a concrete proposal, please start a GitHub Discussion. Issues
|
||||
are reserved for bugs, feature requests with a concrete proposal,
|
||||
and documentation problems.
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
name: Documentation issue
|
||||
about: Report missing, incorrect, or unclear documentation
|
||||
title: ''
|
||||
labels: docs
|
||||
type: Task
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
Documentation problems are real issues. Thanks for taking the time to
|
||||
report one.
|
||||
-->
|
||||
|
||||
### Before filing
|
||||
|
||||
- [ ] I searched the [existing issues](https://github.com/boostorg/graph/issues?q=is%3Aissue+label%3Adocs) and did not find a duplicate.
|
||||
- [ ] I checked the latest version of the documentation on `develop`.
|
||||
|
||||
### Kind of problem
|
||||
|
||||
- [ ] Documentation is missing entirely
|
||||
- [ ] Documentation is incorrect or out of date
|
||||
- [ ] Explanation is unclear or confusing
|
||||
- [ ] Example does not compile
|
||||
- [ ] Example compiles but does not produce the documented result
|
||||
- [ ] Dead link or broken cross-reference
|
||||
- [ ] Other (specify below)
|
||||
|
||||
### Where is the issue?
|
||||
|
||||
<!--
|
||||
A link to the page, or the path to the file (for example,
|
||||
`doc/quick_tour.html` or `include/boost/graph/dijkstra_shortest_paths.hpp`).
|
||||
-->
|
||||
|
||||
### What is wrong, missing, or unclear?
|
||||
|
||||
<!--
|
||||
For example: an example does not compile, an algorithm's complexity is
|
||||
not stated, a parameter is undocumented, an explanation is confusing.
|
||||
-->
|
||||
|
||||
### What did you expect to find?
|
||||
|
||||
<!-- What information would have helped you? -->
|
||||
|
||||
### Suggested wording (optional)
|
||||
|
||||
<!--
|
||||
If you already have an idea of what the docs should say, paste a draft
|
||||
here.
|
||||
-->
|
||||
|
||||
### Are you willing to help?
|
||||
|
||||
- [ ] I'd like to submit a docs pull request.
|
||||
- [ ] I can review a candidate fix.
|
||||
- [ ] I'm only reporting the issue.
|
||||
@@ -1,72 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a new algorithm, API addition, or enhancement
|
||||
title: ''
|
||||
labels: ''
|
||||
type: Feature
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
Thanks for proposing an addition to Boost.Graph.
|
||||
|
||||
If you want to explore an idea or discuss whether a feature would be
|
||||
worthwhile before committing to a concrete proposal, please start a
|
||||
GitHub Discussion instead:
|
||||
https://github.com/boostorg/graph/discussions
|
||||
|
||||
This template is for requests with a clear, actionable proposal: a
|
||||
specific algorithm, API, or enhancement that a maintainer could
|
||||
reasonably implement or review.
|
||||
-->
|
||||
|
||||
### Before filing
|
||||
|
||||
- [ ] I searched the [existing issues](https://github.com/boostorg/graph/issues?q=is%3Aissue) and did not find a duplicate.
|
||||
- [ ] This is a concrete proposal, not an open-ended design question.
|
||||
|
||||
### Kind of addition
|
||||
|
||||
- [ ] New algorithm
|
||||
- [ ] New data structure
|
||||
- [ ] New property map or utility
|
||||
- [ ] New I/O format reader or writer
|
||||
- [ ] Extension to an existing component
|
||||
- [ ] Performance improvement
|
||||
- [ ] Other (specify below)
|
||||
|
||||
### Motivation
|
||||
|
||||
<!--
|
||||
What problem does this feature solve? Who would use it, and in what
|
||||
context?
|
||||
-->
|
||||
|
||||
### Proposed addition
|
||||
|
||||
<!--
|
||||
A new algorithm, a new data structure, an extension to an existing
|
||||
component, or something else? If you have a rough API sketch, paste it
|
||||
here.
|
||||
-->
|
||||
|
||||
### Relation to existing Boost.Graph components
|
||||
|
||||
<!--
|
||||
Does this overlap with or build on something that already exists in the
|
||||
library (for example, an existing algorithm or property map)?
|
||||
-->
|
||||
|
||||
### Prior art
|
||||
|
||||
- [ ] Reference paper or textbook (cite below)
|
||||
- [ ] Implementation in another library (link below)
|
||||
- [ ] None / original idea
|
||||
|
||||
References: <!-- paste DOI, ISBN, or URL -->
|
||||
|
||||
### Are you willing to contribute?
|
||||
|
||||
- [ ] I'd like to submit the implementation as a pull request.
|
||||
- [ ] I can help with review or testing, but not the implementation.
|
||||
- [ ] I'm only proposing the idea.
|
||||
@@ -1,50 +0,0 @@
|
||||
<!--
|
||||
Thanks for contributing to Boost.Graph! A few notes before you fill this in:
|
||||
|
||||
* Target the `develop` branch.
|
||||
* New contributions must be licensed under the
|
||||
[Boost Software License 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
* Please link any related issue with `Fixes #N` or `Refs #N`.
|
||||
-->
|
||||
|
||||
### Before submitting
|
||||
|
||||
- [ ] This PR targets the `develop` branch.
|
||||
- [ ] I searched for an existing PR or issue covering the same change.
|
||||
- [ ] My contribution is licensed under the Boost Software License 1.0.
|
||||
|
||||
### Type of change
|
||||
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature or API addition
|
||||
- [ ] Refactor (no behavior change)
|
||||
- [ ] Documentation
|
||||
- [ ] Build, CI, or tooling
|
||||
- [ ] Other (specify below)
|
||||
|
||||
### Does this PR introduce a breaking change?
|
||||
|
||||
- [ ] Yes (describe migration impact below)
|
||||
- [ ] No
|
||||
|
||||
### What this PR does
|
||||
|
||||
<!-- A short summary of the change. -->
|
||||
|
||||
### Motivation
|
||||
|
||||
<!-- Why is this needed? Link related issue with `Fixes #N` or `Refs #N`. -->
|
||||
|
||||
### Testing
|
||||
|
||||
<!--
|
||||
How did you verify the change? Which compilers and standard libraries did
|
||||
you build against? Were new tests added under `test/`?
|
||||
-->
|
||||
|
||||
### Checklist
|
||||
|
||||
- [ ] Existing tests pass (`b2` in the `test/` directory).
|
||||
- [ ] New behavior is covered by a test, or this is a docs / build / refactor change.
|
||||
- [ ] Documentation was updated if user-facing behavior changed.
|
||||
- [ ] No new compiler warnings on the platforms I built against.
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Print a markdown table comparing compiler-warning counts between two CI log archives.
|
||||
|
||||
Usage: warn_table.py BASELINE.zip AFTER.zip
|
||||
|
||||
A warning is a line matching 'file:line:col: warning:' (clang/gcc) or 'warning Cxxxx'
|
||||
(msvc). Linker, "N warnings generated" summary, and CI-runner lines are not counted.
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
WARNING = re.compile(r":\d+:\d+: warning:|warning C\d+")
|
||||
|
||||
|
||||
def counts(zip_path):
|
||||
"""Map each CI job to its warning count, read from the run's log archive."""
|
||||
result = {}
|
||||
with zipfile.ZipFile(zip_path) as archive:
|
||||
for entry in archive.namelist():
|
||||
# Top-level per-job logs are named like "12_ubuntu (gcc-14, 14).txt".
|
||||
if "/" in entry or not entry.endswith(".txt"):
|
||||
continue
|
||||
job = re.sub(r"^\d+_", "", entry[:-4])
|
||||
log = archive.read(entry).decode("utf-8", "replace")
|
||||
result[job] = sum(1 for line in log.splitlines() if WARNING.search(line))
|
||||
return result
|
||||
|
||||
|
||||
def main(baseline_zip, after_zip):
|
||||
baseline = counts(baseline_zip)
|
||||
after = counts(after_zip)
|
||||
print("| Job | Baseline | After | Delta |")
|
||||
print("|-----|---------:|------:|------:|")
|
||||
for job in sorted(baseline.keys() | after.keys()):
|
||||
if "cmake" in job: # cmake jobs build only the library, they never warn
|
||||
continue
|
||||
before = baseline.get(job, 0)
|
||||
now = after.get(job, 0)
|
||||
diff = now - before
|
||||
delta = f"{diff:+d}" if diff else "0"
|
||||
print(f"| {job} | {before} | {now} | {delta} |")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("usage: warn_table.py BASELINE.zip AFTER.zip")
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
@@ -1,357 +0,0 @@
|
||||
# Copyright 2020 Evan Miller
|
||||
# Copyright 2020 Matt Borland
|
||||
# Copyright 2021 John Maddock
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
name: CI
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
ubuntu:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [ gcc-14, clang-19 ]
|
||||
cxxstd: [ 14, 17, 20, 23 ]
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- uses: mstachniuk/ci-skip@v1
|
||||
with:
|
||||
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]'
|
||||
commit-filter-separator: ';'
|
||||
fail-fast: true
|
||||
- name: Set ENV
|
||||
run: |
|
||||
echo ${{ matrix.compiler }} | awk '/^gcc/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
|
||||
echo ${{ matrix.compiler }} | awk '/^gcc/ { gsub(/gcc/,"CXX=g++"); print; } /^clang/ { gsub(/clang/,"CXX=clang++"); print; }' >> $GITHUB_ENV
|
||||
- name: Install packages
|
||||
run: sudo apt install ${{ matrix.compiler }}
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
run: git submodule update --init tools/boostdep
|
||||
working-directory: ../boost-root
|
||||
- name: Copy files
|
||||
run: cp -r $GITHUB_WORKSPACE/* libs/graph
|
||||
working-directory: ../boost-root
|
||||
- name: Install deps
|
||||
run: python tools/boostdep/depinst/depinst.py graph
|
||||
working-directory: ../boost-root
|
||||
- name: Bootstrap
|
||||
run: ./bootstrap.sh
|
||||
working-directory: ../boost-root
|
||||
- name: Generate headers
|
||||
run: ./b2 headers
|
||||
working-directory: ../boost-root
|
||||
- name: Generate user config
|
||||
run: 'echo "using $TOOLSET : : $CXX ;" > ~/user-config.jam'
|
||||
working-directory: ../boost-root
|
||||
- name: Config info
|
||||
run: ../../../b2 print_config_info toolset=$TOOLSET cxxstd=${{ matrix.cxxstd }}
|
||||
working-directory: ../boost-root/libs/config/test
|
||||
- name: Test
|
||||
run: ../../../b2 toolset=$TOOLSET cxxstd=${{ matrix.cxxstd }}
|
||||
working-directory: ../boost-root/libs/graph/test
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolset: [ clang ]
|
||||
cxxstd: [ 14, 17, 20 ]
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- uses: mstachniuk/ci-skip@v1
|
||||
with:
|
||||
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[linux];[Linux];[LINUX]'
|
||||
commit-filter-separator: ';'
|
||||
fail-fast: true
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
run: git submodule update --init tools/boostdep
|
||||
working-directory: ../boost-root
|
||||
- name: Copy files
|
||||
run: cp -r $GITHUB_WORKSPACE/* libs/graph
|
||||
working-directory: ../boost-root
|
||||
- name: Install deps
|
||||
run: python tools/boostdep/depinst/depinst.py graph
|
||||
working-directory: ../boost-root
|
||||
- name: Bootstrap
|
||||
run: ./bootstrap.sh
|
||||
working-directory: ../boost-root
|
||||
- name: Generate headers
|
||||
run: ./b2 headers
|
||||
working-directory: ../boost-root
|
||||
- name: Config info
|
||||
run: ../../../b2 print_config_info toolset=${{ matrix.toolset }} cxxstd=${{ matrix.cxxstd }}
|
||||
working-directory: ../boost-root/libs/config/test
|
||||
- name: Test
|
||||
run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.cxxstd }} define=CI_SUPPRESS_KNOWN_ISSUES
|
||||
working-directory: ../boost-root/libs/graph/test
|
||||
windows_msvc_14_3:
|
||||
runs-on: windows-2022
|
||||
defaults:
|
||||
run:
|
||||
shell: cmd
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolset: [ msvc-14.3 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- uses: mstachniuk/ci-skip@v1
|
||||
with:
|
||||
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]'
|
||||
commit-filter-separator: ';'
|
||||
fail-fast: true
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
run: git submodule update --init tools/boostdep
|
||||
working-directory: ../boost-root
|
||||
- name: Copy files
|
||||
run: xcopy /s /e /q %GITHUB_WORKSPACE% libs\graph
|
||||
working-directory: ../boost-root
|
||||
- name: Install deps
|
||||
run: python tools/boostdep/depinst/depinst.py graph
|
||||
working-directory: ../boost-root
|
||||
- name: Bootstrap
|
||||
run: bootstrap
|
||||
working-directory: ../boost-root
|
||||
- name: Generate headers
|
||||
run: b2 headers
|
||||
working-directory: ../boost-root
|
||||
- name: Config info
|
||||
run: ..\..\..\b2 print_config_info cxxstd=14,17,20 address-model=64 toolset=msvc-14.3
|
||||
working-directory: ../boost-root/libs/config/test
|
||||
- name: Test
|
||||
run: ..\..\..\b2 --hash address-model=64 cxxstd=14,17,20 toolset=msvc-14.3
|
||||
working-directory: ../boost-root/libs/graph/test
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2022
|
||||
- os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Use library with add_subdirectory (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use library with add_subdirectory (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2022
|
||||
- os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
|
||||
- name: Install (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Debug
|
||||
|
||||
- name: Install (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
- name: Use the installed library (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use the installed library (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
@@ -1,62 +0,0 @@
|
||||
name: docs-check
|
||||
|
||||
# PR-time sanity check for the Antora documentation:
|
||||
# - b2 builds every example .cpp and regenerates its .txt sidecar
|
||||
# (catches broken examples; failures here fail the job)
|
||||
# - Antora renders the full site (catches broken .adoc, missing
|
||||
# includes, broken xrefs)
|
||||
#
|
||||
# No deployment. The real publishing path is boostorg/release-tools,
|
||||
# which auto-detects doc/build_antora.sh and ships to
|
||||
# www.boost.org/doc/libs/<version>/libs/graph/.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["develop", "documentation"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
docs-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
# Set up boost-root so b2 can build the example .cpp files (needs
|
||||
# the full Boost build tree, not just the headers we ship in this
|
||||
# repo).
|
||||
- name: Set up boost-root
|
||||
run: |
|
||||
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
cd ../boost-root
|
||||
git submodule update --init tools/boostdep
|
||||
rm -rf libs/graph
|
||||
cp -r "$GITHUB_WORKSPACE" libs/graph
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" graph
|
||||
git submodule update --init --depth 1 libs/static_assert
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
|
||||
- name: Snapshot example outputs (b2)
|
||||
working-directory: ../boost-root
|
||||
run: ./b2 -j$(nproc) libs/graph/doc/modules/ROOT/examples
|
||||
|
||||
# Mirror the regenerated .txt sidecars back into the workspace so
|
||||
# the Antora build below renders pages against fresh outputs.
|
||||
- name: Mirror generated .txt back to workspace
|
||||
run: rsync -a ../boost-root/libs/graph/doc/modules/ROOT/examples/ doc/modules/ROOT/examples/
|
||||
|
||||
# Build the site exactly as boostorg/release-tools will at release
|
||||
# time: invoke doc/build_antora.sh, which runs npm ci + npx antora
|
||||
# against the committed package-lock.json.
|
||||
- name: Build the site (release-tools entry point)
|
||||
working-directory: doc
|
||||
run: ./build_antora.sh playbook.yml
|
||||
@@ -1,61 +0,0 @@
|
||||
name: warning-count-comment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
PR_RUN: ${{ github.event.workflow_run.id }}
|
||||
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download this PR run's log archive
|
||||
run: gh api "repos/$REPO/actions/runs/$PR_RUN/logs" > pr-logs.zip
|
||||
|
||||
- name: Download latest successful develop run's log archive
|
||||
run: |
|
||||
DEV=$(gh run list --workflow CI --branch develop --status success \
|
||||
--limit 1 --json databaseId --jq '.[0].databaseId')
|
||||
if [ -z "$DEV" ]; then echo "no develop baseline run found" >&2; exit 1; fi
|
||||
echo "DEV_RUN=$DEV" >> "$GITHUB_ENV"
|
||||
gh api "repos/$REPO/actions/runs/$DEV/logs" > base-logs.zip
|
||||
|
||||
- name: Generate table
|
||||
run: |
|
||||
{
|
||||
echo "Compiler-warning counts vs \`develop\` (auto-generated)."
|
||||
echo "PR run \`$PR_RUN\` vs develop run \`$DEV_RUN\` (\`${HEAD_SHA:0:10}\`)."
|
||||
echo
|
||||
python3 .github/scripts/warn_table.py base-logs.zip pr-logs.zip
|
||||
} > table.md
|
||||
|
||||
- name: Resolve PR number
|
||||
id: pr
|
||||
run: |
|
||||
num=$(gh api "repos/$REPO/pulls?state=open&per_page=100" \
|
||||
--jq "map(select(.head.sha==\"$HEAD_SHA\"))[0].number")
|
||||
if [ -z "$num" ]; then
|
||||
echo "no open PR found with head $HEAD_SHA" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "num=$num" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Post or update sticky comment
|
||||
uses: marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
header: warning-counts
|
||||
number: ${{ steps.pr.outputs.num }}
|
||||
path: table.md
|
||||
@@ -1,20 +0,0 @@
|
||||
cube-fr.dot
|
||||
cube.dot
|
||||
disconnected-fr.dot
|
||||
graphml_test_out.xml
|
||||
kevin-bacon2.dat
|
||||
random.dot
|
||||
triangular-fr.dot
|
||||
triangular-kk.dot
|
||||
test/*.dot
|
||||
example/routing-table.dat
|
||||
example/figs/ospf-sptree.dot
|
||||
CMakeFiles/
|
||||
|
||||
# Antora docs build artifacts
|
||||
doc/build/
|
||||
doc/node_modules/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
**/.DS_Store
|
||||
@@ -1,253 +0,0 @@
|
||||
# Copyright 2020, 2021 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
||||
# When we're part of the Boost super project.
|
||||
cmake_minimum_required(VERSION 3.8...3.16)
|
||||
|
||||
project(boost_graph VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_graph
|
||||
src/graphml.cpp
|
||||
src/read_graphviz_new.cpp
|
||||
)
|
||||
|
||||
target_include_directories(boost_graph PUBLIC include)
|
||||
|
||||
target_link_libraries(boost_graph
|
||||
PUBLIC
|
||||
Boost::algorithm
|
||||
Boost::any
|
||||
Boost::array
|
||||
Boost::assert
|
||||
Boost::bimap
|
||||
Boost::concept_check
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::conversion
|
||||
Boost::core
|
||||
Boost::detail
|
||||
Boost::foreach
|
||||
Boost::function
|
||||
Boost::integer
|
||||
Boost::iterator
|
||||
Boost::lexical_cast
|
||||
Boost::math
|
||||
Boost::move
|
||||
Boost::mpl
|
||||
Boost::multi_index
|
||||
Boost::multiprecision
|
||||
Boost::optional
|
||||
Boost::parameter
|
||||
Boost::preprocessor
|
||||
Boost::property_map
|
||||
Boost::property_tree
|
||||
Boost::random
|
||||
Boost::range
|
||||
Boost::serialization
|
||||
Boost::smart_ptr
|
||||
Boost::spirit
|
||||
Boost::throw_exception
|
||||
Boost::tti
|
||||
Boost::tuple
|
||||
Boost::type_traits
|
||||
Boost::typeof
|
||||
Boost::unordered
|
||||
Boost::utility
|
||||
Boost::xpressive
|
||||
PRIVATE
|
||||
Boost::regex
|
||||
)
|
||||
|
||||
target_compile_definitions(boost_graph
|
||||
PUBLIC BOOST_GRAPH_NO_LIB
|
||||
# Source files already define BOOST_GRAPH_SOURCE
|
||||
# PRIVATE BOOST_GRAPH_SOURCE
|
||||
)
|
||||
|
||||
else()
|
||||
# When we're worked on by Boost.Graph developers.
|
||||
# Using 3.29 for now until I figure out the differences with the new Boost
|
||||
# config cmake introduced in 3.30.
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
project(boost_graph VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# TODO: The super-project version is set explicitly just like this, but we
|
||||
# should parse it from boost/version.hpp.
|
||||
find_package(Boost 1.90.0 REQUIRED COMPONENTS regex)
|
||||
|
||||
add_library(boost_graph)
|
||||
target_sources(boost_graph PUBLIC
|
||||
FILE_SET HEADERS
|
||||
BASE_DIRS "include"
|
||||
FILES
|
||||
include/boost/graph/adj_list_serialize.hpp
|
||||
include/boost/graph/adjacency_iterator.hpp
|
||||
include/boost/graph/adjacency_list.hpp
|
||||
include/boost/graph/adjacency_list_io.hpp
|
||||
include/boost/graph/adjacency_matrix.hpp
|
||||
include/boost/graph/astar_search.hpp
|
||||
include/boost/graph/bandwidth.hpp
|
||||
include/boost/graph/bc_clustering.hpp
|
||||
include/boost/graph/bellman_ford_shortest_paths.hpp
|
||||
include/boost/graph/betweenness_centrality.hpp
|
||||
include/boost/graph/biconnected_components.hpp
|
||||
include/boost/graph/bipartite.hpp
|
||||
include/boost/graph/boyer_myrvold_planar_test.hpp
|
||||
include/boost/graph/boykov_kolmogorov_max_flow.hpp
|
||||
include/boost/graph/breadth_first_search.hpp
|
||||
include/boost/graph/bron_kerbosch_all_cliques.hpp
|
||||
include/boost/graph/buffer_concepts.hpp
|
||||
include/boost/graph/chrobak_payne_drawing.hpp
|
||||
include/boost/graph/circle_layout.hpp
|
||||
include/boost/graph/closeness_centrality.hpp
|
||||
include/boost/graph/clustering_coefficient.hpp
|
||||
include/boost/graph/compressed_sparse_row_graph.hpp
|
||||
include/boost/graph/connected_components.hpp
|
||||
include/boost/graph/copy.hpp
|
||||
include/boost/graph/core_numbers.hpp
|
||||
include/boost/graph/create_condensation_graph.hpp
|
||||
include/boost/graph/cuthill_mckee_ordering.hpp
|
||||
include/boost/graph/cycle_canceling.hpp
|
||||
include/boost/graph/dag_shortest_paths.hpp
|
||||
include/boost/graph/degree_centrality.hpp
|
||||
include/boost/graph/depth_first_search.hpp
|
||||
include/boost/graph/dijkstra_shortest_paths.hpp
|
||||
include/boost/graph/dijkstra_shortest_paths_no_color_map.hpp
|
||||
include/boost/graph/dimacs.hpp
|
||||
include/boost/graph/directed_graph.hpp
|
||||
include/boost/graph/dll_import_export.hpp
|
||||
include/boost/graph/dominator_tree.hpp
|
||||
include/boost/graph/eccentricity.hpp
|
||||
include/boost/graph/edge_coloring.hpp
|
||||
include/boost/graph/edge_connectivity.hpp
|
||||
include/boost/graph/edge_list.hpp
|
||||
include/boost/graph/edmonds_karp_max_flow.hpp
|
||||
include/boost/graph/edmunds_karp_max_flow.hpp
|
||||
include/boost/graph/erdos_renyi_generator.hpp
|
||||
include/boost/graph/exception.hpp
|
||||
include/boost/graph/exterior_property.hpp
|
||||
include/boost/graph/filtered_graph.hpp
|
||||
include/boost/graph/find_flow_cost.hpp
|
||||
include/boost/graph/floyd_warshall_shortest.hpp
|
||||
include/boost/graph/fruchterman_reingold.hpp
|
||||
include/boost/graph/geodesic_distance.hpp
|
||||
include/boost/graph/graph_archetypes.hpp
|
||||
include/boost/graph/graph_as_tree.hpp
|
||||
include/boost/graph/graph_concepts.hpp
|
||||
include/boost/graph/graph_mutability_traits.hpp
|
||||
include/boost/graph/graph_selectors.hpp
|
||||
include/boost/graph/graph_stats.hpp
|
||||
include/boost/graph/graph_traits.hpp
|
||||
include/boost/graph/graph_utility.hpp
|
||||
include/boost/graph/graphml.hpp
|
||||
include/boost/graph/graphviz.hpp
|
||||
include/boost/graph/grid_graph.hpp
|
||||
include/boost/graph/gursoy_atun_layout.hpp
|
||||
include/boost/graph/hawick_circuits.hpp
|
||||
include/boost/graph/howard_cycle_ratio.hpp
|
||||
include/boost/graph/incremental_components.hpp
|
||||
include/boost/graph/is_kuratowski_subgraph.hpp
|
||||
include/boost/graph/is_straight_line_drawing.hpp
|
||||
include/boost/graph/isomorphism.hpp
|
||||
include/boost/graph/iteration_macros.hpp
|
||||
include/boost/graph/iteration_macros_undef.hpp
|
||||
include/boost/graph/johnson_all_pairs_shortest.hpp
|
||||
include/boost/graph/kamada_kawai_spring_layout.hpp
|
||||
include/boost/graph/king_ordering.hpp
|
||||
include/boost/graph/kruskal_min_spanning_tree.hpp
|
||||
include/boost/graph/labeled_graph.hpp
|
||||
include/boost/graph/leda_graph.hpp
|
||||
include/boost/graph/lookup_edge.hpp
|
||||
include/boost/graph/loop_erased_random_walk.hpp
|
||||
include/boost/graph/make_biconnected_planar.hpp
|
||||
include/boost/graph/make_connected.hpp
|
||||
include/boost/graph/make_maximal_planar.hpp
|
||||
include/boost/graph/matrix_as_graph.hpp
|
||||
include/boost/graph/max_cardinality_matching.hpp
|
||||
include/boost/graph/maximum_adjacency_search.hpp
|
||||
include/boost/graph/maximum_weighted_matching.hpp
|
||||
include/boost/graph/mcgregor_common_subgraphs.hpp
|
||||
include/boost/graph/mesh_graph_generator.hpp
|
||||
include/boost/graph/metis.hpp
|
||||
include/boost/graph/metric_tsp_approx.hpp
|
||||
include/boost/graph/minimum_degree_ordering.hpp
|
||||
include/boost/graph/named_function_params.hpp
|
||||
include/boost/graph/named_graph.hpp
|
||||
include/boost/graph/neighbor_bfs.hpp
|
||||
include/boost/graph/numeric_values.hpp
|
||||
include/boost/graph/one_bit_color_map.hpp
|
||||
include/boost/graph/overloading.hpp
|
||||
include/boost/graph/page_rank.hpp
|
||||
include/boost/graph/planar_canonical_ordering.hpp
|
||||
include/boost/graph/planar_face_traversal.hpp
|
||||
include/boost/graph/plod_generator.hpp
|
||||
include/boost/graph/point_traits.hpp
|
||||
include/boost/graph/prim_minimum_spanning_tree.hpp
|
||||
include/boost/graph/profile.hpp
|
||||
include/boost/graph/properties.hpp
|
||||
include/boost/graph/property_iter_range.hpp
|
||||
include/boost/graph/push_relabel_max_flow.hpp
|
||||
include/boost/graph/r_c_shortest_paths.hpp
|
||||
include/boost/graph/random.hpp
|
||||
include/boost/graph/random_layout.hpp
|
||||
include/boost/graph/random_spanning_tree.hpp
|
||||
include/boost/graph/read_dimacs.hpp
|
||||
include/boost/graph/relax.hpp
|
||||
include/boost/graph/reverse_graph.hpp
|
||||
include/boost/graph/rmat_graph_generator.hpp
|
||||
include/boost/graph/sequential_vertex_coloring.hpp
|
||||
include/boost/graph/simple_point.hpp
|
||||
include/boost/graph/sloan_ordering.hpp
|
||||
include/boost/graph/small_world_generator.hpp
|
||||
include/boost/graph/smallest_last_ordering.hpp
|
||||
include/boost/graph/ssca_graph_generator.hpp
|
||||
include/boost/graph/st_connected.hpp
|
||||
include/boost/graph/stanford_graph.hpp
|
||||
include/boost/graph/stoer_wagner_min_cut.hpp
|
||||
include/boost/graph/strong_components.hpp
|
||||
include/boost/graph/subgraph.hpp
|
||||
include/boost/graph/successive_shortest_path_nonnegative_weights.hpp
|
||||
include/boost/graph/tiernan_all_cycles.hpp
|
||||
include/boost/graph/topological_sort.hpp
|
||||
include/boost/graph/topology.hpp
|
||||
include/boost/graph/transitive_closure.hpp
|
||||
include/boost/graph/transitive_reduction.hpp
|
||||
include/boost/graph/transpose_graph.hpp
|
||||
include/boost/graph/tree_traits.hpp
|
||||
include/boost/graph/two_bit_color_map.hpp
|
||||
include/boost/graph/two_graphs_common_spanning_trees.hpp
|
||||
include/boost/graph/undirected_dfs.hpp
|
||||
include/boost/graph/undirected_graph.hpp
|
||||
include/boost/graph/use_mpi.hpp
|
||||
include/boost/graph/vector_as_graph.hpp
|
||||
include/boost/graph/vertex_and_edge_range.hpp
|
||||
include/boost/graph/vf2_sub_graph_iso.hpp
|
||||
include/boost/graph/visitors.hpp
|
||||
include/boost/graph/wavefront.hpp
|
||||
include/boost/graph/write_dimacs.hpp
|
||||
PRIVATE
|
||||
src/graphml.cpp
|
||||
src/read_graphviz_new.cpp
|
||||
)
|
||||
target_link_libraries(boost_graph PUBLIC Boost::headers PRIVATE Boost::regex)
|
||||
include(CTest)
|
||||
endif()
|
||||
|
||||
add_library(Boost::graph ALIAS boost_graph)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(boost_graph PUBLIC BOOST_GRAPH_DYN_LINK)
|
||||
else()
|
||||
target_compile_definitions(boost_graph PUBLIC BOOST_GRAPH_STATIC_LINK)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
@@ -1,84 +0,0 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at `arnaud.becheler -at- gmail.com`. All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
@@ -1,182 +0,0 @@
|
||||
# Contributing to Boost.Graph
|
||||
|
||||
## We are welcoming contributions
|
||||
|
||||
- Bug fixes and test cases for them
|
||||
- New algorithms (with tests, documentation, complexity notes, and a reference)
|
||||
- Documentation, examples, performance work
|
||||
- Concept refinements (handle with care as these are API-visible)
|
||||
|
||||
## Maintainers
|
||||
|
||||
| Maintainer | Role | Focus | Availability | Contact |
|
||||
|---|---|---|---|---|
|
||||
| **Jeremy W. Murphy** | Principal maintainer. Holds merge authority and final say on design decisions. | Algorithms, technical review, library architecture. 10+ years on BGL. | Part-time, best-effort. | `jeremy.william.murphy -at- gmail.com` |
|
||||
| **Arnaud Becheler** | Assistant maintainer. Triage, review, and contributor support; defers to Jeremy on merge decisions. | Documentation, modernization, contributor onboarding. | Full-time, funded by the [C++ Alliance](https://cppalliance.org) to assist Jeremy. | `arnaud.becheler -at- gmail.com` |
|
||||
|
||||
The authoritative maintainer list lives in [meta/libraries.json](meta/libraries.json); keep this section in sync with it. Maintainers aim to provide first-pass review on new PRs within two weeks.
|
||||
|
||||
## Getting set up
|
||||
|
||||
Clone the [Boost superproject](https://github.com/boostorg/boost):
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/boostorg/boost
|
||||
cd boost
|
||||
git submodule update --init --depth 1
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
```
|
||||
|
||||
Then replace `libs/graph/` with your fork:
|
||||
|
||||
```bash
|
||||
rm -rf libs/graph
|
||||
git clone https://github.com/<you>/graph libs/graph
|
||||
cd libs/graph
|
||||
git remote add upstream https://github.com/boostorg/graph
|
||||
```
|
||||
|
||||
## Building and testing
|
||||
|
||||
- Headers only: `./b2 headers` from boost root
|
||||
- Compiled components: `./b2` from `libs/graph`
|
||||
- All tests: `./b2` from `libs/graph/test` (takes ~10 min)
|
||||
- Single test: `./b2 cycle_canceling_test` from `libs/graph/test`
|
||||
- Different C++ standard: `./b2 cxxstd=20`
|
||||
- Different compiler: `./b2 toolset=clang`
|
||||
|
||||
### Naming conventions
|
||||
|
||||
BGL follows the standard Boost / STL conventions:
|
||||
|
||||
| Kind | Style | Example |
|
||||
|---|---|---|
|
||||
| Functions, types, variables, files | `snake_case` | `dijkstra_visitor`, `add_edge`, `adjacency_list.hpp` |
|
||||
| Member functions / methods | `snake_case` (same as free functions) | `get_edge`, `out_edges` |
|
||||
| Private member variables | `m_` prefix + `snake_case` | `m_matrix`, `m_num_edges`, `m_property` |
|
||||
| Concept names | `PascalCase` | `IncidenceGraph`, `VertexListGraph` |
|
||||
| Template parameters | `PascalCase` | `template <class Graph, class WeightMap>` |
|
||||
| Tag-dispatch types | `snake_case` + `S` suffix | `vecS`, `directedS` |
|
||||
| Macros | `BOOST_GRAPH_` prefix, `SCREAMING_SNAKE_CASE` | `BOOST_GRAPH_DECLARE_EDGE_PROPERTY` |
|
||||
|
||||
### Formatting
|
||||
|
||||
Low-level formatting (braces, column width, spaces in angle brackets, etc.) is captured by the [`.clang-format`](.clang-format) file at the repo root (WebKit preset with BGL-specific overrides: Allman braces, 80-column limit, `Cpp03`). It is **not** enforced by CI, but contributors are encouraged to run `clang-format -i` on files they touch before opening a PR.
|
||||
|
||||
## Using other Boost libraries
|
||||
|
||||
When writing new code:
|
||||
|
||||
- **Prefer `std::`** when the supported C++ standard has an equivalent. Use `std::function`, `std::shared_ptr`, `std::tuple` over their Boost counterparts. Exceptions are welcome with justification in the PR description, in particular Boost containers with no std equivalent in our standard window (e.g. `boost::unordered_flat_map`, `boost::bimap`, `boost::multi_index_container`).
|
||||
- **Avoid pulling in new heavy dependencies** (Spirit, property_tree, xpressive, etc.) without justification: BGL is gradually migrating away from heavy Boost dependencies. Open a discussion before adding one.
|
||||
- **Concept checks** (`boost::concept`) are encouraged for any new public template. New public APIs should respect the existing concept hierarchy.
|
||||
- Track BGL's position in the Boost dependency DAG via [boostdep](https://github.com/boostorg/boostdep)'s hosted reports. The long-term goal is to reduce BGL's level over time:
|
||||
- **[Module levels](https://pdimov.github.io/boostdep-report/master/module-levels.html#graph)** shows BGL's depth in the global DAG. A rising level means new transitive Boost dependencies have been pulled in.
|
||||
- **[Per-library page](https://pdimov.github.io/boostdep-report/develop/graph.html)** shows BGL's direct deps and per-dep `#include` counts.
|
||||
|
||||
## Boost macro usage
|
||||
|
||||
BGL has accumulated a wide vocabulary of `BOOST_*` macros from its pre-C++14 days. The table below captures the current guidance for each one used in the codebase: **Keep** as-is, **Replace** with a language or std equivalent, or **Remove** along with the dead `#if defined(...)` branch the macro guards. When in doubt, follow the recommendation here or ask before introducing new uses.
|
||||
|
||||
| Macro | Recommendation |
|
||||
|---|---|
|
||||
| `BOOST_ASSERT` | Keep, more useful and configurable than `assert` |
|
||||
| `BOOST_BORLANDC` | Remove |
|
||||
| `BOOST_CONCEPT_ASSERT` | Keep (pre C++20) |
|
||||
| `BOOST_CONCEPT_REQUIRES` | Keep (pre C++20) |
|
||||
| `BOOST_CONCEPT_USAGE` | Keep (pre C++20) |
|
||||
| `BOOST_DEDUCED_TYPENAME` | Remove |
|
||||
| `BOOST_FOREACH` | Replace with an appropriate algorithm or range-based `for` loop |
|
||||
| `BOOST_FWD_REF` | Replace with `T&&` |
|
||||
| `BOOST_JOIN` | Keep |
|
||||
| `BOOST_MPL_HAS_XXX_TRAIT_DEF` | Consider writing the same utility without dependency on MPL |
|
||||
| `BOOST_MSVC` | Keep |
|
||||
| `BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP` | Remove |
|
||||
| `BOOST_NO_AUTO_PTR` | Remove and assume `auto_ptr` is not available |
|
||||
| `BOOST_NO_CXX11_ALLOCATOR` | Remove |
|
||||
| `BOOST_NO_CXX11_RVALUE_REFERENCES` | Remove |
|
||||
| `BOOST_NO_CXX11_SMART_PTR` | Remove |
|
||||
| `BOOST_NO_CXX17_STRUCTURED_BINDINGS` | Keep |
|
||||
| `BOOST_NO_MEMBER_TEMPLATE_FRIENDS` | Remove |
|
||||
| `BOOST_NO_SFINAE` | Remove |
|
||||
| `BOOST_NO_STDC_NAMESPACE` | Possibly keep |
|
||||
| `BOOST_NO_STD_ALLOCATOR` | Remove |
|
||||
| `BOOST_NO_STD_ITERATOR_TRAITS` | Remove |
|
||||
| `BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS` | Remove |
|
||||
| `BOOST_OVERRIDE` | Possibly remove |
|
||||
| `BOOST_PARAMETER_KEYWORD` | Keep |
|
||||
| `BOOST_PARAMETER_NAME` | Keep |
|
||||
| `BOOST_PP_CAT` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_COMMA_IF` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_DEC` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_BINARY_PARAMS` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_BINARY_PARAMS_Z` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_PARAMS` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_PARAMS_Z` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_ENUM_TRAILING_PARAMS_Z` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_EXPR_IF` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_INC` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_LPAREN_IF` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_REPEAT` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_REPEAT_FROM_TO` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_RPAREN_IF` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_SEQ_ELEM` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_SUB` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PP_TUPLE_EAT` | Use if Boost.PP can't be replaced with variadics |
|
||||
| `BOOST_PREVENT_MACRO_SUBSTITUTION` | Keep |
|
||||
| `BOOST_SERIALIZATION_NVP` | Consider removing if you can eliminate the dependency on Boost.Serialization via `<boost/core/serialization.hpp>` |
|
||||
| `BOOST_SPIRIT_CLOSURE_LIMIT` | Keep |
|
||||
| `BOOST_SPIRIT_DEBUG` | Keep |
|
||||
| `BOOST_SPIRIT_DEBUG_RULE` | Keep |
|
||||
| `BOOST_STATIC_ASSERT` | Replace with `static_assert(..., msg)` |
|
||||
| `BOOST_STATIC_ASSERT_MSG` | Replace with `static_assert(..., msg)` |
|
||||
| `BOOST_STATIC_CONSTANT` | Remove in favour of in-class `static constexpr` initialization |
|
||||
| `BOOST_SYMBOL_EXPORT` | Keep |
|
||||
| `BOOST_SYMBOL_IMPORT` | Keep |
|
||||
| `BOOST_SYMBOL_VISIBLE` | Keep |
|
||||
| `BOOST_TESTED_AT` | Keep |
|
||||
| `BOOST_THROW_EXCEPTION` | Keep |
|
||||
| `BOOST_TTI_HAS_MEMBER_FUNCTION` | Consider writing the same utility without dependency on TTI |
|
||||
| `BOOST_USING_STD_MAX` | Replace with `(std::max)(...)` |
|
||||
| `BOOST_USING_STD_MIN` | Replace with `(std::min)(...)` |
|
||||
| `BOOST_WORKAROUND` | Keep |
|
||||
|
||||
When you mark a `BOOST_NO_*` flag as **Remove**, also delete the `#if defined(...)` block it gates — the alternate branch is always taken on the supported toolchains.
|
||||
|
||||
## Pull request process
|
||||
|
||||
- Fork, branch from `develop`, PR back to `develop`
|
||||
- One logical change per PR; rebase before requesting review
|
||||
- Tests required for new features and bug fixes
|
||||
- **Open (non-draft) PRs are assumed ready for review.** Use GitHub's Draft state while iterating, then mark the PR as *Ready for review* when you want maintainers to look at it.
|
||||
- A maintainer will review within ~2 weeks (see Maintainers below)
|
||||
- Squash on merge by default
|
||||
|
||||
## Merge criteria
|
||||
|
||||
Before a PR is merged, all of the following must hold:
|
||||
|
||||
1. CI is green on the full matrix (gcc-14 + clang-19, C++14/17/20/23).
|
||||
2. New behavior has tests.
|
||||
3. Bug fixes have a regression test.
|
||||
4. Documentation under [doc/](doc/) is updated if the public API changed.
|
||||
5. No new compiler warnings on the supported toolchains.
|
||||
6. The PR is rebased on current `develop` with a clean commit history.
|
||||
7. The principal maintainer has approved.
|
||||
|
||||
## Reporting bugs
|
||||
|
||||
1. Search [existing issues](https://github.com/boostorg/graph/issues) first
|
||||
2. Note compiler, version, OS, Boost version
|
||||
3. Minimal reproducer on [Compiler Explorer](https://godbolt.org/z/37dPWd5bs)
|
||||
4. Expected Output versus Actual Output is explained.
|
||||
|
||||
## Security
|
||||
|
||||
See [SECURITY.md](SECURITY.md).
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree your contribution is licensed under the [Boost Software License 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
@@ -0,0 +1,100 @@
|
||||
COPYRIGHT NOTICE:
|
||||
|
||||
Copyright 1997-2000, University of Notre Dame.
|
||||
Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
|
||||
|
||||
The Boost Graph Library "Artistic License"
|
||||
|
||||
Preamble
|
||||
|
||||
The intent of this document is to state the conditions under which a
|
||||
Package may be copied, such that the Copyright Holder maintains some
|
||||
semblance of artistic control over the development of the package,
|
||||
while giving the users of the package the right to use and distribute
|
||||
the Package in a more-or-less free fashion, plus the right to make
|
||||
reasonable modifications.
|
||||
|
||||
Definitions
|
||||
|
||||
"Package" refers to the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection of files created
|
||||
through textual modification.
|
||||
|
||||
"Standard Version" refers to such a Package if it has not been
|
||||
modified, or has been modified in accordance with the wishes of the
|
||||
Copyright Holder as specified below.
|
||||
|
||||
"Copyright Holder" is whoever is named in the copyright or copyrights for the package.
|
||||
|
||||
"You" is you, if you're thinking about copying or distributing this Package.
|
||||
|
||||
"Reasonable copying fee" is whatever you can justify on the basis of
|
||||
media cost, duplication charges, time of people involved, and so
|
||||
on. (You will not be required to justify it to the Copyright Holder,
|
||||
but only to the computing community at large as a market that must
|
||||
bear the fee.)
|
||||
|
||||
"Freely Available" means that no fee is charged for the item itself,
|
||||
though there may be fees involved in handling the item. It also means
|
||||
that recipients of the item may redistribute it under the same
|
||||
conditions they received it.
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of
|
||||
the Standard Version of this Package without restriction, provided
|
||||
that you duplicate all of the original copyright notices and
|
||||
associated disclaimers.
|
||||
|
||||
2. You may apply bug fixes, portability fixes and other modifications
|
||||
derived from the Public Domain or from the Copyright Holder. A Package
|
||||
modified in such a way shall still be considered the Standard Version.
|
||||
|
||||
3. You may otherwise modify your copy of this Package in any way,
|
||||
provided that you insert a prominent notice in each changed file
|
||||
stating how and when you changed that file, and provided that you do
|
||||
at least ONE of the following:
|
||||
|
||||
a. place your modifications in the Public Domain or otherwise make
|
||||
them Freely Available, such as by posting said modifications to Usenet
|
||||
or an equivalent medium, or placing the modifications on a major
|
||||
archive site such as uunet.uu.net, or by allowing the Copyright Holder
|
||||
to include your modifications in the Standard Version of the Package.
|
||||
b. use the modified Package only within your corporation or organization.
|
||||
c. rename any non-standard types and functions so the names do not
|
||||
conflict with Standard Vibrary, which must also be provided, and
|
||||
provide a separate documentation for each non-standard type of function
|
||||
that clearly documents how it differs from the Standard Version.
|
||||
d. make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
4. You may charge a reasonable copying fee for any distribution of this
|
||||
Package. You may charge any fee you choose for support of this
|
||||
Package. You may not charge a fee for this Package itself. However,
|
||||
you may distribute this Package in aggregate with other (possibly
|
||||
commercial) programs as part of a larger (possibly commercial)
|
||||
software distribution provided that you do not advertise this Package
|
||||
as a product of your own.
|
||||
|
||||
5. The name of the Copyright Holder may not be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
DISCLAIMER:
|
||||
|
||||
LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
|
||||
By way of example, but not limitation, Licensor MAKES NO
|
||||
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
|
||||
PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
|
||||
OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
|
||||
OR OTHER RIGHTS.
|
||||
|
||||
The Authors and the University of Notre Dame du Lac shall not be held
|
||||
liable for any liability nor for any direct, indirect or consequential
|
||||
damages with respect to any claim by LICENSEE or any third party on
|
||||
account of or arising from this Agreement or use of this software.
|
||||
|
||||
Any disputes arising out of this Agreement or LICENSEE'S use of the
|
||||
software at any time shall be resolved by the courts of the state of
|
||||
Indiana. LICENSEE hereby consents to the jurisdiction of the Indiana
|
||||
courts and waives the right to challenge the jurisdiction thereof in
|
||||
any dispute arising out of this Agreement or Licensee's use of the
|
||||
software.
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
# Boost Graph Library
|
||||
|
||||
[](https://www.boost.org/doc/libs/release/libs/graph/doc/index.html)
|
||||
[](https://en.cppreference.com/w/cpp/14)
|
||||
[](https://github.com/boostorg/graph/actions/workflows/ci.yml)
|
||||
[](https://www.boost.org/LICENSE_1_0.txt)
|
||||
[](https://github.com/boostorg/boost/releases)
|
||||
|
||||
The Boost Graph Library (BGL) is a generic library that allows users to:
|
||||
|
||||
1. Represent graph data using different structures (adjacency matrix, adjacency list, compressed sparse row, vectors of vectors, user-defined data structures).
|
||||
2. Attach user-defined data to vertices, edges, or the graph itself.
|
||||
3. Run a large number of algorithms on the graph.
|
||||
4. Inject user logic into algorithms using visitor hooks.
|
||||
|
||||
## Example
|
||||
|
||||
[Try it on Compiler Explorer](https://godbolt.org/z/9Esszr9Ga)
|
||||
|
||||
```cpp
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/dijkstra_shortest_paths.hpp>
|
||||
#include <boost/graph/visitors.hpp>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
struct City {};
|
||||
struct Road { int cost; };
|
||||
|
||||
using namespace boost;
|
||||
using Graph = adjacency_list<vecS, vecS, directedS, City, Road>;
|
||||
using Vertex = graph_traits<Graph>::vertex_descriptor;
|
||||
|
||||
int main() {
|
||||
Graph g(4);
|
||||
add_edge(0, 1, Road{1}, g);
|
||||
add_edge(1, 2, Road{2}, g);
|
||||
add_edge(0, 2, Road{10}, g);
|
||||
add_edge(2, 3, Road{1}, g);
|
||||
|
||||
// Storage: you control allocation, lifetime, and container type
|
||||
std::vector<Vertex> storage_pred(num_vertices(g));
|
||||
std::vector<int> storage_dist(num_vertices(g));
|
||||
|
||||
// Property maps: lightweight views into the storage
|
||||
auto index_map = get(vertex_index, g);
|
||||
auto costs_map = get(&Road::cost, g);
|
||||
auto predecessor_map = make_iterator_property_map(storage_pred.begin(), index_map);
|
||||
auto distance_map = make_iterator_property_map(storage_dist.begin(), index_map);
|
||||
|
||||
dijkstra_shortest_paths(g, vertex(0, g),
|
||||
predecessor_map, distance_map,
|
||||
costs_map, index_map,
|
||||
std::less<int>(), std::plus<int>(),
|
||||
std::numeric_limits<int>::max(), 0,
|
||||
dijkstra_visitor<null_visitor>());
|
||||
|
||||
for (auto v : make_iterator_range(vertices(g)))
|
||||
std::cout << "distance to " << v << " = " << storage_dist[v] << "\n";
|
||||
}
|
||||
```
|
||||
```
|
||||
distance to 0 = 0
|
||||
distance to 1 = 1
|
||||
distance to 2 = 3
|
||||
distance to 3 = 4
|
||||
```
|
||||
|
||||
## Algorithms
|
||||
|
||||
BGL ships dozens of graph algorithms: shortest paths (Dijkstra, Bellman-Ford, A*, Floyd-Warshall, Johnson), spanning trees (Kruskal, Prim), maximum flow (Edmonds-Karp, push-relabel, Boykov-Kolmogorov), traversal (BFS, DFS, topological sort), planarity testing, isomorphism, component decomposition, and more.
|
||||
|
||||
See the [full algorithm reference](https://becheler.github.io/graph/graph/algorithms/overview.html) for the complete catalogue.
|
||||
|
||||
## Help and feedback
|
||||
|
||||
* **[GitHub Issues](https://github.com/boostorg/graph/issues)** for bug reports. Search before opening a new one.
|
||||
* **[GitHub Discussions](https://github.com/boostorg/graph/discussions)** for questions, design ideas, and general conversation about the library.
|
||||
* **[Boost mailing list](http://lists.boost.org/mailman/listinfo.cgi/boost-users)** for general Boost development. Use the `[graph]` tag in the subject line.
|
||||
* **CppLang Slack** for real-time chat. [Request an invite](https://cppalliance.org/slack/), then join the `#boost` channel.
|
||||
* **Direct contact with maintainers**: see [CONTRIBUTING.md#maintainers](CONTRIBUTING.md#maintainers).
|
||||
|
||||
## Using BGL
|
||||
|
||||
Install Boost via your package manager:
|
||||
|
||||
| Manager | Command |
|
||||
|---|---|
|
||||
| [vcpkg](https://vcpkg.io) | `vcpkg install boost-graph` |
|
||||
| [Conan](https://conan.io) | `conan install --requires=boost/[*]` |
|
||||
| apt (Debian/Ubuntu) | `sudo apt install libboost-graph-dev` |
|
||||
| Homebrew (macOS) | `brew install boost` |
|
||||
|
||||
Then wire it into CMake:
|
||||
|
||||
```cmake
|
||||
find_package(Boost REQUIRED COMPONENTS graph)
|
||||
target_link_libraries(my_app PRIVATE Boost::graph)
|
||||
```
|
||||
|
||||
Most of BGL is header-only. Linking `Boost::graph` is only required for the GraphViz and GraphML parsers.
|
||||
|
||||
## Building from source
|
||||
|
||||
For working on BGL itself (building Boost from source, running the test suite), see [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
@@ -1,14 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
Boost.Graph is a header-only C++ template library. Most issues that look
|
||||
like security problems are caused by misuse of the API, undefined behavior
|
||||
in caller code, or violating a documented precondition. Those should be
|
||||
filed as regular GitHub issues.
|
||||
|
||||
If you believe you have found a genuine vulnerability in the library
|
||||
itself, please report it privately through GitHub's
|
||||
[private vulnerability reporting](https://github.com/boostorg/graph/security/advisories/new)
|
||||
rather than opening a public issue.
|
||||
|
||||
Fixes land on the `develop` branch and ship with the next Boost release.
|
||||
No back-porting to older releases is guaranteed.
|
||||
@@ -1,61 +0,0 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/algorithm//boost_algorithm
|
||||
/boost/any//boost_any
|
||||
/boost/array//boost_array
|
||||
/boost/assert//boost_assert
|
||||
/boost/bimap//boost_bimap
|
||||
/boost/bind//boost_bind
|
||||
/boost/concept_check//boost_concept_check
|
||||
/boost/config//boost_config
|
||||
/boost/container_hash//boost_container_hash
|
||||
/boost/conversion//boost_conversion
|
||||
/boost/core//boost_core
|
||||
/boost/detail//boost_detail
|
||||
/boost/foreach//boost_foreach
|
||||
/boost/function//boost_function
|
||||
/boost/integer//boost_integer
|
||||
/boost/iterator//boost_iterator
|
||||
/boost/lexical_cast//boost_lexical_cast
|
||||
/boost/math//boost_math_tr1
|
||||
/boost/move//boost_move
|
||||
/boost/mpl//boost_mpl
|
||||
/boost/multi_index//boost_multi_index
|
||||
/boost/multiprecision//boost_multiprecision
|
||||
/boost/optional//boost_optional
|
||||
/boost/parameter//boost_parameter
|
||||
/boost/preprocessor//boost_preprocessor
|
||||
/boost/property_map//boost_property_map
|
||||
/boost/property_tree//boost_property_tree
|
||||
/boost/random//boost_random
|
||||
/boost/range//boost_range
|
||||
/boost/serialization//boost_serialization
|
||||
/boost/smart_ptr//boost_smart_ptr
|
||||
/boost/spirit//boost_spirit
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/tti//boost_tti
|
||||
/boost/tuple//boost_tuple
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/typeof//boost_typeof
|
||||
/boost/unordered//boost_unordered
|
||||
/boost/utility//boost_utility
|
||||
/boost/xpressive//boost_xpressive ;
|
||||
|
||||
project /boost/graph
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_graph : build//boost_graph ]
|
||||
[ alias all : boost_graph example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library graph
|
||||
: install boost_graph
|
||||
;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Copyright (c) 2002 Trustees of Indiana University
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import mpi ;
|
||||
|
||||
constant boost_dependencies_private :
|
||||
/boost/regex//boost_regex
|
||||
;
|
||||
|
||||
project
|
||||
: common-requirements <include>../include <library>$(boost_dependencies)
|
||||
: requirements <include>../src <library>$(boost_dependencies_private)
|
||||
: source-location ../src
|
||||
: usage-requirements <define>BOOST_GRAPH_NO_LIB=1
|
||||
;
|
||||
|
||||
lib boost_graph
|
||||
:
|
||||
read_graphviz_new.cpp
|
||||
graphml.cpp
|
||||
:
|
||||
<link>shared:<define>BOOST_GRAPH_DYN_LINK=1
|
||||
# Without these flags, MSVC 7.1 and 8.0 crash
|
||||
# User reports that VC++ 8.0 does not fail anymore, so that is removed
|
||||
<toolset>msvc-7.1:<cxxflags>-GR-
|
||||
<toolset>sun:<build>no
|
||||
:
|
||||
:
|
||||
;
|
||||
@@ -0,0 +1,164 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>AdjacencyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2><A NAME="concept:AdjacencyGraph"></A>
|
||||
AdjacencyGraph
|
||||
</H2>
|
||||
|
||||
The AdjacencyGraph concept provides and interface for efficient access
|
||||
of the adjacent vertices to a vertex in a graph. This is quite similar
|
||||
to the <a href="./IncidenceGraph.html">IncidenceGraph</a> concept (the
|
||||
target of an out-edge is an adjacent vertex). Both concepts are
|
||||
provided because in some contexts there is only concern for the
|
||||
vertices, whereas in other contexts the edges are also important.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::adjacency_iterator</pre>
|
||||
An adjacency iterator for a vertex <i>v</i> provides access to the
|
||||
vertices adjacent to <i>v</i>. As such, the value type of an
|
||||
adjacency iterator is the vertex descriptor type of its graph. An
|
||||
adjacency iterator must meet the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:adjacent-vertices"><TT>adjacent_vertices(v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to the vertices adjacent to
|
||||
vertex <TT>v</TT> in graph <TT>g</TT>.<a
|
||||
href="adjacencygraph.html#1">[1]</a>
|
||||
|
||||
<br> Return type:
|
||||
<TT>std::pair<adjacency_iterator, adjacency_iterator></TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>adjacent_vertices()</TT> function must return in constant time.
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct AdjacencyGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::adjacency_iterator
|
||||
adjacency_iterator;
|
||||
void constraints() {
|
||||
function_requires< IncidenceGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<adjacency_iterator> >();
|
||||
|
||||
p = adjacent_vertices(v, g);
|
||||
v = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = adjacent_vertices(v, g);
|
||||
}
|
||||
std::pair<adjacency_iterator,adjacency_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<h3>Design Rationale</h3>
|
||||
|
||||
The AdjacencyGraph concept is somewhat frivolous since <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> really covers the same
|
||||
functionality (and more). The AdjacencyGraph concept exists because
|
||||
there are situations when <tt>adjacent_vertices()</tt> is more
|
||||
convenient to use than <tt>out_edges()</tt>. If you are constructing a
|
||||
graph class and do not want to put in the extra work of creating an
|
||||
adjacency iterator, have no fear. There is an adaptor class in
|
||||
<tt>boost/graph/detail/adjacency_iterator.hpp</tt> that you can use to
|
||||
create an adjacency iterator out of an out-edge iterator.
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<a name="1">[1]</a> The case of a
|
||||
<I>multigraph</I> (where multiple edges can connect the same two
|
||||
vertices) brings up an issue as to whether the iterators returned by
|
||||
the <TT>adjacent_vertices()</TT> function access a range that
|
||||
includes each adjacent vertex once, or whether it should match the
|
||||
behavior of the <TT>out_edges()</TT> function, and access a
|
||||
range that may include an adjacent vertex more than once. For now the
|
||||
behavior is defined to match that of <TT>out_edges()</TT>,
|
||||
though this decision may need to be reviewed in light of more
|
||||
experience with graph algorithm implementations.
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,90 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>AdjacencyMatrix</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2><A NAME="concept:AdjacencyMatrix"></A>
|
||||
AdjacencyMatrix
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The AdjacencyMatrix concept refines <a href="./Graph.html">Graph</a>
|
||||
concept and adds the requirement for efficient access to any edge in
|
||||
the graph given the source and target vertices. No Boost Graph Library
|
||||
algorithms currently use this concept. However there are algorithms
|
||||
not yet implemented such as Floyd-Warshall that would require this
|
||||
concept.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Direct Edge Access</td>
|
||||
<TD><TT>edge(u,v,g)</TT></TD>
|
||||
<TD><TT>std::pair<edge_descriptor, bool></TT></TD>
|
||||
<TD>
|
||||
Returns a pair consisting of a flag saying whether there exists an
|
||||
edge between <TT>u</TT> and <TT>v</TT> in graph <TT>g</TT>, and
|
||||
consisting of the edge descriptor if the edge was found.
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
No models of this concept are currently in the Boost Graph Library.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct AdjacencyMatrix
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
p = edge(u, v, g);
|
||||
}
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
std::pair<bool, edge_descriptor> p;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,202 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: BFSVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>BFSVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>.
|
||||
Users can define a class with the BFSVisitor interface and pass and
|
||||
object of the class to <tt>breadth_first_search()</tt>, thereby
|
||||
augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of BFSVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Vertex</td>
|
||||
<td><tt>vis.examine_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on a vertex as it is popped from the queue. This
|
||||
happens immediately before <tt>examine_edge()</tt> is invoked
|
||||
on each of the out-edges of vertex <tt>u</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Tree Edge</td>
|
||||
<td><tt>vis.tree_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on each edge as it becomes a member of the edges that
|
||||
form the search tree.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Non-Tree Edge</td>
|
||||
<td><tt>vis.non_tree_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on back or cross edges for directed graphs and cross
|
||||
edges for undirected graphs.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Gray Target</td>
|
||||
<td><tt>vis.gray_target(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the subset of non-tree edges who's target vertex is
|
||||
colored gray at the time of examination. The color gray indicates
|
||||
that the vertex is currently in the queue.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Black Target</td>
|
||||
<td><tt>vis.black_target(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the subset of non-tree edges who's target vertex is
|
||||
colored black at the time of examination. The color black indicates
|
||||
that the vertex has been removed from the queue.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>See also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,175 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: BellmanFordVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>BellmanFordVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./bellman_ford_shortest.html"><tt>bellman_ford_shortest_paths()</tt></a>.
|
||||
Users can define a class with the BellmanFordVisitor interface and
|
||||
pass and object of the class to <tt>bellman_ford_shortest_paths()</tt>,
|
||||
thereby augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of BellmanFordVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every edge in the graph <tt>num_vertices(g)</tt> times.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Edge Relaxed</td>
|
||||
<td><tt>vis.edge_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the following condition holds then the edge
|
||||
is relaxed (its distance is reduced), and this method is invoked.<br>
|
||||
<tt>
|
||||
tie(u,v) = incident(e, g);<br>
|
||||
D d_u = get(d, u), d_v = get(d, v);<br>
|
||||
W w_e = get(w, e);<br>
|
||||
assert(compare(combine(d_u, w_e), d_v));<br>
|
||||
</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Relaxed</td>
|
||||
<td><tt>edge_not_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the edge is not relaxed (see above) then
|
||||
this method is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Minimized</td>
|
||||
<td><tt>vis.edge_minimized(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
After the <tt>num_vertices(g)</tt> iterations through the edge set
|
||||
of the graph is complete, one last iteration is made to test whether
|
||||
each edge was minimized. If the edge is minimized then this function
|
||||
is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Minimized</td>
|
||||
<td><tt>edge_not_minimized(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
If the edge is not minimized, this function is invoked. This happens
|
||||
when there is a negative cycle in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./bellman_visitor.html"><tt>bellman_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,173 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Bidirectional</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2>
|
||||
<A NAME="concept:BidirectionalGraph"></A>
|
||||
BidirectionalGraph
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The BidirectionalGraph concept refines <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> and adds the
|
||||
requirement for efficient access to the in-edges of each vertex. This
|
||||
concept is separated from <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> because for directed
|
||||
graphs efficient access to in-edges typically requires more storage
|
||||
space, and many algorithms do not require access to in-edges. For
|
||||
undirected graphs this is not an issue, since the <TT>in_edges()</TT>
|
||||
and <TT>out_edges()</TT> functions are the same, they both return the
|
||||
edges incident to the vertex.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::in_edge_iterator</pre>
|
||||
An in-edge iterator for a vertex <i>v</i> provides access to the
|
||||
in-edges of <i>v</i>. As such, the value type of an in-edge iterator
|
||||
is the edge descriptor type of its graph. An in-edge iterator must
|
||||
meet the requirements of <a href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</Table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:in-edges"><TT>in_edges(v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to the
|
||||
in-edges (for directed graphs) or incident edges (for
|
||||
undirected graphs) of vertex <TT>v</TT> in graph <TT>g</TT>.
|
||||
For both directed and undirected graphs, the target of
|
||||
an out-edge is required to be vertex <tt>v</tt> and the
|
||||
source is required to be a vertex that is adjacent to <tt>v</tt>.
|
||||
<br>
|
||||
Return type: <TT>std::pair<in_edge_iterator, in_edge_iterator></TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>in_degree(v, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the number of in-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>v</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>degree(v, g)</TT></TD>
|
||||
<TD>Returns the number of in-edges plus out-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>v</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</Table>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./adjacency_list.html"><tt>adjacency_list</tt></a> with <tt>Directed=bidirectionalS</tt></li>
|
||||
<li><a href="./adjacency_list.html"><tt>adjacency_list</tt></a> with <tt>Directed=undirectedS</tt></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>in_edges()</TT> function is required to be constant time. The
|
||||
<tt>in_degree()</tt> and <tt>degree()</tt> functions must be linear in
|
||||
the number of in-edges (for directed graphs) or incident edges (for
|
||||
undirected graphs).
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct BidirectionalGraph_concept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::in_edge_iterator
|
||||
in_edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< IncidenceGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<in_edge_iterator> >();
|
||||
|
||||
p = in_edges(v, g);
|
||||
e = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = in_edges(v, g);
|
||||
e = *p.first;
|
||||
}
|
||||
std::pair<in_edge_iterator, in_edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,123 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Buffer</Title>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h3>Buffer Concept</h3>
|
||||
|
||||
A Buffer is something in which items can be put and removed.
|
||||
The Buffer <i>concept</i> has very few requirements. It does
|
||||
not require any particular ordering of how the items are stored or in
|
||||
what order they will appear when removed, however, there is typically
|
||||
some sort of ordering policy.
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<table>
|
||||
<tr> <td> <tt>B</tt> </td> <td> is a type that models Buffer. </td></tr>
|
||||
<tr> <td> <tt>T</tt> </td> <td> is the value type of <tt>B</tt>. </td></tr>
|
||||
<tr> <td> <tt>t</tt> </td> <td> is an object of type <tt>T</tt>. </td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Members</h3>
|
||||
|
||||
For a type to model the Buffer concept it must have the following members.
|
||||
|
||||
<p>
|
||||
|
||||
<table border="1">
|
||||
|
||||
<tr> <td><b>Member</b></td> <td><b>Description</b></td> </tr>
|
||||
|
||||
<tr> <td> <tt>value_type</tt> </td>
|
||||
<td> The type of object stored in the Buffer. The value type
|
||||
must be <A href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>size_type</tt> </td>
|
||||
<td> An unsigned integral type for representing the number of
|
||||
objects in the Buffer.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void push(const T& t)</tt> </td>
|
||||
<td> Inserts <tt>t</tt> into the Buffer. <tt>size()</tt> will be
|
||||
incremented by one.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void pop()</tt> </td>
|
||||
<td> Removes an object from the Buffer. <tt>size()</tt> will be
|
||||
decremented by one. Precondition: <tt>empty()</tt>
|
||||
is <tt>false</tt>. </td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>T& top()</tt> </td>
|
||||
<td> Returns a mutable reference to some object in the Buffer.
|
||||
Precondition: <tt>empty()</tt> is <tt>false</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>const T& top() const</tt> </td>
|
||||
<td> Returns a const reference to some object in the Buffer.
|
||||
Precondition: <tt>empty()</tt> is <tt>false</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void size() const</tt> </td>
|
||||
<td> Returns the number of objects in the Buffer.
|
||||
Invariant: <tt>size() >= 0</tt>. </td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>bool empty() const</tt> </td>
|
||||
<td> Equivalent to <tt>b.size() == 0</tt>.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Complexity Guarantees</h3>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI> <tt>push()</tt>, <tt>pop()</tt>, and <tt>size()</tt> must be at
|
||||
most linear time complexity in the size of the Generalized Queue.
|
||||
|
||||
<LI> <tt>top()</tt> and <tt>empty()</tt> must be amortized constant time.
|
||||
|
||||
</UL>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<UL>
|
||||
<LI><a href="http://www.sgi.com/Technology/STL/stack.html"><tt>std::stack</tt></a>
|
||||
<LI><a href="../../pri_queue/queue.html"><tt>boost::queue</tt></a>
|
||||
<LI><a href="../../pri_queue/p_queue.html"><tt>boost::priority_queue</tt></a>
|
||||
</UL>
|
||||
|
||||
<p>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame and C++ Library & Compiler Group/SGI (<A HREF="mailto:jsiek@engr.sgi.com">jsiek@engr.sgi.com</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# Contributing to the Boost.Graph documentation
|
||||
|
||||
The docs are built with [Antora](https://antora.org) from AsciiDoc
|
||||
sources under `doc/modules/ROOT/`.
|
||||
|
||||
## Layout
|
||||
|
||||
| Where | What |
|
||||
|---|---|
|
||||
| `doc/modules/ROOT/pages/` | All `.adoc` pages (organized by topic) |
|
||||
| `doc/modules/ROOT/examples/` | One `.cpp` per page; the build script captures stdout into a sibling `.txt` |
|
||||
| `doc/modules/ROOT/nav.adoc` | Left-side navigation tree |
|
||||
| `doc/templates/` | Starter templates: `algorithm.adoc`, `generator.adoc`, `graph_class.adoc` — copy and fill in |
|
||||
| `doc/playbook.yml` | Antora playbook (UI bundle, content sources) |
|
||||
| `doc/modules/ROOT/examples/Jamfile` | b2 rules that compile every example and snapshot its stdout into a sibling `.txt` |
|
||||
| `doc/build_example_outputs.sh`| g++-only fallback that does the same thing as the Jamfile, for contributors without a `boost-root` checkout |
|
||||
|
||||
## Adding a new page
|
||||
|
||||
1. Pick a template in `doc/templates/` and copy it into the right
|
||||
`pages/` subdirectory.
|
||||
2. Replace the placeholders (title, signatures, parameter table). Keep
|
||||
the section order from the template so the page is consistent with
|
||||
the rest.
|
||||
3. Add an `.cpp` example under `modules/ROOT/examples/` at the path
|
||||
the page's `include::example$…[]` directive points to.
|
||||
4. Add an `xref:` line to `doc/modules/ROOT/nav.adoc`.
|
||||
|
||||
## Building locally
|
||||
|
||||
The example outputs are generated by b2 (the standard Boost build
|
||||
system). From a `boost-root` layout:
|
||||
|
||||
```sh
|
||||
# 1) Compile every example and snapshot its stdout into a sibling .txt.
|
||||
b2 libs/graph/doc/modules/ROOT/examples
|
||||
|
||||
# 2) Build the static site.
|
||||
cd libs/graph
|
||||
npx antora doc/playbook.yml
|
||||
|
||||
# 3) Open the result.
|
||||
open doc/build/site/index.html # macOS
|
||||
xdg-open doc/build/site/index.html # Linux
|
||||
```
|
||||
|
||||
CI runs the same commands on every push.
|
||||
|
||||
### Quick fallback (no boost-root required)
|
||||
|
||||
For doc-only contributors who only want to fix typos and don't have a
|
||||
boost-root checkout, a shell-script equivalent is provided:
|
||||
|
||||
```sh
|
||||
BOOST_INCLUDE=/path/to/boost/include \
|
||||
BOOST_LIB=/path/to/boost/lib \
|
||||
bash doc/build_example_outputs.sh
|
||||
```
|
||||
|
||||
Functionally equivalent to step 1 above; uses g++ directly instead of
|
||||
b2. `BOOST_LIB` is only needed for the three link-required examples
|
||||
(`io/graphml.cpp`, `io/graphviz.cpp`,
|
||||
`algorithms/isomorphism/isomorphism.cpp`).
|
||||
|
||||
## Conventions
|
||||
|
||||
- **Examples first.** `== Example` (with `*Expected output:*` block)
|
||||
goes immediately after `*Defined in:*` so readers see working code
|
||||
before signatures.
|
||||
- **Bold metadata.** `*Complexity:*`, `*Defined in:*`,
|
||||
`*Expected output:*` are bold.
|
||||
- **Output blocks** use `[,text]\n----` (same listing-block wrapper as
|
||||
the code above) and pull from the `.txt` sidecar via
|
||||
`include::example$…[]`, so the documentation can never drift from the
|
||||
code and the two blocks align vertically on the page.
|
||||
- **Heading levels:** `==` for top-level sections; `===` only for
|
||||
numbered overloads or grouped variants. The `'''` thematic break
|
||||
appears only before a `===`, never before a `==`.
|
||||
- **Bundled properties** preferred over interior tag properties in
|
||||
examples, unless the algorithm requires the tag.
|
||||
|
||||
## License
|
||||
|
||||
By contributing you agree to license your contribution under the
|
||||
[Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
@@ -0,0 +1,112 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: ColorValue Concept</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="concept:ColorValue"></A>
|
||||
ColorValue
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
This concept describes the requirements for the type used for color
|
||||
values, as in for coloring a graph during a breath-first search to
|
||||
mark which vertices have been visited.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Refinement of</h3> <a
|
||||
href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>
|
||||
and <a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>T</tt></TD>
|
||||
<TD>A type that is a model of ColorValue.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>cv</tt></TD>
|
||||
<TD>An object of type <tt>T</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Get Color White </td>
|
||||
<TD><TT>color_traits<T>::white()</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color white.</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Get Color Gray </td>
|
||||
<TD><TT>color_traits<T>::gray()</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color gray.</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Get Color Black </td>
|
||||
<TD><TT>color_traits<T>::black()</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color black.</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><tt>default_color_type</tt> (in <a href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt>)
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,184 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>DFSVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>DFSVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./depth_first_search.html"><tt>depth_first_search()</tt></a>.
|
||||
Users can define a class with the DFSVisitor interface and pass and
|
||||
object of the class to <tt>depth_first_search()</tt>, thereby
|
||||
augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of DFSVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Start Vertex</td>
|
||||
<td><tt>vis.start_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the source vertex once before the start of the
|
||||
search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Tree Edge</td>
|
||||
<td><tt>vis.tree_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on each edge as it becomes a member of the edges that
|
||||
form the search tree.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Back Edge</td>
|
||||
<td><tt>vis.back_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the back edges in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Forward or Cross Edge</td>
|
||||
<td><tt>vis.forward_or_cross_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on forward or cross edges in the graph. In an
|
||||
undirected graph this method is never called.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,182 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>EdgeListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:EdgeListGraph"></A>
|
||||
EdgeListGraph
|
||||
</H2>
|
||||
|
||||
The EdgeListGraph concept refines the <a href="./Graph.html">Graph</a>
|
||||
concept, and adds the requirement for efficient access to all the
|
||||
edges in the graph.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of EdgeListGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_iterator</pre>
|
||||
An edge iterator (obtained via <TT>edges(g)</TT>) provides access to
|
||||
all of the edges in a graph. An edge iterator type must meet the
|
||||
requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. The
|
||||
value type of the edge iterator must be the same as the edge
|
||||
descriptor of the graph.
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edges_size_type</pre>
|
||||
The unsigned integer type used to represent the number of edges in the
|
||||
graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:edges"><TT>edges(g)</TT></a></TD>
|
||||
<TD>Returns an iterator-range providing access to all
|
||||
the edges in the graph <TT>g</TT>.<br>
|
||||
Return type: <TT>std::pair<edge_iterator, edge_iterator></TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>num_edges(g)</TT></TD>
|
||||
<TD>Returns the number of edges in the graph <TT>g</TT>.<br>
|
||||
Return type: <TT>edges_size_type</TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>source(e, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the vertex descriptor for <i>u</i> of the edge <i>(u,v)</i>
|
||||
represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><TT>target(e, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the vertex descriptor for
|
||||
<i>v</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><a href="./adjacency_list.html"><TT>adjacency_list</TT></a></LI>
|
||||
<LI><a href="./edge_list.html"><TT>edge_list</TT></a></LI>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>edges()</TT>, <TT>source()</TT>, and <TT>target()</TT> functions
|
||||
must all return in constant time.
|
||||
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct EdgeListGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_iterator
|
||||
edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<edge_iterator> >();
|
||||
|
||||
p = edges(g);
|
||||
E = num_edges(g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = edges(g);
|
||||
E = num_edges(g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
std::pair<edge_iterator,edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
typename boost::graph_traits<G>::edges_size_type E;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,165 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: EventVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>EventVisitor Concept</H1>
|
||||
|
||||
This concept defines the interface for single-event visitors. An
|
||||
EventVisitor has an apply member function (<tt>operator()</tt>) which
|
||||
is invoked within the graph algorithm at the event-point specified by
|
||||
the <tt>event_filter</tt> typedef within the
|
||||
EventVisitor. EventVisitor's can be combined into an <a
|
||||
href="./EventVisitorList.html">EventVistorList</a>.
|
||||
|
||||
<p>
|
||||
The following is the list of event tags that can be invoked in BGL
|
||||
algorithms. Each tag corresponds to a member function of the visitor
|
||||
for an algorithm. For example, the <a
|
||||
href="./BFSVisitor.html">BFSVisitor</a> of <a
|
||||
href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>
|
||||
has a <tt>cycle_edge()</tt> member function. The corresponding tag is
|
||||
<tt>on_cycle_edge</tt>. The first argument is the event visitor's
|
||||
<tt>operator()</tt> must be either an edge or vertex descriptor
|
||||
depending on the event tag.
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
struct on_initialize_vertex { };
|
||||
struct on_start_vertex { };
|
||||
struct on_discover_vertex { };
|
||||
struct on_examine_edge { };
|
||||
struct on_tree_edge { };
|
||||
struct on_cycle_edge { };
|
||||
struct on_finish_vertex { };
|
||||
struct on_forward_or_cross_edge { };
|
||||
struct on_back_edge { };
|
||||
struct on_edge_relaxed { };
|
||||
struct on_edge_not_relaxed { };
|
||||
struct on_edge_minimized { };
|
||||
struct on_edge_not_minimized { };
|
||||
} // namespace boost
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of <a href="./Graph.html">Graph</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of EventVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>x</tt></TD>
|
||||
<TD>An object of type
|
||||
<tt>boost::graph_traits<G>::vertex_descriptor</tt>
|
||||
or <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD>Event Filter </TD>
|
||||
<TD><TT>V::event_filter</TT></TD>
|
||||
<TD>
|
||||
A tag struct to specify on which event the visitor should be invoked.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Apply Visitor</td>
|
||||
<td><TT>vis(x, g)</TT></TD>
|
||||
<TD><TT>void</TT></TD>
|
||||
<TD>
|
||||
Invokes the visitor operation on object <tt>x</tt>, which is
|
||||
either a vertex or edge descriptor of the graph.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>
|
||||
<li><a href="./distance_recorder.html"><tt>distance_recorder</tt></a>
|
||||
<li><a href="./time_stamper.html"><tt>time_stamper</tt></a>
|
||||
<li><a href="./property_writer.html"><tt>property_writer</tt></a>
|
||||
<li><a href="./null_visitor.html"><tt>null_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./EventVisitorList.html">EventVisitorList</a>,
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,131 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: EventVisitorList</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>EventVisitorList Concept</H1>
|
||||
|
||||
An EventVisitorList is either an <a
|
||||
href="./EventVisitor.html">EventVisitor</a>, or a list of
|
||||
EventVisitor's combined using <tt>std::pair</tt>. Each graph algorithm
|
||||
defines visitor adaptors that convert an EventVisitorList into the
|
||||
particular kind of visitor needed by the algorithm.
|
||||
|
||||
In the following example we will show how to combine event visitors
|
||||
into a list using <tt>std::pair</tt> and how to use an algorithm's
|
||||
visitor adaptor class.
|
||||
|
||||
<p>
|
||||
Suppose we would like to print out the parenthesis
|
||||
structure of the discover/finish times of vertices in a <a
|
||||
href="./graph_theory_review.html#sec:dfs-algorithm">depth-first
|
||||
search</a>. We can use the BGL algorithm <a
|
||||
href="./depth_first_search.html"><tt>depth_first_search()</tt></a> and
|
||||
two event visitors to accomplish this. The complete source code for
|
||||
the following example is in <a href="../example/dfs_parenthesis.cpp">
|
||||
<tt>examples/dfs_parenthesis.cpp</tt></a>. First we define the two
|
||||
event visitors. We use <tt>on_discover_vertex</tt> and
|
||||
<tt>on_finish_vertex</tt> as the event points, selected from the list
|
||||
of event points specified in <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
|
||||
<pre>
|
||||
struct open_paren : public base_visitor<open_paren> {
|
||||
typedef on_discover_vertex event_filter;
|
||||
template <class Vertex, class Graph>
|
||||
void operator()(Vertex v, Graph& G) {
|
||||
std::cout << "(" << v;
|
||||
}
|
||||
};
|
||||
struct close_paren : public base_visitor<close_paren> {
|
||||
typedef on_finish_vertex event_filter;
|
||||
template <class Vertex, class Graph>
|
||||
void operator()(Vertex v, Graph& G) {
|
||||
std::cout << v << ")";
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
|
||||
Next we create two event visitor objects and make an EventVisitorList
|
||||
out of them using a <tt>std::pair</tt> which created by
|
||||
<tt>std::make_pair</tt>.
|
||||
|
||||
<pre>
|
||||
std::make_pair(open_paren(), close_paren())
|
||||
</pre>
|
||||
|
||||
Next we want to pass this list into <tt>depth_first_search()</tt>, but
|
||||
<tt>depth_first_search()</tt> is expecting a <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>, not a EventVisitorList. We
|
||||
therefore use the <a
|
||||
href="./dfs_visitor.html"><tt>dfs_visitor</tt></a> adaptor which turns
|
||||
an EventVisitor list into a DFSVisitor. Like all of the visitor
|
||||
adaptors, <tt>dfs_visitor</tt> has a creation function called
|
||||
<tt>make_dfs_visitor()</tt>.
|
||||
|
||||
<pre>
|
||||
make_dfs_visitor(std::make_pair(open_paren(), close_paren()))
|
||||
</pre>
|
||||
|
||||
Now we can pass the resulting visitor object into
|
||||
<tt>depth_first_search()</tt> as follows.
|
||||
|
||||
<pre>
|
||||
// graph object G is created ...
|
||||
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
|
||||
depth_first_search(G, make_dfs_visitor(std::make_pair(open_paren(), close_paren())),
|
||||
color.begin());
|
||||
</pre>
|
||||
|
||||
For creating a list of more than two event visitors, nest calls to
|
||||
<tt>std::make_pair</tt> in the following way:
|
||||
|
||||
<pre>
|
||||
std::make_pair(<i>visitor1</i>,
|
||||
std::make_pair(<i>visitor2</i>,
|
||||
...
|
||||
std::make_pair(<i>visitorN-1</i>, <i>visitorN</i>)...));
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./EventVisitor.html">EventVisitor</a>,
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,133 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Graph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:Graph"></A>
|
||||
Graph
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The Graph concept contains a few requirements that are common to all
|
||||
the graph concepts. These include some associated types for
|
||||
<tt>vertex_descriptor</tt>, <tt>edge_descriptor</tt>, etc., and the
|
||||
<tt>num_vertices()</tt> and <tt>num_edges()</tt> functions. One should
|
||||
note that a model of Graph is <B>not</B> required to be a model of <a
|
||||
href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>,
|
||||
so algorithms should pass graph objects by reference.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::vertex_descriptor</pre>
|
||||
A vertex descriptor corresponds to a unique vertex in an abstract
|
||||
graph instance. A vertex descriptor must be
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>,
|
||||
<a href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>, and
|
||||
<a href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_descriptor</pre>
|
||||
An edge descriptor corresponds to a unique edge <i>(u,v)</i> in a
|
||||
graph. An edge descriptor must be <a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</I>,
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>,
|
||||
and <a href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::directed_category</pre>
|
||||
The choices are <TT>directed_tag</TT> and <TT>undirected_tag</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_parallel_category</pre>
|
||||
This describes whether the graph class allows the insertion of
|
||||
parallel edges (edges with the same source and target). The two tags
|
||||
are <TT>allow_parallel_edge_tag</TT> and <TT>disallow_parallel_edge_tag</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
None required.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct GraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
typedef typename boost::graph_traits<G>::directed_category directed_category;
|
||||
typedef typename boost::graph_traits<G>::edge_parallel_category edge_parallel_category;
|
||||
|
||||
void constraints() {
|
||||
function_requires< DefaultConstructibleConcept<vertex_descriptor> >();
|
||||
function_requires< EqualityComparableConcept<vertex_descriptor> >();
|
||||
function_requires< AssignableConcept<vertex_descriptor> >();
|
||||
function_requires< DefaultConstructibleConcept<edge_descriptor> >();
|
||||
function_requires< EqualityComparableConcept<edge_descriptor> >();
|
||||
function_requires< AssignableConcept<edge_descriptor> >();
|
||||
}
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,199 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>IncidenceGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="concept:IncidenceGraph"></A>
|
||||
IncidenceGraph
|
||||
</H1>
|
||||
|
||||
The IncidenceGraph concept provides an interface for
|
||||
efficient access to the out-edges of each vertex in the graph.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of IncidenceGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u, v</tt></TD>
|
||||
<TD>Are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD>
|
||||
<pre>boost::graph_traits<G>::out_edge_iterator</pre>
|
||||
An out-edge iterator for a vertex <i>v</i> provides access to the
|
||||
out-edges of the vertex. As such, the value type of an out-edge
|
||||
iterator is the edge descriptor type of its graph. An out-edge
|
||||
iterator must meet the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::degree_size_type</pre>
|
||||
The unsigned intergral type used for representing the number
|
||||
out-edges or incident edges of a vertex.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:source"><TT>source(e, g)</TT></a></TD>
|
||||
<TD>Returns the vertex descriptor for <i>u</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:target"><TT>target(e, g)</TT></a></TD>
|
||||
<TD>Returns the vertex descriptor for <i>v</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:out-edges"><TT>out_edges(u, g)</TT></a></TD>
|
||||
<TD>Returns an iterator-range providing access to the out-edges (for
|
||||
directed graphs) or incident edges (for undirected graphs) of vertex
|
||||
<TT>u</TT> in graph <TT>g</TT>. The source vertex of an edge obtained
|
||||
via and out edge iterator is guaranteed (for both directed and
|
||||
undirected graphs) to be the vertex <tt>u</tt> used in the call to
|
||||
<tt>out_edges(u, g)</tt> and the target vertex must the a vertex
|
||||
adjacent to <tt>u</tt>.<a href="">[1]</a>
|
||||
<br>
|
||||
Return type: <TT>std::pair<out_edge_iterator, out_edge_iterator></TT>
|
||||
</TD>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><TT>out_degree(u, g)</TT></TD>
|
||||
<TD>Returns the number of out-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>u</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
<P>
|
||||
The <TT>source()</TT>, <TT>target()</TT>, and <TT>out_edges()</TT>
|
||||
functions must all be constant time. The <tt>out_degree()</tt>
|
||||
function must be linear in the number of out-edges.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Notes</H3>
|
||||
|
||||
<a name="1">[1]</a> For undirected graphs, the edge <tt>(u,v)</tt> is
|
||||
the same as edge <tt>(v,u)</tt>, so without some extra guarantee an
|
||||
implementation would be free use any ordering for the pair of vertices
|
||||
in an out-edge. For example, if you call <tt>out_edges(u, g)</tt>, and
|
||||
<tt>v</tt> is one of the vertices adjacent to <tt>u</tt>, then the
|
||||
implementation would be free to return <tt>(v,u)</tt> as an out-edge
|
||||
which would be non-intuitive and cause trouble for algorithms.
|
||||
Therefore, the extra requirement is added that the out-edge connecting
|
||||
<tt>u</tt> and <tt>v</tt> must be given as <tt>(u,v)</tt> and not
|
||||
<tt>(v,u)</tt>.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct IncidenceGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::out_edge_iterator out_edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<out_edge_iterator> >();
|
||||
|
||||
p = out_edges(v, g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = out_edges(v, g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
std::pair<out_edge_iterator, out_edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,303 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>MutableGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="sec:MutableGraph"></A>
|
||||
MutableGraph
|
||||
</H2>
|
||||
|
||||
A MutableGraph can be changed via the addition or removal of
|
||||
edges and vertices.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u,v</tt></TD>
|
||||
<TD>are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>iter</tt></TD>
|
||||
<TD>is an object of type <tt>boost::graph_traits<G>::out_edge_iterator</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>p</tt></TD>
|
||||
<TD>is an object of a type that models <a
|
||||
href="http://www.sgi.com/Technology/STL/Predicate.html">Predicate</a>
|
||||
and whose argument type matches the <tt>edge_descriptor</tt> type.
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:add-edge"><TT>add_edge(u, v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Inserts the edge <i>(u,v)</i> into the graph, and returns an edge
|
||||
descriptor pointing to the new edge. If the graph disallows parallel
|
||||
edges, and the edge <i>(u,v)</i> is already in the graph, then the
|
||||
<tt>bool</tt> flag returned is <tt>false</tt> and the returned edge
|
||||
descriptor points to the already existing edge. Note that for
|
||||
undirected graphs, <i>(u,v)</i> is the same edge as <i>(v,u)</i>, so
|
||||
after a call to the function <tt>add_edge()</tt>, this implies that
|
||||
edge <i>(u,v)</i> will appear in the out-edges of <i>u</i> and
|
||||
<i>(u,v)</i> (or equivalently <i>(v,u)</i>) will appear in the
|
||||
out-edges of <i>v</i>. Put another way, <i>v</i> will be adjacent to
|
||||
<i>u</i> and <i>u</i> will be adjacent to <i>v</i>.
|
||||
<br>
|
||||
Return type: <TT>std::pair<edge_descriptor, bool></TT>
|
||||
</TD>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:remove_edge"><TT>remove_edge(u, v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Remove the edge <i>(u,v)</i> from the graph. If the
|
||||
graph allows parallel edges this remove all occurances of
|
||||
<i>(u,v)</i>.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <i>u</i> and <i>v</i> are vertices in the graph.<br>
|
||||
Postcondition: <i>(u,v)</i> is no longer in the edge set for
|
||||
<TT>g</TT>.<br>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge(e, g)</TT></TD>
|
||||
<TD>Remove the edge <i>e</i> from the graph.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <i>e</i> is an edge in the graph.<br>
|
||||
Postcondition: <i>e</i> is no longer in the edge set for <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge(iter, g)</TT></TD>
|
||||
<TD>Remove the edge pointed to be <tt>iter</tt> from the graph. This
|
||||
expression is only required when the graph also models <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <tt>*iter</tt> is an edge in the graph.<br>
|
||||
Postcondition: <tt>*iter</tt> is no longer in the edge set for <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge_if(p, g)</TT></TD>
|
||||
<TD>Remove all the edges from graph <tt>g</tt> for which
|
||||
the predicate <tt>p</tt> returns true.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_out_edge_if(u, p, g)</TT></TD>
|
||||
<TD>Remove all the out-edges of vertex <tt>u</tt> for which the
|
||||
predicate <tt>p</tt> returns true. This expression is only required
|
||||
when the graph also models <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_in_edge_if(u, p, g)</TT></TD>
|
||||
<TD>Remove all the in-edges of vertex <tt>u</tt> for which the
|
||||
predicate <tt>p</tt> returns true. This expression is only required when the
|
||||
graph also models <a
|
||||
href="./BidirectionalGraph.html">BidirectionalGraph</a>.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:add-vertex"><TT>add_vertex(g)</TT></a></TD>
|
||||
<TD>
|
||||
Add a new vertex to the graph. The <TT>vertex_descriptor</TT> for the
|
||||
new vertex is returned.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><TT>clear_vertex(u, g)</TT></TD>
|
||||
<TD>
|
||||
Remove all edges to and from vertex <tt>u</tt> from the graph.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <tt>u</tt> is a valid vertex descriptor of <TT>g</TT>.<br>
|
||||
Postcondition: <tt>u</tt> does not appear as a source or target of
|
||||
any edge in <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:remove-vertex"><TT>remove_vertex(u, g)</TT></a></TD>
|
||||
<TD>
|
||||
Remove <i>u</i> from the vertex set of the graph. Note that undefined
|
||||
behavior may result if there are edges remaining in the graph who's
|
||||
target is <i>u</i>. Typically the <TT>clear_vertex()</TT> function
|
||||
should be called first.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <TT>u</TT> is a valid vertex descriptor of <TT>g</TT>.<br>
|
||||
Postcondition: <TT>num_vertices(g)</TT> is one less, <TT>u</TT>
|
||||
no longer appears in the vertex set of the graph and it
|
||||
is no longer a valid vertex descriptor.
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity Guarantees</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>Edge insertion must be either amortized constant time or it
|
||||
can be <i>O(log(E/V))</i> if the insertion also checks to
|
||||
prevent the addition of parallel edges (which is a ``feature'' of
|
||||
some graph types).
|
||||
</LI>
|
||||
<LI>Edge removal is guaranteed to be <i>O(E)</i>.</LI>
|
||||
<LI>Vertex insertion is guaranteed to be amortized constant time.</LI>
|
||||
<LI>Clearing a vertex is <i>O(E + V)</i>.</LI>
|
||||
<LI>Vertex removal is <i>O(E + V)</i>.</LI>
|
||||
</UL>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct MutableGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
v = add_vertex(g);
|
||||
clear_vertex(v, g);
|
||||
remove_vertex(v, g);
|
||||
e_b = add_edge(u, v, g);
|
||||
remove_edge(u, v, g);
|
||||
remove_edge(e, g);
|
||||
}
|
||||
G g;
|
||||
edge_descriptor e;
|
||||
std::pair<edge_descriptor, bool> e_b;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::out_edge_iterator iter;
|
||||
};
|
||||
|
||||
template <class edge_descriptor>
|
||||
struct dummy_edge_predicate {
|
||||
bool operator()(const edge_descriptor& e) const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableIncidenceGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableGraph<G> >();
|
||||
remove_edge(iter, g);
|
||||
remove_out_edge_if(u, p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u;
|
||||
typename boost::graph_traits<G>::out_edge_iterator iter;
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableBidirectionalGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableIncidenceGraph<G> >();
|
||||
remove_in_edge_if(u, p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u;
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableEdgeListGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableGraph<G> >();
|
||||
remove_edge_if(p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,154 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>MutablePropertyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2>
|
||||
<A NAME="sec:MutablePropertyGraph"></A>
|
||||
MutablePropertyGraph
|
||||
</H2>
|
||||
|
||||
A MutablePropertyGraph is a <a
|
||||
href="./MutableGraph.html">MutableGraph</a> with properties attached
|
||||
internally to the vertices and edges. When adding vertices and edges
|
||||
the value of the properties can be given.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./MutableGraph.html">MutableGraph</a> and
|
||||
<a href="./PropertyGraph.html">PropertyGraph</a>
|
||||
|
||||
<H3>Notation</H3>
|
||||
|
||||
|
||||
<TABLE>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u,v</tt></TD>
|
||||
<TD>are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>ep</TT></TD><TD>is an object of type <TT>G::edge_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>vp</TT></TD><TD>is an object of type <TT>G::vertex_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td>Edge Property Type </td>
|
||||
<td><TT>graph_traits<G>::edge_property_type</TT></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Vertex Property Type </td>
|
||||
<td><TT>graph_traits<G>::vertex_property_type</TT> </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><TT>add_edge(u, v, ep, g)</TT></TD>
|
||||
<TD>Inserts the edge <i>(u,v)</i> into the graph, and
|
||||
copies object <TT>ep</TT> into the property property for that edge.<br>
|
||||
Return type: <TT>std::pair<edge_descriptor, bool></TT></TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>add_vertex(vp, g)</TT></TD>
|
||||
<TD>
|
||||
Add a new vertex to the graph and copy <TT>vp</TT> into the property
|
||||
property for the new vertex. The <TT>vertex_descriptor</TT> for the new
|
||||
vertex is returned.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT></LI>
|
||||
</UL>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct MutablePropertyGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
function_requires< MutableGraphConcept<G> >();
|
||||
v = add_vertex(vp, g);
|
||||
p = add_edge(u, v, ep, g);
|
||||
}
|
||||
G g;
|
||||
std::pair<edge_descriptor, bool> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::vertex_property_type vp;
|
||||
typename boost::graph_traits<G>::edge_property_type ep;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,105 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Property</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:Property"></A>
|
||||
Property
|
||||
</H2>
|
||||
|
||||
A Property type is a type used to name or identify properties that are
|
||||
attached to the vertices and edges of a graph. A Property type is not
|
||||
the type of the actual property values. Objects of the Property type
|
||||
are not used except to carry the type information which specifies the
|
||||
property.
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td>Property Kind </td>
|
||||
<td><TT>property_kind<Property>::type</TT> </td>
|
||||
<td>
|
||||
|
||||
This specifies whether the property is a <a
|
||||
name="VertexProperty">VertexProperty</a>
|
||||
(<tt>vertex_property_tag</tt>), an <a
|
||||
name="EdgeProperty">EdgeProperty</a> (<tt>edge_property_tag</tt>), or
|
||||
a <a name="GraphProperty">GraphProperty</a> which is attached to the
|
||||
graph object itself (<tt>graph_property_tag</tt>). The tags are
|
||||
defined in <a
|
||||
href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt></a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
The following models of the Property concept are defined
|
||||
in <a
|
||||
href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt></a>.
|
||||
|
||||
<ul>
|
||||
<li><tt>vertex_index_t</tt></li>
|
||||
<li><tt>edge_index_t</tt></li>
|
||||
<li><tt>graph_name_t</tt></li>
|
||||
<li><tt>vertex_name_t</tt></li>
|
||||
<li><tt>edge_name_t</tt></li>
|
||||
<li><tt>edge_weight_t</tt></li>
|
||||
<li><tt>vertex_distance_t</tt></li>
|
||||
<li><tt>vertex_color_t</tt></li>
|
||||
<li><tt>vertex_degree_t</tt></li>
|
||||
<li><tt>vertex_out_degree_t</tt></li>
|
||||
<li><tt>vertex_in_degree_t</tt></li>
|
||||
<li><tt>vertex_discover_time_t</tt></li>
|
||||
<li><tt>vertex_finish_time_t</tt></li>
|
||||
</ul>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./PropertyGraph.html">PropertyGraph</a>
|
||||
and
|
||||
<a href="../../property_map/property_map.html">Property Map Concepts</a>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
On compilers that do not support partial specialization, each Property
|
||||
type is also required to specialize
|
||||
<tt>property_num<Property></tt> to contain an enum named
|
||||
<tt>value</tt> which uniquely identifies the property type.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,213 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>PropertyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:PropertyGraph"></A>
|
||||
PropertyGraph
|
||||
</H2>
|
||||
|
||||
A PropertyGraph is a graph that has some property associated with each
|
||||
of the vertices or edges in the graph. As a given graph may have
|
||||
several properties associated with each vertex or edge, a tag is used
|
||||
to identity which property is being accessed. The graph provides a
|
||||
function which returns a property map object.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of PropertyGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>X</tt></TD>
|
||||
<TD>Either the vertex or edge descriptor type for <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>x</tt></TD>
|
||||
<TD>An object of type <tt>X</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR>
|
||||
<TD><tt>Map</tt></TD>
|
||||
<TD>The type <tt>boost::property_map<G, Property>::const_type</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::property_traits<Map>::value_type</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>Property</tt></TD>
|
||||
<TD>A type that models the <a href="./Property.html">Property</a> concept.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>p</tt></TD>
|
||||
<TD>An object of type <tt>Property</tt>.</td>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>pmap</tt></TD>
|
||||
<TD>An object of type <tt>Map</tt>.</td>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::property_map<G, Property>::type</pre>
|
||||
The type of the property map for the property specified by
|
||||
<TT>Property</TT>. This type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a> with a key type the same as the graph's vertex or descriptor type.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::property_map<G, Property>::const_type</pre>
|
||||
The type of the const property map for the property specified by
|
||||
<TT>Property</TT>. This type must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>
|
||||
with a key type the same as the graph's vertex or edge descriptor type.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td> <TT>get(p, g)</TT> </td>
|
||||
<td>
|
||||
Returns the property map for the property specified by the
|
||||
<tt>Property</tt> type. The object <tt>p</tt> is only used to
|
||||
carry the type.<br>
|
||||
Return type: <TT>boost::property_map<G, Property>::type</TT> if <TT>g</TT> is mutable and <br><TT>boost::property_map<G, Property>::const_type</TT> otherwise.
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td> <TT>get(p, g, x)</TT> </td>
|
||||
<td>
|
||||
Returns the property value (specified by the <tt>Property</tt> type)
|
||||
associated with object <tt>x</tt> (a vertex or edge).
|
||||
The object <tt>p</tt> is only used to carry the type.
|
||||
This function is equivalent to:<br>
|
||||
<tt>get(get(p, g), x)</tt><br>
|
||||
Return type: <tt>boost::property_traits<Map>::value_type</tt>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td> <TT>put(p, g, x, v)</TT> </td>
|
||||
<td>
|
||||
Set the property (specified by the <tt>Property</tt> type)
|
||||
associated with object <tt>x</tt> (a vertex or edge) to
|
||||
the value <tt>v</tt>. The object <tt>p</tt> is only used to carry the type.
|
||||
This function is equivalent to:<br>
|
||||
<tt>
|
||||
pmap = get(p, g);<br>
|
||||
put(pmap, x, v)
|
||||
</tt><br>
|
||||
Return type: <TT>void</TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
|
||||
</TABLE>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
The <tt>get()</tt> property map function must be constant time.
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
|
||||
<UL>
|
||||
<LI><tt>adjacency_list</tt> with <tt>VertexProperty=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></tt> and <tt>Property=vertex_distance_t</tt>.</li>
|
||||
<li><tt>adjacency_list</tt> with <tt>VertexProperty=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></TT> and <tt>Property=vertex_in_degree_t</tt>.</li>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class Graph, class X, class Property>
|
||||
struct PropertyGraphConcept
|
||||
{
|
||||
typedef typename property_map<G, Property>::type Map;
|
||||
typedef typename property_map<G, Property>::const_type const_Map;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< ReadWritePropertyMapConcept<Map, X> >();
|
||||
function_requires< ReadablePropertyMapConcept<const_Map, X> >();
|
||||
|
||||
Map pmap = get(Property(), g);
|
||||
pval = get(Property(), g, x);
|
||||
put(Property(), g, x, pval);
|
||||
ignore_unused_variable_warning(pmap);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
const_Map pmap = get(Property(), g);
|
||||
pval = get(Property(), g, x);
|
||||
ignore_unused_variable_warning(pmap);
|
||||
}
|
||||
G g;
|
||||
X x;
|
||||
typename property_traits<Map>::value_type pval;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./property_map.html"><tt>property_map</tt></a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,199 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: UniformCostVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>UniformCostVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./uniform_cost_search.html"><tt>uniform_cost_search()</tt></a>
|
||||
and related algorithms. The user can create a class that matches this
|
||||
interface, and then pass objects of the class into
|
||||
<tt>uniform_cost_search()</tt> to augment the actions taken during the
|
||||
search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of UniformCostVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u,v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>DistanceMap</tt></TD>
|
||||
<TD>A type that is a model of <a href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>d</tt></TD>
|
||||
<TD>An object of type <tt>DistanceMap</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>WeightMap</tt></TD>
|
||||
<TD>A type that is a model of <a href="../../property_map/ReadWritePropertyMap.html">ReadablePropertyMap</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>w</tt></TD>
|
||||
<TD>An object of type <tt>DistanceMap</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked one each vertex of the graph when it is initialized.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Start Vertex</td>
|
||||
<td><tt>vis.start_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the source vertex at the beginning of the algorithm.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Relaxed</td>
|
||||
<td><tt>vis.edge_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the following condition holds then the edge
|
||||
is relaxed (its distance is reduced), and this method is invoked.<br>
|
||||
<tt>
|
||||
tie(u,v) = incident(e, g);<br>
|
||||
D d_u = get(d, u), d_v = get(d, v);<br>
|
||||
W w_e = get(w, e);<br>
|
||||
assert(compare(combine(d_u, w_e), d_v));<br>
|
||||
</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Relaxed</td>
|
||||
<td><tt>vis.edge_not_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the edge is not relaxed (see above) then
|
||||
this method is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./ucs_visitor.html"><tt>ucs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,74 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>VertexAndEdgeListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:VertexAndEdgeListGraph"></A>
|
||||
VertexAndEdgeListGraph
|
||||
</H2>
|
||||
|
||||
The VertexAndEdgeListGraph concept refines the <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a> and the <a
|
||||
href="./EdgeListGraph.html">EdgeListGraph</a> concepts. No further
|
||||
requirements are added.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./VertexListGraph.html">VertexListGraph</a>,
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT></LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct VertexAndEdgeListGraph
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< VertexListGraphConcept<G> >();
|
||||
function_requires< EdgeListGraphConcept<G> >();
|
||||
}
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,153 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>VertexListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:VertexListGraph">
|
||||
VertexListGraph
|
||||
</H2>
|
||||
|
||||
The VertexListGraph</I> concept refines the <a
|
||||
href="./AdjacencyGraph.html">AdjacencyGraph</a> concept, and adds the
|
||||
requirement for efficient traversal of all the vertices in the graph.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a>
|
||||
and <a href="./AdjacencyGraph.html">AdjacencyGraph</a>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><tt>boost::graph_traits<G>::vertex_iterator</tt><br><br>
|
||||
A vertex iterator (obtained via <TT>vertices(g)</TT>) provides access
|
||||
to all of the vertices in a graph. A vertex iterator type must meet
|
||||
the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. The
|
||||
value type of the vertex iterator must be the vertex descriptor of the
|
||||
graph.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td><tt>boost::graph_traits<G>::vertices_size_type</tt><br><br>
|
||||
The unsigned integer type used to represent the number of vertices
|
||||
in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Vertex Set of the Graph</td>
|
||||
<td><a name="sec:vertices"><TT>vertices(g)</TT></a></TD>
|
||||
<TD><TT>std::pair<vertex_iterator, vertex_iterator></TT></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to all the vertices in the
|
||||
graph<TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Number of Vertices in the Graph </td>
|
||||
<td><TT>num_vertices(g)</TT></TD>
|
||||
<TD><TT>vertices_size_type</TT></TD>
|
||||
<TD>Returns the number of vertices in the graph <TT>g</TT>.</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
<P>
|
||||
The <TT>vertices()</TT> function must return in constant time.
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
|
||||
<H3>Design Rationale</H3>
|
||||
|
||||
One issue in the design of this concept is whether to include the
|
||||
refinement from the <a href="./IncidenceGraph.html">IncidenceGraph</a>
|
||||
and <a href="./AdjacencyGraph.html">AdjacencyGraph</a> concepts. The
|
||||
ability to traverse the vertices of a graph is orthogonal to
|
||||
traversing out-edges, so it would make sense to have a VertexListGraph
|
||||
concept that only includes vertex traversal. However, such a concept
|
||||
would no longer really be a graph, but would just be a set, and the
|
||||
STL already has concepts for dealing with such things. However, there
|
||||
are many BGL algorithms that need to traverse the vertices and
|
||||
out-edges of a graph, so for convenience a concept is needed that
|
||||
groups these requirements together, hence the VertexListGraph concept.
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct VertexListGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::vertex_iterator
|
||||
vertex_iterator;
|
||||
void constraints() {
|
||||
function_requires< IncidenceGraphConcept<G> >();
|
||||
function_requires< AdjacencyGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<vertex_iterator> >();
|
||||
|
||||
p = vertices(g);
|
||||
V = num_vertices(g);
|
||||
v = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = vertices(g);
|
||||
V = num_vertices(g);
|
||||
v = *p.first;
|
||||
}
|
||||
std::pair<vertex_iterator, vertex_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
typename boost::graph_traits<G>::vertices_size_type V;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,80 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Acknowledgements</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h1>Acknowledgements</h1>
|
||||
|
||||
We owe many debts of thanks to a number of individuals who both
|
||||
inspired and encouraged us in developing the Boost Graph Library.
|
||||
|
||||
<p>
|
||||
A most profound thanks goes to Alexander Stepanov for his pioneering
|
||||
work in generic programming, for his encouragement, and for his
|
||||
algorithm contributions to the BGL. We thank Matthew Austern for his
|
||||
work on documenting the concepts of STL which provided a foundation
|
||||
for creating the concepts in the BGL. We thank Dietmar Kühl for
|
||||
his work on generic graph algorithms and design patterns; especially
|
||||
for the property map abstraction.
|
||||
|
||||
<p>
|
||||
Dave Abrahams, Jens Maurer, Beman Dawes, Gary Powell, Greg Colvin,
|
||||
Valentin Bonnard, and the rest of the group at Boost provided valuable
|
||||
input to the BGL interface, numerous suggestions for improvement,
|
||||
proof reads of the documentation, and help with polishing the code. A
|
||||
special thanks to Dave Abrahams for managing the formal review.
|
||||
|
||||
<p>
|
||||
We also thank the following BGL users whose questions helped to
|
||||
improve the BGL: Gordon Woodhull, Dave Longhorn, Joel Phillips, and
|
||||
Edward Luke.
|
||||
|
||||
<p>
|
||||
A special thanks to Jeffrey Squyres for editing and proof reading
|
||||
of the documentation.
|
||||
|
||||
<p>
|
||||
Our original work on the Boost Graph Library was supported in part by
|
||||
NSF grant ACI-9982205 and by the Director, Office of Science, Division
|
||||
of Mathematical, Information, and Computational Sciences of the U.S.
|
||||
Department of Energy under contract number DE-AC03-76SF00098.
|
||||
<p>
|
||||
In our work we also used resources of the National Energy Research
|
||||
Scientific Computing Center, which is supported by the Office of
|
||||
Science of the U.S. Department of Energy.
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,162 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Graph Traits</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME=""></A>
|
||||
<pre>
|
||||
adjacency_list_traits<EdgeList, VertexList, Directed>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class provides an alternate method for accessing some of the
|
||||
associated types of the <tt>adjacency_list</tt> class. The main reason
|
||||
for this class is that sometimes one would like to create graph
|
||||
properties whose values are vertex or edge descriptors. If you try to
|
||||
use <tt>graph_traits</tt> for this you will run into a problem with
|
||||
mutually recursive types. To get around this problem, the
|
||||
<tt>adjacency_list_traits</tt> class is provided, which gives the user
|
||||
access to the vertex and edge descriptor types without requiring the
|
||||
user to provide the property types for the graph.
|
||||
|
||||
<pre>
|
||||
template <class EdgeList, class VertexList, class Directed>
|
||||
struct adjacency_list_traits {
|
||||
typedef ... vertex_descriptor;
|
||||
typedef ... edge_descriptor;
|
||||
typedef ... directed_category;
|
||||
typedef ... edge_parallel_category;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/adjacency_list.hpp"><tt>boost/graph/adjacency_list.hpp</tt></a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EdgeList</TT></TD>
|
||||
<TD>
|
||||
The selector type for the edge container implementation.
|
||||
</TD>
|
||||
<td><tt>vecS</tt></td>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>VertexList</TT></TD>
|
||||
<TD>
|
||||
The selector type for the vertex container implementation.
|
||||
</TD>
|
||||
<td><tt>vecS</tt></td>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>Directed</TT></TD>
|
||||
<TD>
|
||||
The selector type whether the graph is directed or undirected.
|
||||
</TD>
|
||||
<td><tt>directedS</tt></td>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a> and
|
||||
<a href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>
|
||||
|
||||
<h3>Type Requirements</h3>
|
||||
|
||||
Under construction.
|
||||
|
||||
<H2>Members</H2>
|
||||
|
||||
<p>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Member</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
vertex_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identify vertices in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identify edges in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
directed_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph is undirected (<tt>undirected_tag</tt>)
|
||||
or directed (<tt>directed_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_parallel_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph allows parallel edges to be inserted
|
||||
(<tt>allow_parallel_edge_tag</tt>) or if it automatically removes
|
||||
parallel edges (<tt>disallow_parallel_edge_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./adjacency_list.html"><tt>adjacency_list</tt></a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,551 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Jeremy Siek makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Adjacency Matrix</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:adjacency-matrix-class"></A>
|
||||
<pre>
|
||||
adjacency_matrix<Directed, VertexProperty,
|
||||
EdgeProperty, GraphProperty,
|
||||
Allocator>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
The <tt>adjacency_matrix</tt> class implements the BGL graph interface
|
||||
using the traditional adjacency matrix storage format. For a graph
|
||||
with <i>V</i> vertices, a <i>V x V</i> matrix is used, where each
|
||||
element <i>a<sub>ij</sub></i> is a boolean flag that says whether
|
||||
there is an edge from vertex <i>i</i> to vertex <i>j</i>. <a
|
||||
href="#fig:adj-matrix-graph">Figure 1</a> shows the adjacency matrix
|
||||
representation of a graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:adj-matrix-graph"></A><A NAME="1509"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency Matrix Representation of a Directed Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/adj-matrix-graph.gif" width="386" height="284"></TD>
|
||||
<TD><IMG SRC="./figs/adj-matrix.gif" width="135" height="136"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
The advantage of this matrix format over the adjacency list is that
|
||||
edge insertion and removal is constant time. There are several
|
||||
disadvantages. The first is that the amount of memory used is
|
||||
<i>O(V<sup>2</sup>)</i> instead of <i>O(V + E)</i> (where <i>E</i> is
|
||||
the number of edges). The second is that operations that traverse all
|
||||
the out-edges of each vertex (such as breadth-first search) run in
|
||||
<i>O(V<sup>2</sup>)</i> time instead of <i>O(V + E)</i> time for the
|
||||
adjacency list. In short, it is better to use the
|
||||
<tt>adjacency_matrix</tt> for dense graphs (where <i>E</i> is close to
|
||||
<i>V<sup>2</sup></i>) and it is better to use <a
|
||||
href="adjacency_list.html"><tt>adjacency_list</tt></a> for sparse
|
||||
graphs (where <i>E</i> is much smaller than <i>V<sup>2</sup></i>).
|
||||
|
||||
The <tt>adjacency_matrix</tt> class extends the traditional
|
||||
data-structure by allowing objects to be attached to vertices and
|
||||
edges via the the property template parameters. See Section XXX for an
|
||||
explanation of how to use internal properties.
|
||||
|
||||
In the case of an undirected graph, the
|
||||
<tt>adjacency_matrix</tt>. class does not use a full <i>V x V</i>
|
||||
matrix but instead uses a lower triangle (the diagonal and below)
|
||||
since the matrix for an undirected graph is symmetric. This reduces
|
||||
the storage to <i>(V<sup>2</sup>)/2</i>. <a
|
||||
href="#fig:undir-adj-matrix-graph">Figure 2</a> shows an adjacency
|
||||
matrix representation of an undirected graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:undir-adj-matrix-graph"></A><A NAME="1509"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency Matrix Representation of an Undirected Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/undir-adj-matrix-graph.gif" width="2573" height="60929"></TD>
|
||||
<TD><IMG SRC="./figs/undir-adj-matrix.gif" width="135" height="136"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
Creating the graph of <a href="#fig:adj-matrix-graph">Figure 1</a>.
|
||||
<pre>
|
||||
enum { A, B, C, D, E, F, N };
|
||||
const char* name = "ABCDEF";
|
||||
|
||||
typedef boost::adjacency_matrix<boost::directedS> Graph;
|
||||
Graph g(N);
|
||||
add_edge(B, C, g);
|
||||
add_edge(B, F, g);
|
||||
add_edge(C, A, g);
|
||||
add_edge(C, C, g);
|
||||
add_edge(D, E, g);
|
||||
add_edge(E, D, g);
|
||||
add_edge(F, A, g);
|
||||
|
||||
std::cout << "vertex set: ";
|
||||
boost::print_vertices(g, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "edge set: ";
|
||||
boost::print_edges(g, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "out-edges: " << std::endl;
|
||||
boost::print_graph(g, name);
|
||||
std::cout << std::endl;
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
vertex set: A B C D E F
|
||||
|
||||
edge set: (B,C) (B,F) (C,A) (C,C) (D,E) (E,D) (F,A)
|
||||
|
||||
out-edges:
|
||||
A -->
|
||||
B --> C F
|
||||
C --> A C
|
||||
D --> E
|
||||
E --> D
|
||||
F --> A
|
||||
</pre>
|
||||
|
||||
Creating the graph of <a href="#fig:undir-adj-matrix-graph">Figure 2</a>.
|
||||
<pre>
|
||||
enum { A, B, C, D, E, F, N };
|
||||
const char* name = "ABCDEF";
|
||||
|
||||
typedef boost::adjacency_matrix<boost::undirectedS> UGraph;
|
||||
UGraph ug(N);
|
||||
add_edge(B, C, ug);
|
||||
add_edge(B, F, ug);
|
||||
add_edge(C, A, ug);
|
||||
add_edge(D, E, ug);
|
||||
add_edge(F, A, ug);
|
||||
|
||||
std::cout << "vertex set: ";
|
||||
boost::print_vertices(ug, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "edge set: ";
|
||||
boost::print_edges(ug, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "incident edges: " << std::endl;
|
||||
boost::print_graph(ug, name);
|
||||
std::cout << std::endl;
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
vertex set: A B C D E F
|
||||
|
||||
edge set: (C,A) (C,B) (E,D) (F,A) (F,B)
|
||||
|
||||
incident edges:
|
||||
A <--> C F
|
||||
B <--> C F
|
||||
C <--> A B
|
||||
D <--> E
|
||||
E <--> D
|
||||
F <--> A B
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/adjacency_matrix.hpp"><tt>boost/graph/adjacency_matrix.hpp</tt></a>
|
||||
|
||||
|
||||
<h3>Template Parameters</h3>
|
||||
|
||||
<p>
|
||||
<table border>
|
||||
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>Directed</tt></td>
|
||||
<td>A selector to choose whether the graph is directed or undirected. The options are <tt>directedS</tt> and <tt>undirectedS</tt>.</td>
|
||||
<td><tt>directedS</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>VertexProperty</tt></td>
|
||||
<td>for specifying internal property storage.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>EdgeProperty</tt></td>
|
||||
<td>for specifying internal property storage.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>GraphProperty</tt></td>
|
||||
<td>for specifying property storage for the graph object.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Model Of</h3>
|
||||
|
||||
<a href="./VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>, <a
|
||||
href="./AdjacencyMatrix.html">AdjacencyMatrix</a>, and <a
|
||||
href="./MutablePropertyGraph.html">MutablePropertyGraph</a>.
|
||||
|
||||
|
||||
<h3>Associates Types</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>graph_traits<adjacency_matrix>::vertex_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the vertex descriptors associated with the
|
||||
<tt>adjacency_matrix</tt>.<br>
|
||||
(Required by <a href="./Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>graph_traits<adjacency_matrix>::edge_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the edge descriptors associated with the
|
||||
<tt>adjacency_matrix</tt>.<br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::vertex_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>vertices()</tt>.
|
||||
The vertex iterator models <a href="http://www.sgi.com/Technology/STL/RandomAccessIterator.html">RandomAccessIterator</a>. <br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edge_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>edges()</tt>. This
|
||||
iterator models <a href="http://www.sgi.com/Technology/STL/MultiPassInputIterator.html">MultiPassInputIterator</a>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::out_edge_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>out_edges()</tt>. This
|
||||
iterator models <a href="MultiPassInputIterator.html">MultiPassInputIterator</a>. <br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::adjacency_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>adjacent_vertices()</tt>. This
|
||||
iterator models the same concept as the out-edge iterator.<br>
|
||||
(Required by <a href="AdjacencyGraph.html">AdjacencyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::directed_category</tt>
|
||||
<br><br>
|
||||
Provides information about whether the graph is directed
|
||||
(<tt>directed_tag</tt>) or undirected (<tt>undirected_tag</tt>).<br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edge_parallel_category</tt>
|
||||
<br><br>
|
||||
An adjacency matrix does not allow the insertion of
|
||||
parallel edges, so this type is always
|
||||
<tt>disallow_parallel_edge_tag</tt>. <br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::vertices_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of vertices in
|
||||
the graph.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edges_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of edges in the graph.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::degree_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of out-edges of a vertex.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>property_map<adjacency_matrix, PropertyTag>::type</tt><br>
|
||||
<tt>property_map<adjacency_matrix, PropertyTag>::const_type</tt>
|
||||
<br><br>
|
||||
The map type for vertex or edge properties in the graph. The
|
||||
specific property is specified by the <tt>PropertyTag</tt> template
|
||||
argument, and must match one of the properties specified in the
|
||||
<tt>VertexProperty</tt> or <tt>EdgeProperty</tt> for the graph.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
adjacency_matrix(vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices and zero edges.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename EdgeIterator>
|
||||
adjacency_matrix(EdgeIterator first,
|
||||
EdgeIterator last,
|
||||
vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices with the edges
|
||||
specified in the edge list given by the range <tt>[first, last)</tt>.
|
||||
The value type of the <tt>EdgeIterator</tt> must be a
|
||||
<tt>std::pair</tt>, where the type in the pair is an integer type. The
|
||||
integers will correspond to vertices, and they must all fall in the
|
||||
range of
|
||||
<tt>[0, n)</tt>. <br>
|
||||
(Required by <a href="IteratorConstructibleGraph.html">IteratorConstructibleGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename EdgeIterator, typename EdgePropertyIterator>
|
||||
adjacency_matrix(EdgeIterator first, EdgeIterator last,
|
||||
EdgePropertyIterator ep_iter,
|
||||
vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices, with the edges
|
||||
specified in the edge list given by the range <tt>[first, last)</tt>.
|
||||
The value type of the <tt>EdgeIterator</tt> must be a
|
||||
<tt>std::pair</tt>, where the type in the pair is an integer type. The
|
||||
integers will correspond to vertices, and they must all fall in the
|
||||
range of <tt>[0, n)</tt>. The <tt>value_type</tt> of the
|
||||
<tt>ep_iter</tt> should be <tt>EdgeProperty</tt>.
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<vertex_iterator, vertex_iterator>
|
||||
vertices(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the vertex set of graph <tt>g</i>.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_iterator, edge_iterator>
|
||||
edges(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the edge set of graph <tt>g</i>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<adjacency_iterator, adjacency_iterator>
|
||||
adjacent_vertices(vertex_descriptor v, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the vertices adjacent to
|
||||
vertex <tt>v</i> in graph <tt>g</i>.<br>
|
||||
(Required by <a href="AdjacencyGraph.html">AdjacencyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<out_edge_iterator, out_edge_iterator>
|
||||
out_edges(vertex_descriptor v, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the out-edges of
|
||||
vertex <tt>v</i> in graph <tt>g</i>. If the graph is undirected,
|
||||
this iterator-range provides access to all edge incident on
|
||||
vertex <tt>v</i>. <br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor
|
||||
source(edge_descriptor e, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the source vertex of edge <tt>e</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor
|
||||
target(edge_descriptor e, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the target vertex of edge <tt>e</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
degree_size_type
|
||||
out_degree(vertex_descriptor u, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of edges leaving vertex <tt>u</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
<hr>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertices_size_type num_vertices(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of vertices in the graph <tt>g</i>.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
edges_size_type num_edges(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of edges in the graph <tt>g</tt>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor vertex(vertices_size_type n, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the nth vertex in the graph's vertex list.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
edge(vertex_descriptor u, vertex_descriptor v,
|
||||
const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the edge connecting vertex <tt>u</i> to vertex <tt>v</i> in graph <tt>g</i>.<br>
|
||||
(Required by <a href="AdjacencyMatrix.html">AdjacencyMatrix</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
add_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Adds edge <tt>(u,v)</i> to the graph and returns the edge descriptor for
|
||||
the new edge. If the edge is already in the graph then a duplicate
|
||||
will not be added and the <tt>bool</tt> flag will be <tt>false</tt>.
|
||||
This operation does not invalidate any of the graph's iterators
|
||||
or descriptors.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
add_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
const EdgeProperty& p,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Adds edge <tt>(u,v)</i> to the graph and attaches <tt>p</tt> as the
|
||||
value of the edge's internal property storage. Also see the previous
|
||||
<tt>add_edge()</tt> member function for more details.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void remove_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes the edge <tt>(u,v)</i> from the graph. <br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void remove_edge(edge_descriptor e, adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes the edge <tt>e</tt> from the graph. This is equivalent
|
||||
to calling <tt>remove_edge(source(e, g), target(e, g), g)</tt>.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void clear_vertex(vertex_descriptor u, adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes all edges to and from vertex <tt>u</i>. The vertex still appears
|
||||
in the vertex set of the graph.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property>
|
||||
property_map<adjacency_matrix, Property>::type
|
||||
get(Property, adjacency_matrix& g)
|
||||
|
||||
template <typename Property>
|
||||
property_map<adjacency_matrix, Property>::const_type
|
||||
get(Property, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the property map object for the vertex property specified by
|
||||
<tt>Property</tt>. The <tt>Property</tt> must match one of the
|
||||
properties specified in the graph's <tt>VertexProperty</tt> template
|
||||
argument.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property, typename X>
|
||||
typename property_traits<
|
||||
typenamae property_map<adjacency_matrix, Property>::const_type
|
||||
>::value_type
|
||||
get(Property, const adjacency_matrix& g, X x)
|
||||
</pre>
|
||||
This returns the property value for <tt>x</tt>, which is either
|
||||
a vertex or edge descriptor.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property, typename X, typename Value>
|
||||
void
|
||||
put(Property, const adjacency_matrix& g, X x, const Value& value)
|
||||
</pre>
|
||||
This sets the property value for <tt>x</tt> to
|
||||
<tt>value</tt>. <tt>x</tt> is either a vertex or edge descriptor.
|
||||
<tt>Value</tt> must be convertible to
|
||||
<tt>typename property_traits<property_map<adjacency_matrix, Property>::type>::value_type</tt>.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename GraphProperty, typename GraphProperty>
|
||||
typename property_value<GraphProperty, GraphProperty>::type&
|
||||
get_property(adjacency_matrix& g, GraphProperty)
|
||||
</pre>
|
||||
Return the property specified by <tt>GraphProperty</tt> that is attached
|
||||
to the graph object <tt>g</tt>. The <tt>property_value</tt> traits class
|
||||
is defined in <tt>boost/pending/property.hpp</tt>.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename GraphProperty, typename GraphProperty>
|
||||
const typename property_value<GraphProperty, GraphProperty>::type&
|
||||
get_property(const adjacency_matrix& g, GraphProperty)
|
||||
</pre>
|
||||
Return the property specified by <tt>GraphProperty</tt> that is
|
||||
attached to the graph object <tt>g</tt>. The <tt>property_value</tt>
|
||||
traits class is defined in <tt>boost/pending/property.hpp</tt>.
|
||||
|
||||
|
||||
<hr>
|
||||
@@ -1,10 +0,0 @@
|
||||
name: graph
|
||||
version: ~
|
||||
title: Boost.Graph
|
||||
start_page: index.adoc
|
||||
asciidoc:
|
||||
attributes:
|
||||
source-language: cpp@
|
||||
table-caption: false
|
||||
nav:
|
||||
- modules/ROOT/nav.adoc
|
||||
@@ -0,0 +1,180 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Bellman Ford Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:bellman-ford"></A>
|
||||
<TT>bellman_ford_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed or undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">distance, weight</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(V E)</i></TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/bellman_ford_shortest_paths.hpp"><TT>boost/graph/bellman_ford_shortest_paths.hpp</TT></a>
|
||||
</TD>
|
||||
</TR></TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class WeightMap, class DistanceMap>
|
||||
bool bellman_ford_shortest_paths(EdgeListGraph& g, Size N,
|
||||
WeightMap w, DistanceMap d)
|
||||
|
||||
(2)
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class WeightMap, class DistanceMap,
|
||||
class <a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>>
|
||||
bool bellman_ford_shortest_paths(EdgeListGraph& g, Size N, WeightMap w,
|
||||
DistanceMap d, BellmanFordVisitor visit)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The Bellman-Ford algorithm [<A
|
||||
HREF="bibliography.html#bellman58">4</A>,<A
|
||||
HREF="bibliography.html#ford62:_flows">11</A>,<A
|
||||
HREF="bibliography.html#lawler76:_comb_opt">20</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>] solves the single-source
|
||||
shortest paths problem for a graph with both positive and negative
|
||||
edge weights. See Section <A
|
||||
HREF="./graph_theory_review.html#sec:shortest-paths-algorithms">Shortest-Paths
|
||||
Algorithms</A> for a description of the single-source shortest paths
|
||||
problem. If a cycle with negative length is detected, the algorithm
|
||||
returns <TT>false</TT>. The argument <TT>N</TT> should be the number
|
||||
of vertices in the graph. The source vertex is indicated by
|
||||
initializing the distance of the source vertex to zero and the
|
||||
distances of the rest of the vertices to
|
||||
<TT>std::numeric_limits<T>::max()</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>EdgeListGraph</TT> must be a model of
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>Distance</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the distance map. The value type of the distance
|
||||
map must be <a
|
||||
href="http://www.sgi.com/Technology/STL/LessThanComparable.html">LessThanComparable</a>.
|
||||
</LI>
|
||||
<LI>The <TT>Weight</TT> type must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>.
|
||||
The edge descriptor of the graph needs to be usable as the key
|
||||
type for the weight map. The value type for the
|
||||
weight map must be <I>Addable</I> with the
|
||||
distance map's value type.
|
||||
</LI>
|
||||
<LI>The <TT>Parent</TT> type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
value type and key type should be the graph's vertex descriptor
|
||||
type.
|
||||
</LI>
|
||||
<LI>The type <TT>BellmanFordVisitor</TT> must be a model of <a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The source code for this example is in <a
|
||||
href="../example/bellman_ford.cpp"><TT>examples/bellman_ford.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
enum { u, v, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'x', 'y', 'z' };
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
E edges[] = { E(u,y), E(u,x), E(u,v),
|
||||
E(v,u),
|
||||
E(x,y), E(x,v),
|
||||
E(y,v), E(y,z),
|
||||
E(z,u), E(z,x) };
|
||||
|
||||
int weight[] = { -4, 8, 5,
|
||||
-2,
|
||||
9, -3,
|
||||
7, 2,
|
||||
6, 7 };
|
||||
|
||||
typedef edge_list<E*,E,ptrdiff_t> Graph;
|
||||
Graph g(edges, edges + sizeof(edges)/sizeof(E));
|
||||
|
||||
vector<int> distance(N,std::numeric_limits<short>::max());
|
||||
vector<int> parent(N,-1);
|
||||
|
||||
distance[z] = 0;
|
||||
parent[z] = z;
|
||||
bool r = bellman_ford_shortest_paths(g, int(N), weight,
|
||||
distance.begin(),
|
||||
parent.begin());
|
||||
if (r)
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[i] << ": " << distance[i]
|
||||
<< " " << name[parent[i]] << std::endl;
|
||||
else
|
||||
std::cout << "negative cycle" << std::endl;
|
||||
</PRE>
|
||||
The distance and predecessor for each vertex is:
|
||||
<PRE>
|
||||
u: 2 v
|
||||
v: 4 x
|
||||
x: 7 z
|
||||
y: -2 u
|
||||
z: 0 z
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,115 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: bellman_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
bellman_visitor<EventVisitorList>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
<tt>std::pair</tt>) into a <a
|
||||
href="./BellmanFordVisitor.html">BellmanFordVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EventVisitorList</TT></TD>
|
||||
<TD>
|
||||
A list of <a href="./EventVisitor.html">EventVisitor</a>'s created
|
||||
with <tt>std::pair</tt>.
|
||||
</TD>
|
||||
<TD><TT><a href="./null_visitor.html"><tt>null_visitor</tt></a></TT></TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/bellman_ford_shortest_paths.hpp">
|
||||
<TT>boost/graph/bellman_ford_shortest_paths.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./BellmanFordVisitor.html">BellmanFordVisitor</a>. In each function the
|
||||
appropriate event is dispatched to the <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class EventVisitorList><br>
|
||||
bellman_visitor<EventVisitorList><br>
|
||||
make_bellman_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a BellmanFordVisitor.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are event visitors: <a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
|
||||
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>
|
||||
<a href="./time_stamper.html"><tt>time_stamper</tt></a>,
|
||||
and <a href="./property_writer.html"><tt>property_writer</tt></a>.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,132 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: bfs_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
bfs_visitor<EventVisitorList>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
<tt>std::pair</tt>) into a <a href="./BFSVisitor.html">BFSVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
This is an excerpt from <a
|
||||
href="../example/bfs.cpp"><tt>examples/bfs.cpp</tt></a> where three
|
||||
event-visitors are combined to make a BFS visitor. The functions
|
||||
<tt>boost::record_distances</tt>, <tt>boost::record_predecessors</tt>,
|
||||
and <tt>copy_graph</tt> are all functions that create an event
|
||||
visitor.
|
||||
|
||||
<pre>
|
||||
// Construct graph G and obtain the source vertex s ...
|
||||
|
||||
boost::breadth_first_search(G, s,
|
||||
make_bfs_visitor(
|
||||
std::make_pair(boost::record_distances(d, boost::on_tree_edge()),
|
||||
std::make_pair(boost::record_predecessors(p.begin(),
|
||||
boost::on_tree_edge()),
|
||||
copy_graph(G_copy, boost::on_examine_edge())))) );
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./BFSVisitor.html">BFSVisitor</a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EventVisitorList</TT></TD>
|
||||
<TD>
|
||||
A list of <a href="./EventVisitor.html">EventVisitor</a>'s created
|
||||
with <tt>std::pair</tt>.
|
||||
</TD>
|
||||
<TD><a href="./null_visitor.html"><tt>null_visitor</tt></a></TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp">
|
||||
<TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./BFSVisitor.html">BFSVisitor</a>. In each function the
|
||||
appropriate event is dispatched to the <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class EventVisitorList><br>
|
||||
bfs_visitor<EventVisitorList><br>
|
||||
make_bfs_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a BFS visitor.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are event visitors: <a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
|
||||
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
|
||||
<a href="./time_stamper.html"><tt>time_stamper</tt></a>,
|
||||
and <a href="./property_writer.html"><tt>property_writer</tt></a>.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,275 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Bibliography</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2>Bibliography</H2>
|
||||
|
||||
<DL COMMapCT><DD><P></P><DT><A NAME="aho83:_data_struct_algo">1</A>
|
||||
<DD>
|
||||
A. V. Aho, J. E. Hopcroft, and J. D. Ullman.
|
||||
<BR><EM>Data Structures and Algorithms</EM>.
|
||||
<BR>Addison-Wesley, 1983.
|
||||
|
||||
<P></P><DT><A NAME="austern99:_gener_progr_stl">2</A>
|
||||
<DD>
|
||||
M. H. Austern.
|
||||
<BR><EM>Generic Programming and the STL</EM>.
|
||||
<BR>Professional computing series. Addison-Wesley, 1999.
|
||||
|
||||
<P></P><DT><A NAME="baumgartner95:_signatures">3</A>
|
||||
<DD>
|
||||
G. Baumgartner and V. F. Russo.
|
||||
<BR>Signatures: A language extension for improving type abstraction and
|
||||
subtype polymorphism in C++.
|
||||
<BR><EM>Software-Practice and Experience</EM>, 25(8):863-889, August 1995.
|
||||
|
||||
<P></P><DT><A NAME="bellman58">4</A>
|
||||
<DD>
|
||||
R. Bellman.
|
||||
<BR>On a routing problem.
|
||||
<BR><EM>Quarterly of Applied Mathematics</EM>, 16(1):87-90, 1958.
|
||||
|
||||
<P></P><DT><A NAME="bruce95">5</A>
|
||||
<DD>
|
||||
K. B. Bruce, L. Cardelli, G. Castagna, the Hopkins Objects Group, G. T.
|
||||
Leavens, and B. Pierce.
|
||||
<BR>On binary methods.
|
||||
<BR><EM>Theory and Practice of Object Systems</EM>, 1:221-242, 1995.
|
||||
|
||||
<P></P><DT><A NAME="coleman85:_algor">6</A>
|
||||
<DD>
|
||||
T. F. Coleman, B. S. Garbow, and J. J. Mor'e.
|
||||
<BR>Algorithm 649: Fortran subroutines for estimating sparse hessian
|
||||
matrices.
|
||||
<BR><EM>ACM Transactions on Mathematical Software</EM>, 11(4):378, December
|
||||
1985.
|
||||
|
||||
<P></P><DT><A NAME="coleman84:_estim_jacob">7</A>
|
||||
<DD>
|
||||
T. F. Coleman and J. J. Mor'e.
|
||||
<BR>Estimation of sparse jacobian matrices and graph coloring problems.
|
||||
<BR><EM>SIAM Journal on Numerical Analysis</EM>, 20:187-209,, 1984.
|
||||
|
||||
<P></P><DT><A NAME="clr90">8</A>
|
||||
<DD>
|
||||
T. Cormen, C. Leiserson, and R. Rivest.
|
||||
<BR><EM>Introduction to Algorithms</EM>.
|
||||
<BR>McGraw-Hill, 1990.
|
||||
|
||||
<P></P><DT><A NAME="curtis74:_jacob">9</A>
|
||||
<DD>
|
||||
A. Curtis, M. Powell, and J. Reid.
|
||||
<BR>On the estimation of sparse jacobian matrices.
|
||||
<BR><EM>Journal of the Institute of Mathematics and its Applications</EM>,
|
||||
13:117-119, 1974.
|
||||
|
||||
<P></P><DT><A NAME="dijkstra59">10</A>
|
||||
<DD>
|
||||
E. Dijkstra.
|
||||
<BR>A note on two problems in connexion with graphs.
|
||||
<BR><EM>Numerische Mathematik</EM>, 1:269-271, 1959.
|
||||
|
||||
<P></P><DT><A NAME="ford62:_flows">11</A>
|
||||
<DD>
|
||||
L. R. Ford and D. R. Fulkerson.
|
||||
<BR><EM>Flows in networks</EM>.
|
||||
<BR>Princeton University Press, 1962.
|
||||
|
||||
<P></P><DT><A NAME="gamma95:_design_patterns">12</A>
|
||||
<DD>
|
||||
E. Gamma, R. Helm, R. Johnson, and J. Vlissides.
|
||||
<BR><EM>Design Patterns: Elements of Reusable Object-Oriented Software</EM>.
|
||||
<BR>Professional Computing. Addison-Welsey, 1995.
|
||||
|
||||
<P></P><DT><A NAME="george93:graphtheory">13</A>
|
||||
<DD>
|
||||
A. George, J. R. Gilbert, and J. W. Liu, editors.
|
||||
<BR><EM>Graph Theory and Sparse Matrix Computation</EM>.
|
||||
<BR>Springer-Verlag New York, Inc, 1993.
|
||||
|
||||
<P></P><DT><A NAME="george81:__sparse_pos_def">14</A>
|
||||
<DD>
|
||||
A. George and J. W.-H. Liu.
|
||||
<BR><EM>Computer Solution of Large Sparse Positive Definite Systems</EM>.
|
||||
<BR>Computational Mathematics. Prentice-Hall, 1981.
|
||||
|
||||
<P></P><DT><A NAME="graham85">15</A>
|
||||
<DD>
|
||||
R. Graham and P. Hell.
|
||||
<BR>On the history of the minimum spanning tree problem.
|
||||
<BR><EM>Annals of the History of Computing</EM>, 7(1):43-57, 1985.
|
||||
|
||||
<P></P><DT><A NAME="hart68">16</A>
|
||||
<DD>
|
||||
P. E. Hart, N. J. Nilsson, and B. Raphael.
|
||||
<BR>A formal basis for the heuristic determination of minimum cost paths.
|
||||
<BR><EM>IEEE Transactions on Systems Science and Cybernetics</EM>,
|
||||
4(2):100-107, 1968.
|
||||
|
||||
<P></P><DT><A NAME="kruskal56">18</A>
|
||||
<DD>
|
||||
J. B. Kruskal.
|
||||
<BR>On the shortest spanning subtree of a graph and the traveling
|
||||
salesman problem.
|
||||
<BR>In <EM>Proceedings of the American Mathematical Sofiety</EM>, volume 7,
|
||||
pages 48-50, 1956.
|
||||
|
||||
<P></P><DT><A NAME="kuehl96:_design_patterns_for_graph_algo">19</A>
|
||||
<DD>
|
||||
D. Kühl.
|
||||
<BR>Design patterns for the implementation of graph algorithms.
|
||||
<BR>Master's thesis, Technische Universität Berlin, July 1996.
|
||||
|
||||
<P></P><DT><A NAME="lawler76:_comb_opt">20</A>
|
||||
<DD>
|
||||
E. L. Lawler.
|
||||
<BR><EM>Combinatorial Opimization: Networks and Matroids</EM>.
|
||||
<BR>Holt, Rinehart, and Winston, 1976.
|
||||
|
||||
<P></P><DT><A NAME="LIU:MMD">21</A>
|
||||
<DD>
|
||||
J. W. H. Liu.
|
||||
<BR>Modification of the minimum-degree algorithm by multiple elimination.
|
||||
<BR><EM>ACM Transaction on Mathematical Software</EM>, 11(2):141-153, 1985.
|
||||
|
||||
<P></P><DT><A NAME="mehlhorn99:_leda">22</A>
|
||||
<DD>
|
||||
K. Mehlhorn and S. Näher.
|
||||
<BR><EM>The LEDA Platform of Combinatorial and Geometric Computing</EM>.
|
||||
<BR>Cambridge University Press, 1999.
|
||||
|
||||
<P></P><DT><A NAME="meyer88:_object_soft_const">23</A>
|
||||
<DD>
|
||||
B. Meyer.
|
||||
<BR><EM>Object-oriented Software Construction</EM>.
|
||||
<BR>Prentice Hall International Series in Computer Science. Prentice
|
||||
Hall, 1988.
|
||||
|
||||
<P></P><DT><A NAME="myers95:_trait">24</A>
|
||||
<DD>
|
||||
N. C. Myers.
|
||||
<BR>Traits: a new and useful template technique.
|
||||
<BR><EM>C++ Report</EM>, June 1995.
|
||||
|
||||
<P></P><DT><A NAME="prim57:_short">25</A>
|
||||
<DD>
|
||||
R. Prim.
|
||||
<BR>Shortest connection networks and some generalizations.
|
||||
<BR><EM>Bell System Technical Journal</EM>, 36:1389-1401, 1957.
|
||||
|
||||
<P></P><DT><A NAME="saad96:imsms">26</A>
|
||||
<DD>
|
||||
Y. Saad.
|
||||
<BR><EM>Iterative Methods for Sparse Minear System</EM>.
|
||||
<BR>PWS Publishing Company, 1996.
|
||||
|
||||
<P></P><DT><A NAME="tarjan83:_data_struct_network_algo">27</A>
|
||||
<DD>
|
||||
R. E. Tarjan.
|
||||
<BR><EM>Data Structures and Network Algorithms</EM>.
|
||||
<BR>Society for Industrial and Applied Mathematics, 1983.
|
||||
|
||||
<P></P><DT><A NAME="parter61:_gauss">28</A>
|
||||
<DD>
|
||||
Seymour Parter.
|
||||
<BR><EM>The use of linear graphs in Gauss elimination</EM>.
|
||||
<BR>SIAM Review, 1961 3:119-130.
|
||||
|
||||
<P></P><DT><A NAME="matula72:_graph_theory_computing">29</A>
|
||||
<DD>
|
||||
D. Matula, G. Marble, and J. Isaacson
|
||||
<BR><EM>Graph coloring algorithms in Graph Theory and
|
||||
Computing</EM>.<BR>
|
||||
Academic Press, pp.104-122, 1972.
|
||||
|
||||
<P></P><DT><A NAME="garey79:computers-and-intractability">30</a>
|
||||
<DD>
|
||||
M.R. Garey and D.S. Johnson<BR>
|
||||
<EM>Computers and Intractibility: A Guide to the Theory of
|
||||
NP-Completeness</EM><BR>
|
||||
W.H. Freeman, New York, 1979.
|
||||
|
||||
<P></P><DT><A NAME="welsch67">31</a>
|
||||
<DD>D. Welsch and M. B. Powel<BR>
|
||||
<EM>An upper bound for the chromatic number of a graph and its
|
||||
application to timetabling problems</EM>
|
||||
Computer Journal, 10:85-86, 1967.
|
||||
|
||||
<P></P><DT><A NAME="brelaz79:_new">32</a>
|
||||
<DD>D. Br'elaz<BR>
|
||||
<EM>New methods to color the vertices of a graph</EM><br>
|
||||
Communications of the ACM, vol. 22, 1979, pp. 251-256.
|
||||
|
||||
<P></P><DT><A NAME="heber99:_saw">33</a>
|
||||
<DD>G. Heber, R. Biswas, G.R. Gao<BR>
|
||||
<EM>Self-Avoiding Walks over Adaptive Unstructured Grids</EM><br>
|
||||
Parallel and Distributed Processing, LNCS 1586,
|
||||
Springer-Verlag, 1999, pp. 968-977
|
||||
|
||||
|
||||
<P></P><DT><A NAME="ng-raghavan">34</a>
|
||||
<DD>Esmond G. Ng amd Padma Raghavan<BR>
|
||||
<EM>Performance of greedy ordering heuristics for sparse {C}holesky factorization</EM><br>
|
||||
SIAM Journal on Matrix Analysis and Applications (To appear)
|
||||
|
||||
<P></P><DT><A NAME="George:evolution">35</a>
|
||||
<DD>Alan George and Joseph W. H. Liu<BR>
|
||||
<EM>The Evolution of the Minimum Degree Ordering Algorithm</EM><br>
|
||||
SIAM Review, March 1989, vol. 31, num. 1, pp. 1-19.
|
||||
|
||||
<P></P><DT><A NAME="ford56:_maxim">36</a>
|
||||
<DD>L. R. Ford and D. R. Fulkerson<BR>
|
||||
<EM>Maximal flow through a network.</EM><br>
|
||||
Can. Journal of Mathematics 1956 pp.399-404
|
||||
|
||||
<P></P><DT><A NAME="goldberg85:_new_max_flow_algor">37</a>
|
||||
<DD>A. V. Goldberg<BR>
|
||||
<EM>A New Max-Flow Algorithm.</EM><br>
|
||||
MIT Tehnical report MIT/LCS/TM-291, 1985.
|
||||
|
||||
<P></P><DT><A NAME="karzanov74:_deter">38</a>
|
||||
<DD>A. V. Karzanov<BR>
|
||||
<EM>Determining the maximal flow in a network by the method of preflows.</EM><br>
|
||||
Sov. Math. Dokl. 1974
|
||||
|
||||
<P></P><DT><A NAME="ahuja93:_network_flows">39</a>
|
||||
<DD>Ravindra K. Ahuja and Thomas L. Magnanti and James B. Orlin<BR>
|
||||
<EM>Network Flows: Theory, Algorithms, and Applications.</EM><br>
|
||||
Prentice Hall, 1993.
|
||||
|
||||
<P></P><DT><A NAME="edmonds72:_improvements_netflow">40</a>
|
||||
<DD>Jack Edmonds and Richard M. Karp<BR>
|
||||
<EM>Theoretical improvements in the algorithmic efficiency for network flow problems.</EM><br>
|
||||
Journal of the ACM, 1972 19:248-264
|
||||
|
||||
|
||||
</DL>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,246 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Breadth-First Search</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bfs">
|
||||
<TT>breadth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./BFSVisitor.html">BFSVisitor</a>>
|
||||
void breadth_first_search(VertexListGraph& G,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
BFSVisitor vis);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./BFSVisitor.html">BFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void breadth_first_search(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
BFSVisitor vis, ColorMap color);
|
||||
|
||||
(3)
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./Buffer.html">Buffer</a>, <a href="./BFSVisitor.html">BFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void breadth_first_search(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The breadth-first search (BFS) algorithm is not really an algorithm in
|
||||
the sense that it has a particular purpose. Instead BFS is more like
|
||||
an algorithm <I>pattern</I>. One can do many different things with
|
||||
BFS. For example, the BFS pattern is used in the BGL to build several
|
||||
other algorithms: Dijkstra's shortest paths, Prim's Minimum Spanning
|
||||
Tree and best-first search. The definition of a <I>breadth-first
|
||||
search</I> is given in Section <A
|
||||
HREF="./graph_theory_review.html#sec:bfs-algorithm">Breadth-First
|
||||
Search</A>.
|
||||
|
||||
<P>
|
||||
The BGL BFS functions are highly parameterized so that they can be
|
||||
used in a wide variety of places. The way to customize the BFS
|
||||
algorithm to perform different operations is to supply a visitor,
|
||||
which is a function object with multiple functions. Each member
|
||||
function of the visitor gets invoked at special times during the
|
||||
algorithm as specified by <a
|
||||
href="./BFSVisitor.html">BFSVisitor</a>. Also, visitors can be layered
|
||||
on top of each other so that one can do lots of things during a single
|
||||
run of BFS. See the <a href="./bfs_visitor.html">bfs_visitor</a> class
|
||||
and the <A HREF="./EventVisitor.html">EventVisitor</A> concept for
|
||||
more details.
|
||||
|
||||
<P>
|
||||
Another way to customize the BFS algorithm is change the type of queue
|
||||
used. For instance, <TT>dijkstra_shortest_paths()</TT> uses a priority
|
||||
queue.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by BFS to keep track of which vertices
|
||||
have been visited. At the beginning of the algorithm all vertices are
|
||||
white. As the algorithm proceeds, vertices are colored gray as they
|
||||
are inserted into the queue, and then colored black when they are
|
||||
finished and removed from queue.
|
||||
|
||||
|
||||
<P>
|
||||
Version 1 of the algorithm takes only three arguments: the graph
|
||||
object, the source vertex, and a visitor to specify the actions to be
|
||||
taken during the graph search. The algorithm will need to use a color
|
||||
property which must be provided by the graph object (through a vertex
|
||||
color property).
|
||||
|
||||
<P>
|
||||
Version 2 of the algorithm adds a color property argument to
|
||||
accommodate the use of an external property map.
|
||||
|
||||
<P>
|
||||
Version 3 of the algorithm is the most generalized. It adds a
|
||||
parameter for the queue. This version does not initialize the color of
|
||||
all the vertices to white at the start of the algorithm or invoke the
|
||||
<tt>initialize_vertex()</tt> visitor method, so that must be taken
|
||||
care of before calling this versin of <tt>breadth_first_search()</tt>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp"><TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>IncidenceGraph</TT> must be a model of <a href="./IncidenceGraph.html">IncidenceGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>BFSVisitor</TT> must be a model of <a href="./BFSVisitor.html">BFSVisitor</a>.
|
||||
</LI>
|
||||
<LI>In version (1) of the algorithm the graph must be a model
|
||||
of <a href="./PropertyGraph.html">PropertyGraph</a> for
|
||||
<TT>vertex_color_t</TT> and
|
||||
the color property map for the graph must meet the
|
||||
same requirements as <TT>ColorMap</TT>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>.
|
||||
A vertex descriptor must be usable as the key type of the map,
|
||||
and the value type of the map must be a model of <a
|
||||
href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI>The type <TT>Buffer</TT> must be a model of <a href="./Buffer.html">Buffer</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001330300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001330400000000000000">
|
||||
Example</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
This example demonstrates using the BGL Breadth-first search algorithm
|
||||
on the graph from <A
|
||||
HREF="./graph_theory_review.html#fig:bfs-example">Figure 5</A>. The
|
||||
source code for this example is in <a
|
||||
href="../example/bfs_basics.cpp"><TT>examples/bfs_basics.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Select the graph type we wish to use
|
||||
typedef adjacency_list<vecS, undirectedS> Graph;
|
||||
// Set up the vertex ID's and names
|
||||
enum { r, s, t, u, v, w, x, y, N };
|
||||
char name[] = { 'r', 's', 't', 'u', 'v', 'w', 'x', 'y' };
|
||||
// Specify the edges in the graph
|
||||
typedef pair<int,int> E;
|
||||
E edge_array[] = { E(r,s), E(r,v), E(s,w), E(w,r), E(w,t),
|
||||
E(w,x), E(x,t), E(t,u), E(x,y), E(u,y) };
|
||||
// Create the graph object
|
||||
Graph G(N, edge_array, edge_array + sizeof(edge_array)/sizeof(E));
|
||||
|
||||
// Some typedef's to save a little typing
|
||||
typedef Graph::vertex_descriptor Vertex;
|
||||
typedef std::vector<Vertex>::iterator Piter;
|
||||
typedef std::vector<Graph::size_type>::iterator Iiter;
|
||||
|
||||
// vectors to hold color, discover time, and finish time properties
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
std::vector<Graph::size_type> dtime(num_vertices(G));
|
||||
std::vector<Graph::size_type> ftime(num_vertices(G));
|
||||
|
||||
breadth_first_search(G, vertex(s,G),
|
||||
visit_timestamp(dtime.begin(), ftime.begin()),
|
||||
color.begin());
|
||||
|
||||
// Use std::sort to order the vertices by their discover time
|
||||
vector<Graph::size_type> discover_order(N);
|
||||
iota(discover_order.begin(), discover_order.end(), 0);
|
||||
std::sort(discover_order.begin(), discover_order.end(),
|
||||
indirect_cmp<Iiter, std::less<Graph::size_type> >(dtime.begin()));
|
||||
|
||||
cout << "order of discovery: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
cout << name[ discover_order[i] ] << " ";
|
||||
|
||||
vector<Graph::size_type> finish_order(N);
|
||||
iota(finish_order.begin(), finish_order.end(), 0);
|
||||
std::sort(finish_order.begin(), finish_order.end(),
|
||||
indirect_cmp<Iiter, std::less<Graph::size_type> >(ftime.begin()));
|
||||
|
||||
cout << endl << "order of finish: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
cout << name[ finish_order[i] ] << " ";
|
||||
cout << endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
order of discovery: s r w v t x u y
|
||||
order of finish: s r w v t x u y
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and
|
||||
<a href="./depth_first_search.html"><tt>depth_first_search()</tt></a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/graph
|
||||
#
|
||||
# Picked up by boostorg/release-tools' build_docs/{linuxdocs.sh,macosdocs.sh,
|
||||
# windowsdocs.ps1} via auto-detection: presence of this file selects the
|
||||
# Antora build pipeline. Output lands in doc/build/site/.
|
||||
|
||||
set -xe
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
PLAYBOOK="playbook.yml"
|
||||
else
|
||||
PLAYBOOK="$1"
|
||||
fi
|
||||
|
||||
echo "Installing npm dependencies..."
|
||||
npm ci
|
||||
|
||||
echo "Building docs with Antora using $PLAYBOOK..."
|
||||
PATH="$(pwd)/node_modules/.bin:${PATH}"
|
||||
export PATH
|
||||
npx antora --clean --fetch "$PLAYBOOK"
|
||||
echo "Done"
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compiles every .cpp under modules/ROOT/examples/ with -std=c++14, runs it,
|
||||
# and writes stdout to a sibling .txt file that Antora pages can include.
|
||||
#
|
||||
# Usage:
|
||||
# BOOST_INCLUDE=/path/to/boost/include \
|
||||
# BOOST_LIB=/path/to/boost/lib \
|
||||
# ./build_example_outputs.sh
|
||||
#
|
||||
# Defaults below match the Conan-installed Boost 1.79 layout used for
|
||||
# local development. CI overrides them.
|
||||
|
||||
set -u
|
||||
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
REPO_ROOT=$(cd "$HERE/.." && pwd)
|
||||
EXAMPLES_ROOT="$HERE/modules/ROOT/examples"
|
||||
|
||||
: "${BOOST_INCLUDE:=$HOME/.conan/data/boost/1.79.0/_/_/package/2c7a64ca03ffe00ac4600bf373ea3ecf338b36d9/include}"
|
||||
: "${BOOST_LIB:=}"
|
||||
: "${CXX:=g++}"
|
||||
: "${CXXFLAGS:=-std=c++14 -O1 -w}"
|
||||
|
||||
if [ ! -d "$BOOST_INCLUDE" ]; then
|
||||
echo "BOOST_INCLUDE not found: $BOOST_INCLUDE" >&2
|
||||
echo "Set BOOST_INCLUDE to the Boost include directory and re-run." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Per-example link flags. A handful of examples need the prebuilt
|
||||
# boost_graph library (graphviz, graphml readers and the isomorphism
|
||||
# example pull in non-header-only code).
|
||||
extra_libs_for() {
|
||||
case "$1" in
|
||||
io/graphml.cpp|io/graphviz.cpp|algorithms/isomorphism/isomorphism.cpp)
|
||||
echo "-lboost_graph"
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
LDFLAGS=""
|
||||
if [ -n "$BOOST_LIB" ]; then
|
||||
LDFLAGS="-L$BOOST_LIB -Wl,-rpath,$BOOST_LIB"
|
||||
fi
|
||||
|
||||
WORK=$(mktemp -d)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
ok=0
|
||||
fail=0
|
||||
fail_list=""
|
||||
|
||||
while IFS= read -r src; do
|
||||
rel=${src#"$EXAMPLES_ROOT/"}
|
||||
out_txt=${src%.cpp}.txt
|
||||
bin="$WORK/$(basename "$src" .cpp).out"
|
||||
extra=$(extra_libs_for "$rel")
|
||||
|
||||
if ! "$CXX" $CXXFLAGS \
|
||||
-I"$REPO_ROOT/include" -I"$BOOST_INCLUDE" \
|
||||
"$src" -o "$bin" $LDFLAGS $extra 2>/dev/null; then
|
||||
printf ' [compile FAIL] %s\n' "$rel"
|
||||
fail=$((fail + 1))
|
||||
fail_list+="$rel (compile)\n"
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! "$bin" > "$out_txt.tmp" 2>&1; then
|
||||
printf ' [run FAIL] %s\n' "$rel"
|
||||
rm -f "$out_txt.tmp"
|
||||
fail=$((fail + 1))
|
||||
fail_list+="$rel (run)\n"
|
||||
continue
|
||||
fi
|
||||
|
||||
mv "$out_txt.tmp" "$out_txt"
|
||||
printf ' [OK] %s\n' "$rel"
|
||||
ok=$((ok + 1))
|
||||
done < <(find "$EXAMPLES_ROOT" -name '*.cpp' | sort)
|
||||
|
||||
echo
|
||||
echo "Generated $ok .txt outputs, $fail failures."
|
||||
if [ "$fail" -gt 0 ]; then
|
||||
printf "Failing examples:\n$fail_list"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,108 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Challenge</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h2>Boost Graph Library Challenge and To-Do Items</h2>
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Polish up code/docs for pending items and champion the formal
|
||||
review. The pending items are:</li>
|
||||
<ul>
|
||||
<li><tt>container_traits.hpp</tt> (this should also include
|
||||
the work Matt Austern is doing on this topic)</li>
|
||||
|
||||
<li><tt>property.hpp</tt></li>
|
||||
|
||||
<li>The queues and heaps: <tt>queue.hpp</tt>,
|
||||
<tt>mutable_queue.hpp</tt>, <tt>fibonacci_heap.hpp</tt>.
|
||||
Somehow merge implementation with Dietmer's heaps and queues.</li>
|
||||
|
||||
<li><tt>disjoint_sets</tt> </li>
|
||||
</ul>
|
||||
|
||||
<li>Port the graph library to Borland C++</li>
|
||||
|
||||
<li>Construct a set of planar graph algorithms.</li>
|
||||
<ul>
|
||||
<li> Is the graph planar?</li>
|
||||
<li> "Walk around the block" and similar open and closed neighborhood
|
||||
traversals. Note that edge traversals need to resolve to particular ends
|
||||
and sides (see below), not just to the edge as a whole.</li>
|
||||
<li> Given a point, find the nearest vertex, edge, or bounded polygon.
|
||||
Again, edges are viewed as having left and right sides.</li>
|
||||
<li> Given a line segment, find intersecting vertices, edges, or bounded
|
||||
polygons.</li>
|
||||
<li> Given a polygon, find intersecting whatever...</li>
|
||||
<li> Various minimum bounding rectangle and clipping problems.</li>
|
||||
<li> Construct a planar embedding of a planar graph.</li>
|
||||
<li> Find a balanced separator of a graph.</li>
|
||||
<li> Modify adjacency_list so that the out-edges can be ordered
|
||||
according to a user defined comparison object.</li>
|
||||
</ul>
|
||||
|
||||
<li>Floyd-Warshall algorithm.</li>
|
||||
|
||||
<li>Rewrite the Qhull algorithm using the Boost Graph Library.</li>
|
||||
|
||||
<li>Explore the use of Algorithm Objects as an alternative to
|
||||
the current approach with visitors.</li>
|
||||
|
||||
<li>Analyze the algorithms that do not yet have visitors, and
|
||||
come up with visitor interfaces for them.</li>
|
||||
|
||||
<li>Add a check in the adjacency_list class to make sure
|
||||
all the vertex property template arguments have kind=vertex_property_tag
|
||||
and all edge property template arguments have kind=edge_property_tag.</li>
|
||||
|
||||
<li>Clean up the output functions in graph_utility.hpp to
|
||||
use streams, and document all the utility functions. Replace
|
||||
the random number stuff with calls to the boost random number generator.</li>
|
||||
|
||||
<li>Modularize the tests in test/graph.cpp to apply to particular
|
||||
concepts. Make sure there are run-time tests for every BGL concept.</li>
|
||||
|
||||
<li>Write tests for the BGL algorithms. Currently the examples
|
||||
are used as a sanity check, but they do not constitute a real test. </li>
|
||||
|
||||
<li>Write up the examples from Knuth's <i>Stanford GraphBase</i> using
|
||||
the BGL. The file <a
|
||||
href="../example/miles_span.cpp"><tt>examples/miles_span.cpp</tt></a>
|
||||
is a start.
|
||||
|
||||
<li>Create a class to support sub-graph views of a graph, where a
|
||||
sub-graph behaves just like a graph, but shares vertex and edge
|
||||
properties with the original graph. Perhaps even support sub-graphs
|
||||
of sub-graphs, etc.
|
||||
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,267 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Jeremy Siek makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Connected Components</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1>
|
||||
<A NAME="sec:connected-components"></A><A NAME="sec:strongly-connected-components"></A>
|
||||
<TT>connected_components</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">see below</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">components, color, discover time, finish time</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components>
|
||||
typename property_traits< Components >::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
Visitor v);
|
||||
|
||||
(2)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components, class Color>
|
||||
typename property_traits<Components>::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
Color color, Visitor v);
|
||||
|
||||
(3)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components, class DiscoverTime,
|
||||
class FinishTime, class Color>
|
||||
typename property_traits<Components>::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
DiscoverTime d, FinishTime f,
|
||||
Color color, Visitor v);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <TT>connected_component()</TT> function dispatches to two different
|
||||
algorithms depending on whether the graph in question is directed or
|
||||
undirected.
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>Computes the strongly connected components of a directed graph
|
||||
using the DFS/transpose/DFS algorithm [<A
|
||||
HREF="bibliography.html#aho83:_data_struct_algo">1</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>].
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
<LI>Computes the connected components of an undirected graph using
|
||||
a DFS-based approach. If the connected-components are to be
|
||||
calculated over and over while a graph is changing the disjoint-set
|
||||
based approach of function
|
||||
<TT>dynamic_connected_components()</TT> is faster. For
|
||||
``static'' graphs this DFS-based approach is faster [<A
|
||||
HREF="bibliography.html#clr90">8</A>].
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The output of the algorithm is recorded in the component property
|
||||
map <TT>c</TT>, which will contain numbers giving the component ID
|
||||
assigned to each vertex. The number of components is the return value
|
||||
of the function.
|
||||
|
||||
<P>
|
||||
The algorithm requires the use of several property maps: color,
|
||||
discover time, and finish time. There are several versions of this
|
||||
algorithm to accommodate whether you wish to use interior or exterior
|
||||
property maps.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Definitions</H3>
|
||||
|
||||
<P>
|
||||
A <I>connected component</I> of an undirected graph is a set of
|
||||
vertices that are all reachable from each other. A <I>strongly
|
||||
connected component</I> of a directed graph <i>G=(V,E)</i> is a
|
||||
maximal set of vertices <i>U</i> which is in <i>V</i> such that for
|
||||
every pair of vertices <i>u</i> and <i>v</i> in <i>U</i>, we have both
|
||||
a path from <i>u</i> to <i>v</i> and path from <i>v</i> to
|
||||
<i>u</i>. That is to say that <i>u</i> and <i>v</i> are reachable from
|
||||
each other.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The graph type must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
|
||||
</LI>
|
||||
<LI><TT>DiscoverTime</TT> and <TT>FinishTime</TT> must be models of <a
|
||||
href="../../property_map/WritablePropertyMap.html">WritablePropertyMap</a>
|
||||
and their value type must be an integer type. Vertex descriptors from
|
||||
the graph should be usable as the key type for these maps.
|
||||
</LI>
|
||||
<LI>The <TT>Color</TT> map must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>
|
||||
and the graph's vertex descriptor type should be usable as the
|
||||
map's key type. The value type of the map must be a
|
||||
model of <I>ColorValue</I>.
|
||||
</LI>
|
||||
<LI>The <TT>Components</TT> type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
value type of the <TT>Components</TT> property map should be
|
||||
an integer type, preferably the same as the <TT>size_type</TT> of
|
||||
the graph. The key type should be the graph's vertex descriptor
|
||||
type.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the strongly connected components algorithm is
|
||||
<i>O(V + E)</i>. The time complexity for the connected components
|
||||
algorithm is also <i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Calculating the connected components of an undirected graph. The
|
||||
complete source is in file <a
|
||||
href="../example/connected_components.cpp"><tt>examples/connected_components.cpp</tt></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef discover_time_property< finish_time_property
|
||||
< color_property<> > > VertexProperty;
|
||||
typedef adjacency_list <vecS, vecS, undirectedS, VertexProperty> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 4, G);
|
||||
add_edge(4, 0, G);
|
||||
add_edge(2, 5, G);
|
||||
|
||||
std::vector<int> c(num_vertices(G));
|
||||
int num = connected_components(G, c.begin(),
|
||||
get_color_map(G), null_visitor());
|
||||
|
||||
cout << endl;
|
||||
std::vector<int>::iterator i;
|
||||
cout << "Total number of components: " << num << endl;
|
||||
for (i = c.begin(); i != c.end(); ++i)
|
||||
cout << "Vertex " << i - c.begin()
|
||||
<< " is in component " << *i << endl;
|
||||
cout << endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
Total number of components: 3
|
||||
Vertex 0 is in component 1
|
||||
Vertex 1 is in component 1
|
||||
Vertex 2 is in component 2
|
||||
Vertex 3 is in component 3
|
||||
Vertex 4 is in component 1
|
||||
Vertex 5 is in component 2
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Calculating the strongly connected components of a directed graph.
|
||||
<PRE>
|
||||
typedef discover_time_property< finish_time_property
|
||||
< color_property<> > > VertexProperty;
|
||||
typedef adjacency_list< vecS, vecS, directedS, VertexProperty > Graph;
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 1, G);
|
||||
add_edge(1, 3, G);
|
||||
add_edge(1, 4, G);
|
||||
add_edge(4, 3, G);
|
||||
add_edge(3, 4, G);
|
||||
add_edge(3, 0, G);
|
||||
add_edge(5, 2, G);
|
||||
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
std::vector<int> c(N);
|
||||
int num = connected_components(G, c.begin(),
|
||||
get_color_map(G), null_visitor());
|
||||
|
||||
cout << endl;
|
||||
cout << "Total number of components: " << num << endl;
|
||||
std::vector<int>::iterator i;
|
||||
for (i = c.begin(); i != c.end(); ++i)
|
||||
cout << "Vertex " << i - c.begin()
|
||||
<< " is in component " << *i << endl;
|
||||
}
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
Total number of components: 3
|
||||
Vertex 0 is in component 3
|
||||
Vertex 1 is in component 3
|
||||
Vertex 2 is in component 2
|
||||
Vertex 3 is in component 3
|
||||
Vertex 4 is in component 3
|
||||
Vertex 5 is in component 1
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,187 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Constructing Graph Algorithms</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Constructing graph algorithms with BGL</H1>
|
||||
|
||||
<P>
|
||||
The <I>main</I> goal of BGL is not to provide a nice graph class, or
|
||||
to provide a comprehensive set of reusable graph algorithms (though
|
||||
these are goals). The main goal of BGL is to encourage others to
|
||||
write reusable graph algorithms. By reusable we mean maximally
|
||||
reusable. Generic programming is a methodology for making algorithms
|
||||
maximally reusable, and in this section we will discuss how to apply
|
||||
generic programming to constructing graph algorithms.
|
||||
|
||||
<P>
|
||||
To illustrate the generic programming process we will step though the
|
||||
construction of a graph coloring algorithm. The graph coloring problem
|
||||
(or more specifically, the vertex coloring problem) is to label each
|
||||
vertex in a graph <i>G</i> with a color such that no two adjacent
|
||||
vertices are labeled with the same color and such that the minimum
|
||||
number of colors are used. In general, the graph coloring problem is
|
||||
NP-complete, and therefore it is impossible to find an optimal
|
||||
solution in a reasonable amount of time. However, there are many
|
||||
algorithms that use heuristics to find colorings that are close to the
|
||||
minimum.
|
||||
|
||||
<P>
|
||||
The particular algorithm we present here is based on the linear time
|
||||
<TT>SEQ</TT> subroutine that is used in the estimation of sparse
|
||||
Jacobian and Hessian matrices [<A
|
||||
HREF="bibliography.html#curtis74:_jacob">9</A>,<A
|
||||
HREF="bibliography.html#coleman84:_estim_jacob">7</A>,<A
|
||||
HREF="bibliography.html#coleman85:_algor">6</A>]. This algorithm
|
||||
visits all of the vertices in the graph according to the order defined
|
||||
by the input order. At each vertex the algorithm marks the colors of
|
||||
the adjacent vertices, and then chooses the smallest unmarked color
|
||||
for the color of the current vertex. If all of the colors are already
|
||||
marked, a new color is created. A color is considered marked if its
|
||||
mark number is equal to the current vertex number. This saves the
|
||||
trouble of having to reset the marks for each vertex. The
|
||||
effectiveness of this algorithm is highly dependent on the input
|
||||
vertex order. There are several ordering algorithms, including the
|
||||
<I>largest-first</I> [<A HREF="bibliography.html#welsch67">31</A>],
|
||||
<I>smallest-last</I> [<a
|
||||
href="bibliography.html#matula72:_graph_theory_computing">29</a>], and
|
||||
<I>incidence degree</I> [<a
|
||||
href="bibliography.html#brelaz79:_new">32</a>] algorithms, which
|
||||
improve the effectiveness of this coloring algorithm.
|
||||
|
||||
<P>
|
||||
The first decision to make when constructing a generic graph algorithm
|
||||
is to decide what graph operations are necessary for implementing the
|
||||
algorithm, and which graph concepts the operations map to. In this
|
||||
algorithm we will need to traverse through all of the vertices to
|
||||
intialize the vertex colors. We also need to access the adjacent
|
||||
vertices. Therefore, we will choose the <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a> concept because it
|
||||
is the minimum concept that includes these operations. The graph type
|
||||
will be parameterized in the template function for this algorithm. We
|
||||
do not restrict the graph type to a particular graph class, such as
|
||||
the BGL <a href="./adjacency_list.html"><TT>adjacency_list</TT></a>,
|
||||
for this would drastically limit the reusability of the algorithm (as
|
||||
most algorithms written to date are). We do restrict the graph type to
|
||||
those types that model <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>. This is enforced by
|
||||
the use of those graph operations in the algorithm, and furthermore by
|
||||
our explicit requirement added as a concept check with
|
||||
<TT>function_requires()</TT> (see Section <A
|
||||
HREF="../../concept_check/concept_check.htm">Concept
|
||||
Checking</A> for more details about concept checking).
|
||||
|
||||
<P>
|
||||
Next we need to think about what vertex or edge properties will be
|
||||
used in the algorithm. In this case, the only property is vertex
|
||||
color. The most flexible way to specify access to vertex color is to
|
||||
use the propery map interface. This gives the user of the
|
||||
algorithm the ability to decide how they want to store the properties.
|
||||
Since we will need to both read and write the colors we specify the
|
||||
requirements as <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
<TT>key_type</TT> of the color map must be the
|
||||
<TT>vertex_descriptor</TT> from the graph, and the <TT>value_type</TT>
|
||||
must be some kind of integer. We also specify the interface for the
|
||||
<TT>order</TT> parameter as a property map, in this case a <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. For
|
||||
order, the <TT>key_type</TT> is an integer offset and the
|
||||
<TT>value_type</TT> is a <TT>vertex_descriptor</TT>. Again we enforce
|
||||
these requirements with concept checks. The return value of this
|
||||
algorithm is the number of colors that were needed to color the graph,
|
||||
hence the return type of the function is the graph's
|
||||
<TT>vertices_size_type</TT>. The following code shows the interface for our
|
||||
graph algorithm as a template function, the concept checks, and some
|
||||
typedefs. The implementation is straightforward, the only step not
|
||||
discussed above is the color initialization step, where we set the
|
||||
color of all the vertices to ``uncolored''.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
namespace boost {
|
||||
template <class VertexListGraph, class Order, class Color>
|
||||
typename graph_traits<VertexListGraph>::vertices_size_type
|
||||
sequential_vertex_color_ting(const VertexListGraph& G,
|
||||
Order order, Color color)
|
||||
{
|
||||
typedef graph_traits<VertexListGraph> GraphTraits;
|
||||
typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
|
||||
typedef typename GraphTraits::vertices_size_type size_type;
|
||||
typedef typename property_traits<Color>::value_type ColorType;
|
||||
typedef typename property_traits<Order>::value_type OrderType;
|
||||
|
||||
function_requires< VertexListGraphConcept<VertexListGraph> >();
|
||||
function_requires< ReadWritePropertyMapConcept<Color, vertex_descriptor> >();
|
||||
function_requires< IntegerConcept<ColorType> >();
|
||||
function_requires< size_type, ReadablePropertyMapConcept<Order> >();
|
||||
typedef typename same_type<OrderType, vertex_descriptor>::type req_same;
|
||||
|
||||
size_type max_color = 0;
|
||||
const size_type V = num_vertices(G);
|
||||
std::vector<size_type>
|
||||
mark(V, numeric_limits_max(max_color));
|
||||
|
||||
typename GraphTraits::vertex_iterator v, vend;
|
||||
for (tie(v, vend) = vertices(G); v != vend; ++v)
|
||||
color[*v] = V - 1; // which means "not colored"
|
||||
|
||||
for (size_type i = 0; i < V; i++) {
|
||||
vertex_descriptor current = order[i];
|
||||
|
||||
// mark all the colors of the adjacent vertices
|
||||
typename GraphTraits::adjacency_iterator ai, aend;
|
||||
for (tie(ai, aend) = adjacent_vertices(current, G); ai != aend; ++ai)
|
||||
mark[color[*ai]] = i;
|
||||
|
||||
// find the smallest color unused by the adjacent vertices
|
||||
size_type smallest_color = 0;
|
||||
while (smallest_color < max_color && mark[smallest_color] == i)
|
||||
++smallest_color;
|
||||
|
||||
// if all the colors are used up, increase the number of colors
|
||||
if (smallest_color == max_color)
|
||||
++max_color;
|
||||
|
||||
color[current] = smallest_color;
|
||||
}
|
||||
return max_color;
|
||||
}
|
||||
} // namespace boost
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,223 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Depth-First Search</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:depth-first-search"></A>
|
||||
<TT>depth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/depth_first_search.hpp"><TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>>
|
||||
void depth_first_search(VertexListGraph& G, DFSVisitor v);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void depth_first_search(VertexListGraph& G, DFSVisitor v, ColorMap c);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <TT>depth_first_search()</TT> algorithm performs a depth-first
|
||||
search (DFS) on a graph, invoking the methods of the graph search
|
||||
visitor at the appropriate event-points. A depth-first search visits
|
||||
all the vertices in a graph, starting with some arbitrary vertex and
|
||||
then always choosing the next adjacent unvisited vertex. Once the DFS
|
||||
reaches a vertex with no unvisited neighbors it backtracks to one of
|
||||
the previous vertices and continues from there. Once all of the
|
||||
vertices in the same connected component have been visited, another
|
||||
arbitrary unvisited vertex is choosen and the depth-first search
|
||||
resumes. A more detailed explanation of DFS is given in Section <A
|
||||
HREF="./graph_theory_review.html#sec:dfs-algorithm">Depth-First
|
||||
Search</A>. The depth-first exploration of each connected component is
|
||||
implemented by the function <a
|
||||
href="./depth_first_visit.html"><tt>depth_first_visit()</tt></a>.
|
||||
|
||||
|
||||
<p>
|
||||
The <tt>DFSVisitor</tt> supplied by the user determines what
|
||||
actions are taken at each event-point within the algorithm.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by the algorithm to keep track
|
||||
of which vertices have been visited.
|
||||
|
||||
<P>
|
||||
DFS is used as the kernel for several other graph algorithms,
|
||||
including <a
|
||||
href="./topological_sort.html"><tt>topological_sort</tt></a> and two
|
||||
of the connected component algorithms.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<LI>In version (1) of the algorithm the graph must be a model of <a
|
||||
href="./PropertyGraph.html">PropertyGraph</a> for
|
||||
<TT>vertex_color_t</TT> and the color property map for the graph
|
||||
must meet the same requirements as <TT>ColorMap</TT>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The key type of <tt>ColorMap</tt> must be the vertex descriptor type for the graph and the value type of <TT>ColorMap</TT> must be a model of
|
||||
<a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI>The <tt>DFSVisitor</tt> type must be a model of <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001340300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
This example shows DFS applied to the graph in <A
|
||||
HREF="./graph_theory_review.html#fig:dfs-example">Figure 1</A>. The
|
||||
source code for this example is in <a
|
||||
href="../example/dfs_basics.cpp"><TT>examples/dfs_basics.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<p></p>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:dfs-example"></A></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
Depth-first search spreading through a graph.
|
||||
</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/dfs_example.gif" width="166" height="91"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
<p></p>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Select the graph type we wish to use
|
||||
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> Graph;
|
||||
// Set up the vertex names
|
||||
enum { u, v, w, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||
// Specify the edges in the graph
|
||||
typedef std::pair<int,int> E;
|
||||
E edge_array[] = { E(u,v), E(u,x), E(x,v), E(y,x),
|
||||
E(v,y), E(w,y), E(w,z), E(z,z) };
|
||||
Graph G(N, edge_array, edge_array + sizeof(edge_array)/sizeof(E));
|
||||
|
||||
// Some typedef's to save a little typing
|
||||
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef boost::graph_traits<Graph>::vertices_size_type size_type;
|
||||
typedef std::vector<Vertex>::iterator Piter;
|
||||
typedef std::vector<size_type>::iterator Iiter;
|
||||
|
||||
// color, discover time, and finish time properties
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
std::vector<size_type> dtime(num_vertices(G));
|
||||
std::vector<size_type> ftime(num_vertices(G));
|
||||
|
||||
boost::depth_first_search(G, boost::visit_timestamp(dtime.begin(), ftime.begin()),
|
||||
color.begin());
|
||||
|
||||
// use std::sort to order the vertices by their discover time
|
||||
std::vector<size_type> discover_order(N);
|
||||
boost::iota(discover_order.begin(), discover_order.end(), 0);
|
||||
std::sort(discover_order.begin(), discover_order.end(),
|
||||
boost::indirect_cmp<Iiter, std::less<size_type> >(dtime.begin()));
|
||||
|
||||
std::cout << "order of discovery: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[ discover_order[i] ] << " ";
|
||||
|
||||
std::vector<size_type> finish_order(N);
|
||||
boost::iota(finish_order.begin(), finish_order.end(), 0);
|
||||
std::sort(finish_order.begin(), finish_order.end(),
|
||||
boost::indirect_cmp<Iiter, std::less<size_type> >(ftime.begin()));
|
||||
|
||||
std::cout << endl << "order of finish: ";
|
||||
for (size_type i = 0; i < N; ++i)
|
||||
std::cout << name[ finish_order[i] ] << " ";
|
||||
std::cout << std::endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
order of discovery: u v y x w z
|
||||
order of finish: x y v u z w
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./depth_first_visit.html"><tt>depth_first_visit</tt></a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,107 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Depth-First Visit</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="sec:dfs"></A>
|
||||
<TT>depth_first_visit</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(E)</i></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/depth_first_search.hpp"><TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void depth_first_visit(IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
DFSVisitor& vis, ColorMap color)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function visits all of the vertices in the same connected
|
||||
component as the source vertex <tt>s</tt>, using the <a
|
||||
href="./graph_theory_review.html#sec:dfs-algorithm">depth-first
|
||||
pattern</a>. The main purpose of the function is for the
|
||||
implementation of <TT>depth_first_search()</TT> though sometimes it is
|
||||
useful on its own.
|
||||
|
||||
<p>
|
||||
The <tt>DFSVisitor</tt> supplied by the user determines what
|
||||
actions are taken at each event-point within the algorithm.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by the algorithm to keep track
|
||||
of which vertices have been visited.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>IncidenceGraph</TT> must be a model of
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>DFSVisitor</TT> must be a model of <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The key type of <tt>ColorMap</tt> must be the vertex descriptor type for the graph and the value type of <TT>ColorMap</TT> must be a model of
|
||||
<a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,115 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: dfs_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
dfs_visitor<EventVisitorList>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
<tt>std::pair</tt>) into a <a href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
See the example for <a href="./EventVisitor.html">EventVisitor</a>.
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./DFSVisitor.html">DFSVisitor</a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EventVisitorList</TT></TD>
|
||||
<TD>
|
||||
A list of <a href="./EventVisitor.html">EventVisitor</a>'s created
|
||||
with <tt>std::pair</tt>.
|
||||
</TD>
|
||||
<TD><TT><a href="./null_visitor.html"><tt>null_visitor</tt></a></TT></TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/depth_first_search.hpp">
|
||||
<TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>. In each function the
|
||||
appropriate event is dispatched to the <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class EventVisitorList><br>
|
||||
dfs_visitor<EventVisitorList><br>
|
||||
make_dfs_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a DFS visitor.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are event visitors: <a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
|
||||
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
|
||||
<a href="./time_stamper.html"><tt>time_stamper</tt></a>,
|
||||
and <a href="./property_writer.html"><tt>property_writer</tt></a>.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,236 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Jeremy Siek makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Dijkstra's Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:dijkstra"></A>
|
||||
<TT>dijkstra_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color, distance, weight, vertex index</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O((V + E) log V)</i>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/dijkstra_shortest_paths.hpp"><TT>boost/graph/dijkstra_shortest_paths.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="#DistanceMap">DistanceMap</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap d);
|
||||
|
||||
(3)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="#DistanceMap">DistanceMap</a>, class <a href="./UniformCostVisitor.html">UniformCostVisitor</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap d, UniformCostVisitor visit);
|
||||
|
||||
(4)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./UniformCostVisitor.html">UniformCostVisitor</a>,
|
||||
class <a href="#DistanceMap">DistanceMap</a>, class <a href="#WeightMap">WeightMap</a>, class <a href="#ColorMap">ColorMap</a>, class <a href="#VertexIndexMap">VertexIndexMap</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap distance, WeightMap weight, ColorMap color, VertexIndexMap id,
|
||||
UniformCostVisitor vis);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This is the modified Dijkstra algorithm [<A
|
||||
HREF="bibliography.html#dijkstra59">10</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>] which solves the single-source
|
||||
shortest-paths problem on a weighted, directed graph for the case
|
||||
where all edge weights are nonnegative. See Section <A
|
||||
HREF="graph_theory_review.html#sec:shortest-path-algorithms">Shortest-Paths Algorithms</A>
|
||||
for some background to the shortest-path problem. The priority queue
|
||||
used inside the algorithm is implemented with a heap for efficiency.
|
||||
|
||||
<P>
|
||||
There are four versions of the algorithm to accommodate whether the
|
||||
necessary graph properties will be supplied by the graph object or
|
||||
externally via a argument to this function. The properties needed by
|
||||
the algorithm are distance, weight, color, and vertex index. Version 3
|
||||
and 4 of the algorithm also include a visitor argument for added
|
||||
extensibility.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<li>In version (1) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>vertex_distance_t</tt>, <tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<li>In version (2) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<li>In version (3) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<LI>The type <TT>UniformCostVisitor</TT> must be a model of <a href="./UniformCostVisitor.html">UniformCostVisitor</a>.
|
||||
</LI>
|
||||
<LI><a name="DistanceMap">The type <TT>DistanceMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the distance map. The value type of the distance
|
||||
map must be <a href="http://www.sgi.com/Technology/STL/LessThanComparable.html">LessThanComparable</a>.</a>
|
||||
</LI>
|
||||
<LI><a name="WeightMap">The type <TT>WeightMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. The
|
||||
edge descriptor type of the graph needs to be usable as the key
|
||||
type for the weight map. The value type for the map
|
||||
must be <I>Addable</I> with the value type of the distance
|
||||
map.</a>
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of
|
||||
<a href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. A vertex descriptor must be
|
||||
usable as the key type of the map, and the value type of the
|
||||
map must be a model of <a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI><a name="VertexIndexMap">The type <TT>VertexIndexMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. The
|
||||
value type of <TT>VertexIndexMap</TT> must be an integer type. The
|
||||
integers must map vertex descriptors to the integers zero through
|
||||
<tt>num_vertices(g) - 1</tt>. The vertex
|
||||
descriptor type of the graph needs to be usable as the key type
|
||||
of the vertex index map.</a>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O((V + E) log V)</i>, or just <i>O(E log V)</i>
|
||||
if all vertices are reachable from the source.
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The source code for this example is in <a
|
||||
href="../example/dijkstra.cpp"><TT>examples/dijkstra.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
int
|
||||
main(int , char* [])
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef property<edge_weight_t, int> weightp;
|
||||
typedef adjacency_list< listS, vecS, directedS,
|
||||
property<vertex_color_t,default_color_type>, weightp > Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
|
||||
const int num_nodes = 5;
|
||||
E edges[] = { E(0,2),
|
||||
E(1,1), E(1,3), E(1,4),
|
||||
E(2,1), E(2,3),
|
||||
E(3,4),
|
||||
E(4,0), E(4,1) };
|
||||
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1};
|
||||
|
||||
Graph G(num_nodes, edges, edges + sizeof(edges)/sizeof(E), weights);
|
||||
|
||||
std::vector<Vertex> p(num_vertices(G));
|
||||
std::vector<int> d(num_vertices(G));
|
||||
|
||||
Vertex s = *(vertices(G).first);
|
||||
p[s] = s;
|
||||
dijkstra_shortest_paths(G, s, &d[0],
|
||||
make_ucs_visitor(record_predecessors(&p[0], on_edge_relaxed())));
|
||||
|
||||
std::cout << "distances from start vertex:" << std::endl;
|
||||
graph_traits<Graph>::vertex_iterator vi, vend;
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
std::cout << "distance(" << *vi << ") = " << d[*vi] << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "shortest paths tree" << std::endl;
|
||||
adjacency_list<> tree(num_nodes);
|
||||
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
if (*vi != p[*vi])
|
||||
add_edge(p[*vi], *vi, tree);
|
||||
|
||||
print_graph(tree);
|
||||
|
||||
return 0;
|
||||
}
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
distances from start vertex:
|
||||
distance(0) = 0
|
||||
distance(1) = 6
|
||||
distance(2) = 1
|
||||
distance(3) = 4
|
||||
distance(4) = 5
|
||||
|
||||
shortest paths tree
|
||||
0 --> 2
|
||||
1 -->
|
||||
2 --> 3
|
||||
3 --> 4
|
||||
4 --> 1
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,186 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: distance_recorder</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
distance_recorder<DistanceMap, EventTag>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This is an <a href="./EventVisitor.html">EventVisitor</a> that records
|
||||
the distance of a vertex (using a <a
|
||||
href="property_map.html">property map</a>) from some
|
||||
source vertex during a graph search. When applied to edge <i>e =
|
||||
(u,v)</i>, the distance of <i>v</i> is recorded to be one more than
|
||||
the distance of <i>u</i>. The distance recorder is typically used with
|
||||
the <tt>on_tree_edge</tt> or <tt>on_relax_edge</tt> events, and
|
||||
cannot be used with vertex events.
|
||||
|
||||
<p>
|
||||
<tt>distance_recorder</tt> can be used with graph algorithms by
|
||||
wrapping it with the algorithm specific adaptor, such as <a
|
||||
href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and <a
|
||||
href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>. Also, this event
|
||||
visitor can be combined with other event visitors using
|
||||
<tt>std::pair</tt> to form an EventVisitorList.
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
See the example for <a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>.
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./EventVisitor.html">EventVisitor</a>
|
||||
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/visitors.hpp">
|
||||
<TT>boost/graph/visitors.hpp</TT></a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>DistanceMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
where the key type and the value type are the vertex descriptor type
|
||||
of the graph.
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>EventTag</TT></TD>
|
||||
<TD>
|
||||
The tag to specify when the <tt>distance_recorder</tt> should be
|
||||
applied during the graph algorithm. <tt>EventTag</tt> must be an
|
||||
edge event.
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H2>Associated Types</H2>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>distance_recorder::event_filter</tt></td>
|
||||
<td>
|
||||
This will be the same type as the template parameter <tt>EventTag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<p>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Member</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
distance_recorder(DistanceMap pa);
|
||||
</tt></td>
|
||||
<td>
|
||||
Construct a distance recorder object with distance property map
|
||||
<tt>pa</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
template <class Edge, class Graph><br>
|
||||
void operator()(Edge e, const Graph& g);
|
||||
</tt></td>
|
||||
<td>
|
||||
Given edge <i>e = (u,v)</i>, this records the distance of <i>v</i> as
|
||||
one plus the distance of <i>u</i>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class DistanceMap, class Tag><br>
|
||||
distance_recorder<DistanceMap, Tag> <br>
|
||||
record_distances(DistanceMap pa, Tag);
|
||||
</tt></td><td>
|
||||
A convenient way to create a <tt>distance_recorder</tt>.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are other event visitors: <a
|
||||
href="./distance_recorder.html"><tt>predecessor_recorder</tt></a>,
|
||||
<a href="./time_stamper.html"><tt>time_stamper</tt></a>,
|
||||
and <a href="./property_writer.html"><tt>property_writer</tt></a>.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!-- LocalWords: DistanceMap EventTag EventVisitor map bfs dfs const Siek
|
||||
-->
|
||||
<!-- LocalWords: EventVisitorList WritablePropertyMap Univ Quan
|
||||
-->
|
||||
<!-- LocalWords: Lumsdaine
|
||||
-->
|
||||
@@ -0,0 +1,422 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Dynamic Connected Components</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Dynamic Connected Components</H1>
|
||||
|
||||
<P>
|
||||
This section describes a family of functions and classes that
|
||||
calculate the connected components of an undirected graph. The
|
||||
algorithm used here is based on the disjoint-sets data
|
||||
structure [<A
|
||||
HREF="bibliography.html#clr90">8</A>,<A
|
||||
HREF="bibliography.html#tarjan83:_data_struct_network_algo">27</A>] which is
|
||||
the best method for situations where the graph is growing (edges are
|
||||
being added) and the connected components information needs to be
|
||||
updated repeatedly. The disjoint-sets class is described in
|
||||
Section <A HREF="../../disjoint_sets/disjoint_sets.html">Disjoint Sets</A>.
|
||||
|
||||
<P>
|
||||
The following five operations are the primary functions that you will
|
||||
use to calculate and maintain the connected components. The objects
|
||||
used here are a graph <TT>g</TT>, a disjoint-sets structure <TT>ds</TT>,
|
||||
and vertices <TT>u</TT> and <TT>v</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI><TT>initialize_dynamic_components(g, ds)</TT>
|
||||
<BR>
|
||||
Basic initialization of the disjoint-sets structure. Each
|
||||
vertex in the graph <TT>g</TT> is in its own set.
|
||||
</LI>
|
||||
<LI><TT>dynamic_connected_components(g, ds)</TT>
|
||||
<BR>
|
||||
The connected components are calculated based on the edges in the graph
|
||||
<TT>g</TT> and the information is embedded in <TT>ds</TT>.
|
||||
</LI>
|
||||
<LI><TT>ds.find_set(v)</TT>
|
||||
<BR>
|
||||
Extracts the component information for vertex <TT>v</TT> from the
|
||||
disjoint-sets.
|
||||
</LI>
|
||||
<LI><TT>ds.union_set(u, v)</TT>
|
||||
<BR>
|
||||
Update the disjoint-sets structure when edge <i>(u,v)</i> is added to the graph.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the whole process is <i>O(V + E
|
||||
alpha(E,V))</i> where <i>E</i> is the total number of edges in the
|
||||
graph (by the end of the process) and <i>V</i> is the number of
|
||||
vertices. <i>alpha</i> is the inverse of Ackermann's function which
|
||||
has explosive recursively exponential growth. Therefore its inverse
|
||||
function grows <I>very</I> slowly. For all practical purposes
|
||||
<i>alpha(m,n) <= 4</i> which means the time complexity is only
|
||||
slightly larger than <i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Maintain the connected components of a graph while adding edges using
|
||||
the disjoint-sets data structure. The full source code for this
|
||||
example can be found in <a
|
||||
href="../example/dynamic_components.cpp"><TT>examples/dynamic_components.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Create a graph
|
||||
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
|
||||
typedef Graph::vertex_descriptor Vertex;
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 4, G);
|
||||
|
||||
// create the disjoint-sets structure, which requires
|
||||
// rank and parent vertex properties
|
||||
std::vector<Vertex> rank(num_vertices(G));
|
||||
std::vector<Vertex> parent(num_vertices(G));
|
||||
typedef std::vector<Graph::size_type>::iterator Rank;
|
||||
typedef std::vector<Vertex>::iterator Parent;
|
||||
disjoint_sets<Rank, Parent> ds(rank.begin(), parent.begin());
|
||||
|
||||
// determine the connected components
|
||||
// the results are embedded in the disjoint-sets structure
|
||||
initialize_dynamic_components(G, ds);
|
||||
dynamic_connected_components(G, ds);
|
||||
|
||||
Graph::edge_descriptor e;
|
||||
bool flag;
|
||||
|
||||
// Add a couple more edges and update the disjoint-sets
|
||||
tie(e,flag) = add_edge(4, 0, G);
|
||||
ds.union_set(4,0);
|
||||
|
||||
tie(e,flag) = add_edge(2, 5, G);
|
||||
ds.union_set(2,5);
|
||||
|
||||
cout << "An undirected graph:" << endl;
|
||||
print_graph(G, get(vertex_index, G));
|
||||
cout << endl;
|
||||
|
||||
Graph::vertex_iterator i,end;
|
||||
for (tie(i,end) = vertices(G); i != end; ++i)
|
||||
cout << "representative[" << *i << "] = " <<
|
||||
ds.find_set(*i) << endl;;
|
||||
cout << endl;
|
||||
|
||||
typedef component_index<int> Components;
|
||||
Components components(parent.begin(), parent.end());
|
||||
|
||||
for (Components::size_type i = 0; i < components.size(); ++i) {
|
||||
cout << "component " << i << " contains: ";
|
||||
Components::value_type::iterator
|
||||
j = components[i].begin(),
|
||||
jend = components[i].end();
|
||||
for ( ; j != jend; ++j)
|
||||
cout << *j << " ";
|
||||
cout << endl;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:initialize-dynamic-components"></A>
|
||||
<TT>initialize_dynamic_components</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class VertexListGraph, class DisjointSets>
|
||||
void initialize_dynamic_components(VertexListGraph& G, DisjointSets& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This prepares the disjoint-sets data structure for the dynamic
|
||||
connected components algorithm by making each vertex in the graph a
|
||||
member of its own component (or set).
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:dynamic-connected-components"></A>
|
||||
<TT>dynamic_connected_components</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<p>
|
||||
<PRE>
|
||||
template <class EdgeListGraph, class DisjointSets>
|
||||
void dynamic_connected_components(EdgeListGraph& g, DisjointSets& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function calculates the connected components of the graph,
|
||||
embedding the results in the disjoint-sets data structure.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The graph type must be a model of <a href="./EdgeListGraph.html">EdgeListGraph</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:same-component">
|
||||
<TT>same_component</TT></A>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(alpha(E,V))</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class Vertex, class DisjointSet>
|
||||
bool same_component(Vertex u, Vertex v, DisjointSet& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function determines whether <TT>u</TT> and <TT>v</TT> are in the same
|
||||
component.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI><TT>Vertex</TT> must be compatible with the rank and parent
|
||||
property maps of the <TT>DisjointSets</TT> data structure.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:component-index"></A>
|
||||
<TT>component_index</TT>
|
||||
</H2>
|
||||
|
||||
<p>
|
||||
<PRE>
|
||||
component_index<Index>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The is a class that provides an STL container-like view for the
|
||||
components of the graph. Each component is a container-like object,
|
||||
and the <TT>component_index</TT> object provides access to the
|
||||
component objects via <TT>operator[]</TT>. A <TT>component_index</TT>
|
||||
object is initialized with the parents property in the disjoint-sets
|
||||
calculated from the <TT>dynamic_connected_components()</TT> function.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Members</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Member</th> <th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type</tt></td>
|
||||
<td>The type used for representing the number of components.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type</tt></td>
|
||||
<td>
|
||||
The type for a component object. The component type has the following members.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::value_type</tt></td>
|
||||
<td>
|
||||
The value type of a component object is a vertex ID.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator</tt></td>
|
||||
<td>
|
||||
This iterator can be used to traverse all of the vertices
|
||||
in the component. This iterator dereferences to give a vertex ID.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::const_iterator</tt></td>
|
||||
<td>
|
||||
The const iterator.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::begin() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing to the first vertex in the component.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::end() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing past the end of the last vertex in the
|
||||
component.
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<tt>
|
||||
template <class ComponentsContainer>
|
||||
component_index(const ComponentsContainer& c)
|
||||
</tt>
|
||||
</td>
|
||||
<td>
|
||||
Construct the <TT>component_index</TT> using the information
|
||||
from the components container <TT>c</TT> which was the result
|
||||
of executing <TT>connected_components_on_edgelist</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type operator[](size_type i)</tt></td>
|
||||
<td>
|
||||
Returns the <TT>i</TT>th component in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type component_index::size()</tt></td>
|
||||
<td>
|
||||
Returns the number of components in the graph.
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,225 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Edge List Class</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:edge-list-class"></A>
|
||||
<PRE>
|
||||
edge_list<EdgeIterator, ValueType, DiffType>
|
||||
</PRE>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
The <TT>edge_list</TT> class is an adaptor that turns a pair of edge
|
||||
iterators into a class that models <TT>EdgeListGraph</TT>. The
|
||||
<TT>value_type</TT> of the edge iterator must be a <TT>std::pair</TT> (or
|
||||
at least have <TT>first</TT> and <TT>second</TT> members). The
|
||||
<TT>first_type</TT> and <TT>second_type</TT> of the pair must be the
|
||||
same and they will be used for the graph's <TT>vertex_descriptor</TT>.
|
||||
The <TT>ValueType</TT> and <TT>DiffType</TT> template parameters are only
|
||||
needed if your compiler does not support partial
|
||||
specialization. Otherwise they default to the correct types.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Applying the Bellman-Ford shortest paths algorithm to an
|
||||
<TT>edge_list</TT>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
enum { u, v, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'x', 'y', 'z' };
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
E edges[] = { E(u,y), E(u,x), E(u,v),
|
||||
E(v,u),
|
||||
E(x,y), E(x,v),
|
||||
E(y,v), E(y,z),
|
||||
E(z,u), E(z,x) };
|
||||
|
||||
int weight[] = { -4, 8, 5,
|
||||
-2,
|
||||
9, -3,
|
||||
7, 2,
|
||||
6, 7 };
|
||||
|
||||
typedef boost::edge_list<E*> Graph;
|
||||
Graph g(edges, edges + sizeof(edges) / sizeof(E));
|
||||
|
||||
std::vector<int> distance(N, std::numeric_limits<short>::max());
|
||||
std::vector<int> parent(N,-1);
|
||||
|
||||
distance[z] = 0;
|
||||
parent[z] = z;
|
||||
bool r = boost::bellman_ford_shortest_paths(g, int(N), weight,
|
||||
distance.begin(),
|
||||
parent.begin());
|
||||
if (r)
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[i] << ": " << distance[i]
|
||||
<< " " << name[parent[i]] << std::endl;
|
||||
else
|
||||
std::cout << "negative cycle" << std::endl;
|
||||
</PRE>
|
||||
The output is the distance from the root and the parent
|
||||
of each vertex in the shortest paths tree.
|
||||
<PRE>
|
||||
u: 2 v
|
||||
v: 4 x
|
||||
x: 7 z
|
||||
y: -2 u
|
||||
z: 0 z
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<p>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<a href="../../../boost/graph/edge_list.hpp"><TT>boost/graph/edge_list.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EdgeIterator</TT></TD> <TD>Must be model of <a
|
||||
href="http://www.sgi.com/Technology/STL/InputIterator.html">InputIterator</a>
|
||||
who's <TT>value_type</TT> must be a pair of vertex descriptors.</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>ValueType</TT></TD>
|
||||
<TD>The <TT>value_type</TT> of the <TT>EdgeIterator</TT>.<br>
|
||||
Default: <TT>std::iterator_traits<EdgeIterator>::value_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>DiffType</TT></TD>
|
||||
<TD>The <TT>difference_type</TT> of the <TT>EdgeIterator</TT>.<br>
|
||||
Default: <TT>std::iterator_traits<EdgeIterator>::difference_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
<P>
|
||||
|
||||
<H3>Model of</H3>
|
||||
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>boost::graph_traits<edge_list>::vertex_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the vertex descriptors associated with the
|
||||
<TT>edge_list</TT>. This will be the same type as
|
||||
<TT>std::iterator_traits<EdgeIterator>::value_type::first_type</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
boost::graph_traits<edge_list>::edge_descriptor
|
||||
</tt>
|
||||
<br><br>
|
||||
The type for the edge descriptors associated with the
|
||||
<TT>edge_list</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
boost::graph_traits<edge_list>::edge_iterator
|
||||
</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <TT>edges()</TT>. The iterator
|
||||
category of the <TT>edge_iterator</TT> will be the same as that of the
|
||||
<TT>EdgeIterator</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
edge_list(EdgeIterator first, EdgeIterator last)
|
||||
</tt>
|
||||
<br><br>
|
||||
Creates a graph object with <TT>n</TT> vertices and with the
|
||||
edges specified in the edge list given by the range <TT>[first,last)</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<H3>Non-Member Functions</H3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
std::pair<edge_iterator, edge_iterator><br>
|
||||
edges(const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns an iterator-range providing access to the edge set of graph <TT>g</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
vertex_descriptor<br>
|
||||
source(edge_descriptor e, const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns the source vertex of edge <TT>e</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
vertex_descriptor<br>
|
||||
target(edge_descriptor e, const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns the target vertex of edge <TT>e</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,306 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Edmunds-Karp Maximum Flow</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:edmunds_karp_max_flow">
|
||||
<TT>edmunds_karp_max_flow</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">edge capacity, edge residual capacity, reverse edge,
|
||||
(vertex index | edge predecessor of vertex, vertex color)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(V E<sup>2</sup>)</i> or <i>O(V E U)</i> if capacity values are integers bounded by <i>U</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <typename VertexListGraph,
|
||||
typename CapacityEdgeMap, typename ResidualCapacityEdgeMap,
|
||||
typename ReverseEdgeMap, typename VertexIndexMap>
|
||||
typename property_traits<CapacityEdgeMap>::value_type
|
||||
edmunds_karp_max_flow
|
||||
(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor src,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor sink,
|
||||
CapacityEdgeMap cap,
|
||||
ResidualCapacityEdgeMap res,
|
||||
ReverseEdgeMap rev,
|
||||
VertexIndexMap index_map)
|
||||
|
||||
(2)
|
||||
template <typename VertexListGraph,
|
||||
typename CapacityEdgeMap, typename ResidualCapacityEdgeMap,
|
||||
typename ReverseEdgeMap, typename ColorMap, typename PredEdgeMap>
|
||||
typename property_traits<CapacityEdgeMap>::value_type
|
||||
edmunds_karp_max_flow
|
||||
(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor src,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor sink,
|
||||
CapacityEdgeMap cap,
|
||||
ResidualCapacityEdgeMap res,
|
||||
ReverseEdgeMap rev,
|
||||
ColorMap color,
|
||||
PredEdgeMap pred)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <tt>edmunds_karp_max_flow()</tt> function calculates the maximum flow
|
||||
of a network. See Section <a
|
||||
href="./graph_theory_review.html#sec:network-flow-algorithms">Network
|
||||
Flow Algorithms</a> for a description of maximum flow. The calculated
|
||||
maximum flow will be the return value of the function. The function
|
||||
also calculates the flow values <i>f(u,v)</i> for all <i>(u,v)</i> in
|
||||
<i>E</i>, which are returned in the form of the residual capacity
|
||||
<i>r(u,v) = c(u,v) - f(u,v)</i>.
|
||||
|
||||
<p>
|
||||
There are several special requirements on the input graph and property
|
||||
map parameters for this algorithm. First, the directed graph
|
||||
<i>G=(V,E)</i> that represents the network must be augmented to
|
||||
include the reverse edge for every edge in <i>E</i>. That is, the
|
||||
input graph should be <i>G<sub>in</sub> = (V,{E U
|
||||
E<sup>T</sup>})</i>. The <tt>ReverseEdgeMap</tt> argument <tt>rev</tt>
|
||||
must map each edge in the original graph to its reverse edge, that is
|
||||
<i>(u,v) -> (v,u)</i> for all <i>(u,v)</i> in <i>E</i>. The
|
||||
<tt>CapacityEdgeMap</tt> argument <tt>cap</tt> must map each edge in
|
||||
<i>E</i> to a positive number, and each edge in <i>E<sup>T</sup></i>
|
||||
to 0.
|
||||
|
||||
<p>
|
||||
The algorithm is due to <a
|
||||
href="./bibliography.html#edmonds72:_improvements_netflow">Edmonds and
|
||||
Karp</a>, though we are using the variation called the ``labeling
|
||||
algorithm'' described in <a
|
||||
href="./bibliography.html#ahuja93:_network_flows">Network Flows</a>.
|
||||
|
||||
<p>
|
||||
This algorithm provides a very simple an easy to implement solution to
|
||||
the maximum flow problem. However, there are several reasons why this
|
||||
algorithm is not as good as the <a
|
||||
href="./push_relabel_max_flow.html"><tt>push_relabel_max_flow()</tt></a>
|
||||
algorithm.
|
||||
|
||||
<ul>
|
||||
<li>In the non-integer capacity case, the time complexity is <i>O(V
|
||||
E<sup>2</sup>)</i> which is worse than the time complexity of the
|
||||
push-relabel algorithm <i>O(V<sup>2</sup>E<sup>1/2</sup>)</i>
|
||||
for all but the sparsest of graphs.</li>
|
||||
|
||||
<li>In the integer capacity case, if the capacity bound <i>U</i> is
|
||||
very large then the algorithm will take a long time.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/edmunds_karp_max_flow.hpp"><TT>boost/graph/edmunds_karp_max_flow.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
<p>
|
||||
For version 1:
|
||||
|
||||
<ul>
|
||||
|
||||
<li> <tt>VertexListGraph& g</tt> (IN) <br>
|
||||
A directed graph. The
|
||||
graph's type must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>. For each edge
|
||||
<i>(u,v)</i> in the graph, the reverse edge <i>(v,u)</i> must also
|
||||
be in the graph.
|
||||
|
||||
<li> <tt>vertex_descriptor src</tt>  (IN) <br>
|
||||
The source vertex for the flow network graph.
|
||||
|
||||
<li> <tt>vertex_descriptor sink</tt>  (IN) <br>
|
||||
The sink vertex for the flow network graph.
|
||||
|
||||
<li> <tt>CapacityEdgeMap cap</tt>  (IN) <br>
|
||||
The edge capacity property map. The type must be a model of a
|
||||
constant <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>. The
|
||||
key type of the map must be the graph's edge descriptor type.
|
||||
|
||||
<li> <tt>ResidualCapacityEdgeMap res</tt> (OUT) <br>
|
||||
The edge residual capacity property map. The type must be a model of
|
||||
a mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>. The
|
||||
key type of the map must be the graph's edge descriptor type.
|
||||
|
||||
<li> <tt>ReverseEdgeMap rev</tt> (OUT) <br>
|
||||
An edge property map that maps every edge <i>(u,v)</i> in the graph
|
||||
to the reverse edge <i>(v,u)</i>. The map must be a model of
|
||||
constant <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>. The
|
||||
key type of the map must be the graph's edge descriptor type.
|
||||
|
||||
<li> <tt>VertexIndexMap index_map</tt>  (IN) <br>
|
||||
Maps each vertex of the graph to a unique integer in the range
|
||||
<tt>[0, num_vertices(g))</tt>. The map must be a model of constant <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>. The
|
||||
key type of the map must be the graph's vertex descriptor type.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
For version 2 (all of the above, minus the vertex index map, plus the
|
||||
following):
|
||||
|
||||
<ul>
|
||||
<li> <tt>ColorMap color</tt> (WORK) <br>
|
||||
Used by the algorithm to keep track of progress during the
|
||||
breadth-first search stage. At the end of the algorithm, the white
|
||||
vertices define the minimum cut set. The map must be a model of
|
||||
mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>.
|
||||
The key type of the map should be the graph's vertex descriptor type, and
|
||||
the value type must be a model of <a
|
||||
href="./ColorValue.html">ColorValue</a>.</li>
|
||||
|
||||
<li> <tt>PredEdgeMap pred</tt> (WORK) <br>
|
||||
Use by the algorithm to store augmenting paths. The map must be a
|
||||
model of mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">LvaluePropertyMap</a>.
|
||||
The key type must be the graph's vertex descriptor type and the
|
||||
value type must be the graph's edge descriptor type.
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
This reads in an example maximum flow problem (a graph with edge
|
||||
capacities) from a file in the DIMACS format. The source for this
|
||||
example can be found in <a
|
||||
href="../example/edmunds_karp_max_flow.cpp"><tt>example/edmunds_karp_max_flow.cpp</tt></a>.
|
||||
|
||||
<pre>
|
||||
#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <boost/graph/edmunds_karp_map_flow.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/read_dimacs.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef adjacency_list_traits<vecS, vecS, directedS> Traits;
|
||||
typedef adjacency_list<vecS, vecS, directedS,
|
||||
property<vertex_name_t, std::string>,
|
||||
property<edge_capacity_t, long,
|
||||
property<edge_residual_capacity_t, long,
|
||||
property<edge_reverse_t, Traits::edge_descriptor> > >
|
||||
> Graph;
|
||||
|
||||
Graph g;
|
||||
long flow;
|
||||
|
||||
property_map<Graph, edge_capacity_t>::type
|
||||
capacity = get(edge_capacity, g);
|
||||
property_map<Graph, edge_residual_capacity_t>::type
|
||||
residual_capacity = get(edge_residual_capacity, g);
|
||||
property_map<Graph, edge_reverse_t>::type
|
||||
reverse_edge = get(edge_reverse, g);
|
||||
|
||||
Traits::vertex_descriptor s, t;
|
||||
read_dimacs_max_flow(g, capacity, residual_capacity, reverse_edge, s, t);
|
||||
|
||||
flow = edmunds_karp_max_flow(g, s, t, capacity, residual_capacity,
|
||||
reverse_edge, get(vertex_index, g));
|
||||
|
||||
std::cout << "c The total flow:" << std::endl;
|
||||
std::cout << "s " << flow << std::endl << std::endl;
|
||||
|
||||
std::cout << "c flow values:" << std::endl;
|
||||
graph_traits<Graph>::vertex_iterator u_iter, u_end;
|
||||
graph_traits<Graph>::out_edge_iterator ei, e_end;
|
||||
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
if (capacity[*ei] > 0)
|
||||
std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
|
||||
<< (capacity[*ei] - residual_capacity[*ei]) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
c The total flow:
|
||||
s 4
|
||||
|
||||
c flow values:
|
||||
f 0 1 4
|
||||
f 1 2 4
|
||||
f 2 3 2
|
||||
f 2 4 2
|
||||
f 3 1 0
|
||||
f 3 6 2
|
||||
f 4 5 3
|
||||
f 5 6 0
|
||||
f 5 7 3
|
||||
f 6 4 1
|
||||
f 6 7 1
|
||||
</pre>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./push_relabel_max_flow.html"><tt>push_relabel_max_flow()</tt></a>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!-- LocalWords: HTML Siek Edmunds BGCOLOR ffffff ee VLINK ALINK ff IMG SRC
|
||||
-->
|
||||
<!-- LocalWords: gif ALT BR sec edmunds karp TT DIV CELLPADDING TR TD PRE lt
|
||||
-->
|
||||
<!-- LocalWords: typename VertexListGraph CapacityEdgeMap ReverseEdgeMap gt
|
||||
-->
|
||||
<!-- LocalWords: ResidualCapacityEdgeMap VertexIndexMap src rev ColorMap pred
|
||||
-->
|
||||
<!-- LocalWords: PredEdgeMap tt href html hpp ul li nbsp br LvaluePropertyMap
|
||||
-->
|
||||
<!-- LocalWords: num ColorValue DIMACS cpp pre config iostream dimacs int std
|
||||
-->
|
||||
<!-- LocalWords: namespace vecS directedS cout endl iter ei HR valign nowrap
|
||||
-->
|
||||
<!-- LocalWords: jeremy siek htm Univ mailto jsiek lsc edu
|
||||
p -->
|
||||
@@ -0,0 +1,78 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
--
|
||||
-- Permission to use, copy, modify, distribute and sell this software
|
||||
-- and its documentation for any purpose is hereby granted without fee,
|
||||
-- provided that the above copyright notice appears in all copies and
|
||||
-- that both that copyright notice and this permission notice appear
|
||||
-- in supporting documentation. We make no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: FAQ</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>Frequently Asked Questions</h1>
|
||||
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Why does the algorithm X work with <tt>adjacency_list</tt> where
|
||||
<tt>VertexList=vecS</tt> but not when <tt>VertexList=listS</tt>? <br><br>
|
||||
Often the reason is that the algorithm expects to find the
|
||||
<tt>vertex_index</tt> property stored in the graph. When
|
||||
<tt>VertexList=vecS</tt>, the <tt>adjacency_list</tt> automatically
|
||||
has a <tt>vertex_index</tt> property. However, when <tt>VertexList=listS</tt>
|
||||
this is not the case, and the <tt>vertex_index</tt> property must be
|
||||
explicitly added, and initialized. For example,
|
||||
<pre>
|
||||
// specify the graph type
|
||||
typedef adjacency_list<listS, listS, undirectedS,
|
||||
property<vertex_index_t, std::size_t>,
|
||||
no_property
|
||||
> graph_t;
|
||||
|
||||
// construct a graph object
|
||||
graph_t G(num_nodes);
|
||||
// obtain a property map for the vertex_index property
|
||||
property_map<graph_t, vertex_index_t>::type
|
||||
index = get(vertex_index, G);
|
||||
// initialize the vertex_index property values
|
||||
graph_traits<graph_t>::vertex_iterator vi, vend;
|
||||
graph_traits<graph_t>::vertices_size_type cnt = 0;
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
put(index, *vi, cnt++);
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>When using algorithm X, why do I get an error about a property
|
||||
not being found, such as:
|
||||
<pre>
|
||||
../../../boost/concept_check.hpp:209: no match for
|
||||
`boost::detail::error_property_not_found & ==
|
||||
boost::detail::error_property_not_found &'
|
||||
</pre>
|
||||
or a message such as:
|
||||
<pre>
|
||||
../../..\boost/graph/depth_first_search.hpp(78) : error C2664: 'white'
|
||||
: cannot convert parameter 1 from
|
||||
'struct boost::detail::error_property_not_found'
|
||||
to 'enum boost::default_color_type'
|
||||
</pre>
|
||||
|
||||
The reason is that the algorithm expected to find some property (like color or
|
||||
weight) attached to the vertices or edges of the graph, but didn't
|
||||
find it. You need to either add an interior property to the graph, or
|
||||
create an exterior property map for the property and pass it as an
|
||||
argument to the algorithm.</li>
|
||||
|
||||
|
||||
|
||||
</ol>
|
||||
@@ -1,9 +1,4 @@
|
||||
# -*- makefile -*-
|
||||
# Copyright (c) 2002 Trustees of Indiana University
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
.SUFFIXES: .fig .gif .tif .jpeg
|
||||
|
||||
|
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 968 B After Width: | Height: | Size: 968 B |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 800 B After Width: | Height: | Size: 800 B |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 947 B After Width: | Height: | Size: 947 B |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 744 B After Width: | Height: | Size: 744 B |
@@ -2,7 +2,7 @@
|
||||
Portrait
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
@@ -10,6 +10,9 @@ Single
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6975 3150 7500 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6525 3825 7650 3075
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6975 2175 7575 2775
|
||||
@@ -21,21 +24,21 @@ Single
|
||||
6975 2625 7575 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3900 3225 4875 3225
|
||||
4350 2625 4800 2625
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6525 4350 7650 3150
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
4350 2550 5175 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3900 3225 4575 3825
|
||||
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
|
||||
2250 3075 2850 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6525 3900 7575 3075
|
||||
3900 3225 4875 3225
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2070 4350 3900 AdacencyMatrix\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2040 5175 2100 IncidenceGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2430 900 2100 BidirectionalGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 1935 4950 3300 EdgeListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 795 7575 3000 Graph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2145 4800 2700 AdjacencyGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2100 2175 2700 VertexListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 3285 600 3300 VertexAndEdgeListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 1935 4575 3975 EdgeListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2100 4800 3300 VertexListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2145 4350 4500 AdjacencyMatrix\001
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 813 B |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -2,7 +2,7 @@
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||