Boost logo

Boost Users :

From: Trevon Fuller (yg-boost-users_at_[hidden])
Date: 2003-08-12 12:09:40


Is there documentation anywhere that explains how to build and link graphviz
for MSVC .NET for use with the BOOST graph library?

I am trying to compile the example ospf-example.cpp from the BOOST graph
library in MSVC .NET. I am using BOOST 1.30.0. I built the graphviz library
using bjam with the vc7 toolset. I am getting a compile error:

c:\boost_1_30_0\boost\tuple\detail\tuple_basic_no_partial_spec.hpp(83):
error C2679: binary '=' : no operator found which takes a right-hand operand
of type 'const
boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexP
roperty,EdgeProperty,GraphProperty,EdgeListS>::config::edge_iterator' (or
there is no acceptable conversion)

with

        [

Graph=boost::adjacency_list<boost::vecS,boost::vecS,boost::directedS,boost::

no_property,boost::property<boost::edge_weight_t,int,boost::no_property>,boo

st::no_property,boost::listS>,

VertexListS=boost::vecS,

OutEdgeListS=boost::vecS,

DirectedS=boost::directedS,

VertexProperty=boost::no_property,

EdgeProperty=boost::property<boost::edge_weight_t,int,boost::no_property>,

GraphProperty=boost::no_property,

EdgeListS=boost::listS

        ]

I think this error is due to the fact that MSVC does not support partial
template specialization. Also, when I comment out all of the code except for
the first 3 lines of the main, I get the error :

dijkstra_link_state_routing error result returned from 'cl.exe'

("dijkstra_link_state_routing" is the name of the solution that contains the
file ospf-example.cpp).

Any suggestions anyone could offer would be appreciated. Below is the code
for ospf-example.cpp. It is the same as the code on the BOOST website.

Thanks,

Trevon Fuller

//======================================================================

// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,

//

// This file is part of the Boost Graph Library

//

// You should have received a copy of the License Agreement for the // Boost
Graph Library along with the software; see the file LICENSE.

// If not, contact Office of Research, Indiana University,

// Bloomington, IN 47405.

//

// Permission to modify the code and to distribute the code is // granted,
provided the text of this NOTICE is retained, a notice if // the code was
modified is included with the above COPYRIGHT NOTICE // and with the
COPYRIGHT NOTICE in the LICENSE file, and that the // LICENSE file is
distributed with the modified code.

//

// 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.

//======================================================================

#include <fstream> // for file I/O

#include <boost/graph/graphviz.hpp> // for read/write_graphviz()

#include <boost/graph/dijkstra_shortest_paths.hpp>

#include <boost/lexical_cast.hpp>

int

main()

{

using namespace boost;

GraphvizDigraph g_dot;

read_graphviz("figs/ospf-graph.dot", g_dot);

typedef adjacency_list < vecS, vecS, directedS, no_property,

property < edge_weight_t, int > > Graph; typedef graph_traits < Graph
>::vertex_descriptor vertex_descriptor;

Graph g(num_vertices(g_dot));

property_map < GraphvizDigraph, edge_attribute_t >::type

edge_attr_map = get(edge_attribute, g_dot);

graph_traits < GraphvizDigraph >::edge_iterator ei, ei_end;

for (tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) {

int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); property <
edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot),
target(*ei, g_dot), edge_property, g);

  }

vertex_descriptor router_six;

property_map < GraphvizDigraph, vertex_attribute_t >::type

vertex_attr_map = get(vertex_attribute, g_dot); graph_traits <
GraphvizDigraph >::vertex_iterator vi, vi_end; for (tie(vi, vi_end) =
vertices(g_dot); vi != vi_end; ++vi)

if ("RT6" == vertex_attr_map[*vi]["label"]) {

router_six = *vi;

break;

    }

std::vector < vertex_descriptor > parent(num_vertices(g));

// All vertices start out as there own parent typedef graph_traits < Graph
>::vertices_size_type size_type; for (size_type p = 0; p < num_vertices(g);
++p)

parent[p] = p;

#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300

std::vector<int> distance(num_vertices(g));

property_map<Graph, edge_weight_t>::type weightmap = get(edge_weight, g);

property_map<Graph, vertex_index_t>::type indexmap = get(vertex_index, g);

dijkstra_shortest_paths

(g, router_six, &parent[0], &distance[0], weightmap,

indexmap, std::less<int>(), closed_plus<int>(),

std::numeric_limits<int>::max(), 0, default_dijkstra_visitor());

#else dijkstra_shortest_paths(g, router_six, predecessor_map(&parent[0]));

#endif

graph_traits < GraphvizDigraph >::edge_descriptor e;

for (size_type i = 0; i < num_vertices(g); ++i)

if (parent[i] != i) {

e = edge(parent[i], i, g_dot).first;

edge_attr_map[e]["color"] = "black";

    }

#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300

// VC++ can't handle write_graphviz :(

  {

std::ofstream out("figs/ospf-sptree.dot");

out << "digraph loops {\n"

<< "size=\"3,3\"\n"

<< "ratio=\"fill\"\n"

<< "shape=\"box\"\n";

graph_traits<Graph>::vertex_iterator vi, vi_end;

for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {

out << *vi << "[";

for (std::map<std::string,std::string>::iterator ai

vertex_attr_map[*vi].begin();

ai != vertex_attr_map[*vi].end(); ++ai) {

out << ai->first << "=" << ai->second;

if (next(ai) != vertex_attr_map[*vi].end())

out << ", ";

      }

out<< "]";

    }

for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {

out << source(*ei, g) << " -> " << target(*ei, g) << "[";

std::map<std::string,std::string>& attr_map = edge_attr_map[*ei];

for (std::map<std::string,std::string>::iterator eai

attr_map.begin();

eai != attr_map.end(); ++eai) {

out << eai->first << "=" << eai->second;

if (next(eai) != attr_map.end())

out << ", ";

      }

out<< "]";

    }

out << "}\n";

  }

#else

graph_property < GraphvizDigraph, graph_edge_attribute_t >::type &

graph_edge_attr_map = get_property(g_dot, graph_edge_attribute);
graph_edge_attr_map["color"] = "grey"; write_graphviz("figs/ospf-sptree.dot"
, g_dot);

#endif

std::ofstream rtable("routing-table.dat");

rtable << "Dest Next Hop Total Cost" << std::endl;

for (tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi)

if (parent[*vi] != *vi) {

rtable << vertex_attr_map[*vi]["label"] << " ";

vertex_descriptor v = *vi, child;

int path_cost = 0;

property_map < Graph, edge_weight_t >::type

weight_map = get(edge_weight, g);

do {

path_cost += get(weight_map, edge(parent[v], v, g).first); child = v; v =
parent[v];

} while (v != parent[v]); rtable << vertex_attr_map[child]["label"] <<
" "; rtable << path_cost << std::endl;

    }

return EXIT_SUCCESS;

}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net