2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-31 20:22:09 +00:00

ported the graph library to borland

[SVN r7965]
This commit is contained in:
Jeremy Siek
2000-10-17 00:16:05 +00:00
parent 9435201530
commit ea086c75e0
29 changed files with 246 additions and 180 deletions

View File

@@ -51,7 +51,7 @@
*/
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
using namespace std;

View File

@@ -104,7 +104,7 @@ copy_graph(NewGraph& g, Tag) {
return graph_copier<NewGraph, Tag>(g);
}
int main(int argc, char* argv[])
int main(int , char* [])
{
typedef boost::adjacency_list<
boost::mapS, boost::vecS, boost::bidirectionalS,

View File

@@ -58,7 +58,7 @@
using namespace std;
using namespace boost;
int main(int argc, char* argv[])
int main(int, char*[])
{
// Select the graph type we wish to use
typedef adjacency_list<vecS, vecS, undirectedS> Graph;

View File

@@ -68,7 +68,7 @@
using namespace std;
using boost::tie;
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
typedef int Index; // ID of a Vertex

View File

@@ -57,6 +57,7 @@ main(int,char*[])
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
REQUIRE2(IndexMap, Vertex, ReadablePropertyMap);
}
#if 0
{
typedef adjacency_list<vecS, vecS, bidirectionalS,
property<vertex_color_t, int>,
@@ -107,5 +108,6 @@ main(int,char*[])
typedef Graph* Graph;
REQUIRE(Graph, VertexListGraph);
}
#endif
return 0;
}

View File

@@ -64,7 +64,7 @@
using namespace std;
int main(int argc, char* argv[])
int main(int , char* [])
{
// First example: the connected components of an undirected graph
using namespace boost;

View File

@@ -40,7 +40,7 @@
Reverse Cuthill-McKee ordering: //choose vertex 9
0 8 5 7 3 6 4 2 1 9
*/
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
using namespace std;

View File

@@ -166,7 +166,7 @@ void print(Graph& G, Name name)
int
main(int argc, char* argv[])
main(int , char* [])
{
// Name and ID numbers for the vertices
char name[] = "abcdefg";

View File

@@ -92,7 +92,7 @@ categorize_edges(const VisitorList& v) {
}
int
main(int argc, char* argv[])
main(int , char* [])
{
using namespace boost;

View File

@@ -66,7 +66,7 @@ using namespace boost;
int main(int argc, char* argv[])
int main(int, char*[])
{
// Select the graph type we wish to use
typedef adjacency_list<vecS, vecS, directedS> Graph;

View File

@@ -59,7 +59,7 @@ struct close_paren : public base_visitor<close_paren> {
int
main(int argc, char* argv[])
main(int, char*[])
{
using namespace boost;

View File

@@ -48,7 +48,7 @@
*/
int
main(int argc, char* argv[])
main(int , char* [])
{
using namespace boost;

View File

@@ -61,7 +61,7 @@
using namespace std;
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
typedef adjacency_list <vecS, vecS, undirectedS> Graph;

View File

@@ -119,7 +119,7 @@ void print_network(Graph& G, Capacity capacity, Flow flow)
}
int main(int argc, char* argv[])
int main(int , char* [])
{
typedef property<edge_capacity_t, int> Cap;
typedef property<edge_flow_t, int, Cap> Flow;

View File

@@ -79,7 +79,7 @@ void print_network(Graph& G, Capacity capacity, Flow flow)
}
int main(int argc, char* argv[]) {
int main(int , char* []) {
typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, boost::no_property,

View File

@@ -54,7 +54,7 @@ using namespace std;
enum family { Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N };
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
using boost::tie;

View File

@@ -39,7 +39,7 @@
*/
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
using namespace std;

View File

@@ -23,6 +23,7 @@
// OR OTHER RIGHTS.
//=======================================================================
#include <stdlib.h>
#include <iostream>
#include <stack>
#include <queue>

View File

@@ -41,7 +41,7 @@
*/
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
using namespace std;

View File

@@ -43,7 +43,7 @@
// parent[i] = c
//
int main(int argc, char* argv[])
int main(int , char* [])
{
using namespace boost;
typedef adjacency_list<vecS, vecS, undirectedS,

View File

@@ -47,7 +47,7 @@ typedef std::pair<size_t,size_t> Pair;
*/
int
main(int argc, char* argv[])
main(int , char* [])
{
//begin
using namespace boost;

View File

@@ -79,7 +79,7 @@ edge_printer<Tag> print_edge(std::string type, Tag) {
}
int
main(int argc, char* argv[])
main(int, char*[])
{
using namespace boost;

View File

@@ -225,11 +225,13 @@ namespace boost {
namespace detail {
template <class Directed> struct is_random_access {
enum { value = false};
enum { value = false};
typedef false_type type;
};
template <>
struct is_random_access<vecS> {
enum { value = true };
typedef true_type type;
};
} // namespace detail
@@ -238,9 +240,20 @@ namespace boost {
//===========================================================================
// Selectors for the Directed template parameter of adjacency_list.
struct directedS { enum { is_directed = true, is_bidir = false }; };
struct undirectedS { enum { is_directed = false, is_bidir = false }; };
struct bidirectionalS { enum { is_directed = true, is_bidir = true }; };
struct directedS { enum { is_directed = true, is_bidir = false };
typedef true_type is_directed_t;
typedef false_type is_bidir_t;
};
struct undirectedS {
enum { is_directed = false, is_bidir = false };
typedef false_type is_directed_t;
typedef false_type is_bidir_t;
};
struct bidirectionalS {
enum { is_directed = true, is_bidir = true };
typedef true_type is_directed_t;
typedef true_type is_bidir_t;
};
//===========================================================================
// The adjacency_list_traits class, which provides a way to access
@@ -254,11 +267,14 @@ namespace boost {
class DirectedS = directedS>
struct adjacency_list_traits
{
enum { is_rand_access = detail::is_random_access<VertexListS>::value };
typedef typename detail::is_random_access<VertexListS>::type
is_rand_access;
typedef typename DirectedS::is_bidir_t is_bidir;
typedef typename DirectedS::is_directed_t is_directed;
typedef typename boost::ct_if<DirectedS::is_bidir,
typedef typename boost::ct_if_t<is_bidir,
bidirectional_tag,
typename boost::ct_if<DirectedS::is_directed,
typename boost::ct_if_t<is_directed,
directed_tag, undirected_tag
>::type
>::type directed_category;
@@ -267,9 +283,8 @@ namespace boost {
edge_parallel_category;
typedef void* vertex_ptr;
typedef typename boost::ct_if<is_rand_access,
typedef typename boost::ct_if_t<is_rand_access,
std::size_t, vertex_ptr>::type vertex_descriptor;
typedef detail::edge_desc_impl<directed_category, vertex_descriptor>
edge_descriptor;
};

View File

@@ -133,7 +133,8 @@ namespace boost {
FinishTime f, Color color, directed_tag)
{
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typename property_traits<Color>::value_type cc;
typename property_traits<Color>::value_type
cc = get(color, *vertices(G).first);
int time = 0;
depth_first_search(G, record_times(d, f, time, v), color);

View File

@@ -70,7 +70,8 @@ namespace boost {
depth_first_search(VertexListGraph& g, DFSVisitor vis, ColorMap color)
{
REQUIRE2(DFSVisitor, VertexListGraph, DFSVisitor);
typename property_traits<ColorMap>::value_type c;
typename property_traits<ColorMap>::value_type
c = get(color, *vertices(g).first); // value of c not used, just type
typename graph_traits<VertexListGraph>::vertex_iterator ui, ui_end;
for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) {

View File

@@ -154,9 +154,15 @@ namespace boost {
#endif
template <class P>
struct has_property { enum { value = true }; };
struct has_property {
enum { value = true };
typedef true_type type;
};
template <>
struct has_property<no_property> { enum { value = false }; };
struct has_property<no_property> {
enum { value = false };
typedef false_type type;
};
//=========================================================================
@@ -1026,6 +1032,7 @@ namespace boost {
g.out_edge_list(u).clear();
g.in_edge_list(u).clear();
}
// O(1) for allow_parallel_edge_tag
// O(log(E/V)) for disallow_parallel_edge_tag
template <class Config>
@@ -1055,6 +1062,7 @@ namespace boost {
return std::make_pair(edge_descriptor(u,v), false);
}
}
template <class Config>
inline std::pair<typename Config::edge_descriptor, bool>
add_edge(typename Config::vertex_descriptor u,
@@ -1141,7 +1149,7 @@ namespace boost {
inline std::pair<typename Config::edge_descriptor, bool>
add_edge(typename Config::vertex_descriptor u,
typename Config::vertex_descriptor v,
const no_property&,
const no_property&,
bidirectional_graph_helper_without_property<Config>& g_)
{
return add_edge(u, v, g_);
@@ -1239,11 +1247,14 @@ namespace boost {
// protected:
// The edge_dispatch() functions should be static, but
// Borland gets confused about constness.
// O(E/V)
static inline std::pair<edge_descriptor,bool>
inline std::pair<edge_descriptor,bool>
edge_dispatch(const AdjList& g,
vertex_descriptor u, vertex_descriptor v,
boost::allow_parallel_edge_tag)
boost::allow_parallel_edge_tag) const
{
bool found;
const typename Config::OutEdgeList& el = g.out_edge_list(u);
@@ -1257,10 +1268,10 @@ namespace boost {
return std::make_pair(edge_descriptor(u, v), false);
}
// O(log(E/V))
static inline std::pair<edge_descriptor,bool>
inline std::pair<edge_descriptor,bool>
edge_dispatch(const AdjList& g,
vertex_descriptor u, vertex_descriptor v,
boost::disallow_parallel_edge_tag)
boost::disallow_parallel_edge_tag) const
{
bool found;
typename Config::OutEdgeList::const_iterator
@@ -1742,11 +1753,11 @@ namespace boost {
add_edge(typename Config::vertex_descriptor u,
typename Config::vertex_descriptor v,
const typename Config::edge_property_type& p,
vec_adj_list_impl<Graph, Config, Base>& g_)
vec_adj_list_impl<Graph, Config, Base>& g_)
{
typename Config::vertex_descriptor x = std::max(u, v);
if (x >= num_vertices(g_))
g_.m_vertices.resize(x + 1);
g_.m_vertices.resize(x + 1);
adj_list_helper<Config, Base>& g = g_;
return add_edge(u, v, p, g);
}
@@ -1754,7 +1765,7 @@ namespace boost {
inline std::pair<typename Config::edge_descriptor, bool>
add_edge(typename Config::vertex_descriptor u,
typename Config::vertex_descriptor v,
vec_adj_list_impl<Graph, Config, Base>& g_)
vec_adj_list_impl<Graph, Config, Base>& g_)
{
typename Config::edge_property_type p;
return add_edge(u, v, p, g_);
@@ -1803,10 +1814,9 @@ namespace boost {
for (vertex_descriptor v = 0; v < V; ++v)
reindex_edge_list(g.out_edge_list(v), u,
edge_parallel_category());
typename Graph::EdgeContainer::iterator
ei = g.m_edges.begin(),
ei_end = g.m_edges.end();
typedef typename Graph::EdgeContainer Container;
typedef typename Container::iterator Iter;
Iter ei = g.m_edges.begin(), ei_end = g.m_edges.end();
for (; ei != ei_end; ++ei) {
if (ei->m_source > u)
--ei->m_source;
@@ -1869,10 +1879,11 @@ namespace boost {
class GraphProperty>
struct adjacency_list_generator
{
enum { is_rand_access = detail::is_random_access<VertexListS>::value,
has_edge_property = has_property<EdgeProperty>::value,
Directed = DirectedS::is_directed,
Bidirectional = DirectedS::is_bidir };
typedef typename detail::is_random_access<VertexListS>::type
is_rand_access;
typedef typename has_property<EdgeProperty>::type has_edge_property;
typedef typename DirectedS::is_directed_t DirectedT;
typedef typename DirectedS::is_bidir_t BidirectionalT;
struct config
{
@@ -1896,7 +1907,7 @@ namespace boost {
typedef typename container_gen<VertexListS,
vertex_ptr>::type SeqVertexList;
typedef boost::integer_range<std::size_t> RandVertexList;
typedef typename boost::ct_if<is_rand_access,
typedef typename boost::ct_if_t<is_rand_access,
RandVertexList, SeqVertexList>::type VertexList;
typedef typename VertexList::iterator vertex_iterator;
@@ -1911,41 +1922,42 @@ namespace boost {
// need to reorganize this to avoid instantiating stuff
// that doesn't get used -JGS
typedef typename boost::ct_if< Directed,
typename boost::ct_if< Bidirectional && has_edge_property,
typedef typename boost::ct_if_t<DirectedT,
typename boost::ct_if_t< typename ct_and<BidirectionalT,has_edge_property>::type,
BidirEdgeList,
no_property
>::type,
typename boost::ct_if< has_edge_property,
typename boost::ct_if_t<has_edge_property,
UndirEdgeList,
UndirEdgeNoPropertyList
>::type
>::type EdgeContainer;
typedef typename boost::ct_if< Directed,
typename boost::ct_if< Bidirectional && has_edge_property,
typedef typename boost::ct_if_t<DirectedT,
typename boost::ct_if_t<typename ct_and<BidirectionalT,has_edge_property>::type,
typename BidirEdgeList::size_type,
std::size_t
>::type,
typename boost::ct_if< has_edge_property,
typename boost::ct_if_t<has_edge_property,
typename UndirEdgeList::size_type,
typename UndirEdgeNoPropertyList::size_type
>::type
>::type edges_size_type;
typedef typename boost::ct_if< Directed,
typename boost::ct_if< Bidirectional && has_edge_property,
typedef typename boost::ct_if_t< DirectedT,
typename boost::ct_if_t<typename ct_and<BidirectionalT, has_edge_property>::type,
typename BidirEdgeList::iterator,
typename BidirEdgeList::iterator // bogus, not used
>::type,
typename boost::ct_if< has_edge_property,
typename boost::ct_if_t<has_edge_property,
typename UndirEdgeList::iterator,
typename UndirEdgeNoPropertyList::iterator
>::type
>::type EdgeIter;
typedef typename boost::ct_if< Directed && !Bidirectional,
typename boost::ct_if< has_edge_property,
typedef typename ct_and<DirectedT, typename ct_not<BidirectionalT>::type>::type on_edge_storage;
typedef typename boost::ct_if_t<on_edge_storage,
typename boost::ct_if_t<has_edge_property,
stored_edge_property<vertex_descriptor, EdgeProperty>,
stored_edge<vertex_descriptor>
>::type,
@@ -2022,7 +2034,7 @@ namespace boost {
typedef adj_list_edge_iterator<vertex_iterator, out_edge_iterator,
graph_type> DirectedEdgeIter;
typedef typename boost::ct_if< Directed,
typedef typename boost::ct_if_t<DirectedT,
DirectedEdgeIter, UndirectedEdgeIter >::type edge_iterator;
// stored_vertex and StoredVertexList
@@ -2048,32 +2060,34 @@ namespace boost {
InEdgeList m_in_edges;
VertexProperty m_property;
};
typedef typename boost::ct_if< is_rand_access,
typename boost::ct_if< Bidirectional,
typedef typename boost::ct_if_t<is_rand_access,
typename boost::ct_if_t<BidirectionalT,
bidir_rand_stored_vertex, rand_stored_vertex>::type,
typename boost::ct_if< Bidirectional,
typename boost::ct_if_t<BidirectionalT,
bidir_seq_stored_vertex, seq_stored_vertex>::type
>::type StoredVertex;
struct stored_vertex : public StoredVertex { };
typedef typename container_gen<VertexListS, stored_vertex>::type
RandStoredVertexList;
typedef typename boost::ct_if< is_rand_access,
typedef typename boost::ct_if_t< is_rand_access,
RandStoredVertexList, SeqStoredVertexList>::type StoredVertexList;
};
}; // end of config
typedef typename boost::ct_if< Bidirectional,
typename boost::ct_if< has_edge_property,
typedef typename boost::ct_if_t<BidirectionalT,
typename boost::ct_if_t<has_edge_property,
bidirectional_graph_helper_with_property<config>,
bidirectional_graph_helper_without_property<config>
>::type,
typename boost::ct_if< Directed,
typename boost::ct_if_t<DirectedT,
directed_graph_helper<config>,
undirected_graph_helper<config>
>::type
>::type DirectedHelper;
typedef typename boost::ct_if< is_rand_access,
typedef typename boost::ct_if_t<is_rand_access,
vec_adj_list_impl<Graph, config, DirectedHelper>,
adj_list_impl<Graph, config, DirectedHelper>
>::type type;

View File

@@ -43,6 +43,7 @@ namespace adstl {
#endif
class array_binary_tree_node {
public:
typedef array_binary_tree_node ArrayBinaryTreeNode;
typedef RandomAccessIterator rep_iterator;
#if !defined BOOST_NO_STD_ITERATOR_TRAITS
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type
@@ -57,8 +58,8 @@ public:
struct children_type {
struct iterator
: boost::iterator<std::bidirectional_iterator_tag, array_binary_tree_node,
difference_type, array_binary_tree_node*, array_binary_tree_node&>
: boost::iterator<std::bidirectional_iterator_tag, ArrayBinaryTreeNode,
difference_type, array_binary_tree_node*, ArrayBinaryTreeNode&>
{ // replace with iterator_adaptor implementation -JGS
inline iterator() : i(0), n(0) { }
@@ -73,7 +74,8 @@ public:
size_type ii,
size_type nn,
const ID& _id) : r(rr), i(ii), n(nn), id(_id) { }
inline array_binary_tree_node operator*() { return array_binary_tree_node(r, i, n, id); }
inline array_binary_tree_node operator*() {
return ArrayBinaryTreeNode(r, i, n, id); }
inline iterator& operator++() { ++i; return *this; }
inline iterator operator++(int)
{ iterator t = *this; ++(*this); return t; }
@@ -116,7 +118,7 @@ public:
inline array_binary_tree_node() : i(0), n(0) { }
inline array_binary_tree_node(const array_binary_tree_node& x)
: r(x.r), i(x.i), n(x.n), id(x.id) { }
inline array_binary_tree_node& operator=(const array_binary_tree_node& x) {
inline ArrayBinaryTreeNode& operator=(const ArrayBinaryTreeNode& x) {
r = x.r;
i = x.i;
n = x.n;
@@ -125,16 +127,18 @@ public:
return *this;
}
inline array_binary_tree_node(rep_iterator start,
rep_iterator end,
rep_iterator pos, const ID& _id)
rep_iterator end,
rep_iterator pos, const ID& _id)
: r(start), i(pos - start), n(end - start), id(_id) { }
inline array_binary_tree_node(rep_iterator rr,
size_type ii,
size_type nn, const ID& _id)
size_type ii,
size_type nn, const ID& _id)
: r(rr), i(ii), n(nn), id(_id) { }
inline value_type& value() { return *(r + i); }
inline const value_type& value() const { return *(r + i); }
inline array_binary_tree_node parent() const { return array_binary_tree_node(r, (i - 1) / 2, n, id); }
inline ArrayBinaryTreeNode parent() const {
return ArrayBinaryTreeNode(r, (i - 1) / 2, n, id);
}
inline bool has_parent() const { return i != 0; }
inline children_type children() { return children_type(r, i, n, id); }
/*
@@ -146,7 +150,7 @@ public:
}
*/
template <class ExternalData>
inline void swap(array_binary_tree_node x, ExternalData& edata ) {
inline void swap(ArrayBinaryTreeNode x, ExternalData& edata ) {
value_type tmp = x.value();
/*swap external data*/

View File

@@ -33,125 +33,148 @@
#include <boost/pending/integer_range.hpp>
#include <boost/graph/graph_traits.hpp>
#ifndef __GNUC__
namespace boost {
#endif
//
// The edge_list class is an EdgeListGraph module that is constructed
// from a pair of iterators whose value type is a pair of vertex
// descriptors.
//
// For example:
//
// typedef std::pair<int,int> E;
// list<E> elist;
// ...
// typedef edge_list<list<E>::iterator> Graph;
// Graph g(elist.begin(), elist.end());
//
// If the iterators are random access, then Graph::edge_descriptor
// is of Integral type, otherwise it is a struct, though it is
// convertible to an Integral type.
//
//
// The edge_list class is an EdgeListGraph module that is constructed
// from a pair of iterators whose value type is a pair of vertex
// descriptors.
//
// For example:
//
// typedef std::pair<int,int> E;
// list<E> elist;
// ...
// typedef edge_list<list<E>::iterator> Graph;
// Graph g(elist.begin(), elist.end());
//
// If the iterators are random access, then Graph::edge_descriptor
// is of Integral type, otherwise it is a struct, though it is
// convertible to an Integral type.
//
// The implementation class for edge_list.
template <class G, class EdgeIter, class T, class D>
class edge_list_impl
{
public:
typedef D Eid;
typedef T Vpair;
typedef typename Vpair::first_type V;
typedef V vertex_descriptor;
struct edge_descriptor
// The implementation class for edge_list.
template <class G, class EdgeIter, class T, class D>
class edge_list_impl
{
edge_descriptor() { }
edge_descriptor(EdgeIter p, Eid id) : _ptr(p), _id(id) { }
operator Eid() { return _id; }
EdgeIter _ptr;
Eid _id;
public:
typedef D Eid;
typedef T Vpair;
typedef typename Vpair::first_type V;
typedef V vertex_descriptor;
struct edge_descriptor
{
edge_descriptor() { }
edge_descriptor(EdgeIter p, Eid id) : _ptr(p), _id(id) { }
operator Eid() { return _id; }
EdgeIter _ptr;
Eid _id;
};
typedef edge_descriptor E;
struct edge_iterator
{
typedef edge_iterator self;
typedef E value_type;
typedef E& reference;
typedef E* pointer;
typedef std::ptrdiff_t difference_type;
typedef std::input_iterator_tag iterator_category;
edge_iterator() { }
edge_iterator(EdgeIter iter) : _iter(iter), _i(0) { }
E operator*() { return E(_iter, _i); }
self& operator++() { ++_iter; ++_i; return *this; }
self operator++(int) { self t = *this; ++(*this); return t; }
bool operator==(const self& x) { return _iter == x._iter; }
bool operator!=(const self& x) { return _iter != x._iter; }
EdgeIter _iter;
Eid _i;
};
typedef void out_edge_iterator;
typedef void in_edge_iterator;
typedef void adjacency_iterator;
typedef void vertex_iterator;
};
typedef edge_descriptor E;
struct edge_iterator
{
typedef edge_iterator self;
typedef E value_type;
typedef E& reference;
typedef E* pointer;
typedef std::ptrdiff_t difference_type;
typedef std::input_iterator_tag iterator_category;
edge_iterator() { }
edge_iterator(EdgeIter iter) : _iter(iter), _i(0) { }
E operator*() { return E(_iter, _i); }
self& operator++() { ++_iter; ++_i; return *this; }
self operator++(int) { self t = *this; ++(*this); return t; }
bool operator==(const self& x) { return _iter == x._iter; }
bool operator!=(const self& x) { return _iter != x._iter; }
EdgeIter _iter;
Eid _i;
};
typedef void out_edge_iterator;
typedef void in_edge_iterator;
typedef void adjacency_iterator;
typedef void vertex_iterator;
typedef std::pair<edge_iterator,edge_iterator> EdgesRet;
friend EdgesRet edges(const G& g) {
return EdgesRet(edge_iterator(g._first), edge_iterator(g._last));
template <class G, class EI, class T, class D>
std::pair<typename edge_list_impl<G,EI,T,D>::edge_iterator,
typename edge_list_impl<G,EI,T,D>::edge_iterator>
edges(const edge_list_impl<G,EI,T,D>& g_) {
const G& g = static_cast<const G&>(g_);
typedef typename edge_list_impl<G,EI,T,D>::edge_iterator edge_iterator;
return std::make_pair(edge_iterator(g._first), edge_iterator(g._last));
}
friend V source(E e, const G&) {
template <class G, class EI, class T, class D>
typename edge_list_impl<G,EI,T,D>::vertex_descriptor
source(typename edge_list_impl<G,EI,T,D>::edge_descriptor e,
const edge_list_impl<G,EI,T,D>&) {
return (*e._ptr).first;
}
friend V target(E e, const G&) {
template <class G, class EI, class T, class D>
typename edge_list_impl<G,EI,T,D>::vertex_descriptor
target(typename edge_list_impl<G,EI,T,D>::edge_descriptor e,
const edge_list_impl<G,EI,T,D>&) {
return (*e._ptr).second;
}
};
// A specialized implementation for when the iterators are random access.
template <class G, class EdgeIter, class T, class D>
class edge_list_impl_ra
{
public:
typedef D E;
typedef T Vpair;
typedef typename Vpair::first_type V;
typedef E edge_descriptor;
typedef V vertex_descriptor;
typedef typename boost::integer_range<E>::iterator edge_iterator;
typedef void out_edge_iterator;
typedef void in_edge_iterator;
typedef void adjacency_iterator;
typedef void vertex_iterator;
typedef std::pair<edge_iterator,edge_iterator> EdgesRet;
// A specialized implementation for when the iterators are random access.
friend EdgesRet edges(const G& g) {
return EdgesRet(edge_iterator(0), edge_iterator(g._last - g._first));
template <class G, class EdgeIter, class T, class D>
class edge_list_impl_ra
{
public:
typedef D E;
typedef T Vpair;
typedef typename Vpair::first_type V;
typedef E edge_descriptor;
typedef V vertex_descriptor;
typedef typename boost::integer_range<E>::iterator edge_iterator;
typedef void out_edge_iterator;
typedef void in_edge_iterator;
typedef void adjacency_iterator;
typedef void vertex_iterator;
};
template <class G, class EI, class T, class D>
std::pair<typename edge_list_impl_ra<G,EI,T,D>::edge_iterator,
typename edge_list_impl_ra<G,EI,T,D>::edge_iterator>
edges(const edge_list_impl_ra<G,EI,T,D>& g_)
{
const G& g = static_cast<const G&>(g_);
typedef typename edge_list_impl_ra<G,EI,T,D>::edge_iterator edge_iterator;
return std::make_pair(edge_iterator(0), edge_iterator(g._last - g._first));
}
friend V source(E e, const G& g) {
template <class G, class EI, class T, class D>
typename edge_list_impl_ra<G,EI,T,D>::vertex_descriptor
source(typename edge_list_impl_ra<G,EI,T,D>::edge_descriptor e,
const edge_list_impl_ra<G,EI,T,D>& g_)
{
const G& g = static_cast<const G&>(g_);
return g._first[e].first;
}
friend V target(E e, const G& g) {
template <class G, class EI, class T, class D>
typename edge_list_impl_ra<G,EI,T,D>::vertex_descriptor
target(typename edge_list_impl_ra<G,EI,T,D>::edge_descriptor e,
const edge_list_impl_ra<G,EI,T,D>& g_)
{
const G& g = static_cast<const G&>(g_);
return g._first[e].second;
}
};
#ifdef __GNUC__
namespace boost {
#endif
// Some helper classes for determining if the iterators are random access
template <class Cat>
struct is_random { enum { RET = false }; };
struct is_random {
enum { RET = false };
typedef false_type type;
};
template <>
struct is_random<std::random_access_iterator_tag> { enum { RET = true }; };
struct is_random<std::random_access_iterator_tag> {
enum { RET = true }; typedef true_type type;
};
// The edge_list class conditionally inherits from one of the
// above two classes.
@@ -159,11 +182,12 @@ namespace boost {
#if !defined BOOST_NO_STD_ITERATOR_TRAITS
template <class EdgeIter,
class T = typename std::iterator_traits<EdgeIter>::value_type,
class D = typename std::iterator_traits<EdgeIter>::difference_type >
class D = typename std::iterator_traits<EdgeIter>::difference_type>
class edge_list
: public ct_if< is_random<typename std::iterator_traits<EdgeIter>::iterator_category>::RET,
edge_list_impl_ra< edge_list<EdgeIter,T,D>, EdgeIter, T, D >,
edge_list_impl< edge_list<EdgeIter,T,D>, EdgeIter, T, D >
: public ct_if_t< typename is_random<
typename std::iterator_traits<EdgeIter>::iterator_category>::type,
edge_list_impl_ra< edge_list<EdgeIter,T,D>, EdgeIter,T,D>,
edge_list_impl< edge_list<EdgeIter,T,D>, EdgeIter,T,D>
>::type
#else
template <class EdgeIter,

View File

@@ -157,7 +157,11 @@ namespace boost {
}
inline std::size_t random_number(std::size_t N) {
#if 0
std::size_t ret = rand() % N;
#else
std::size_t ret = 0;
#endif
return ret;
}