for myself

boost_graph-vc80-mt-gd-1_38.lib

#include <fstream>

#include <boost/graph/graphviz.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
namespace boost {
enum edge_haha_t{edge_haha = 9871};

BOOST_INSTALL_PROPERTY(edge, haha) ;
}
int main(int argc, char** argv) {
   using namespace boost ;




// Graph properties
   typedef property < graph_name_t, std::string
       //property<graph_edge_attribute_t, std::string>
       > graph_p;
   // Graph properties
   //typedef property < graph_name_t, std::string,
    //   property<graph_edge_attribute_t, std::string>
   //> graph_p;


   typedef property< vertex_name_t, std::string> r_vertex_p ;
   typedef property<edge_weight_t, int, property<edge_weight2_t, std::string,
       property<edge_haha_t, std::string> >
       > r_edge_p ;
   typedef adjacency_list<vecS, vecS, directedS,
      r_vertex_p, r_edge_p, graph_p> r_graph_t ;
 

// Construct an empty graph and prepare the dynamic_property_maps.
   r_graph_t r_graph ;
   dynamic_properties dp;

   property_map<r_graph_t, vertex_name_t>::type name =
      get(vertex_name, r_graph);
   dp.property("node_id",name);

 
   property_map<r_graph_t, edge_weight_t>::type weight =
      get(edge_weight, r_graph);
   dp.property("label",weight);
   property_map<r_graph_t, edge_weight2_t>::type weight2 =
       get(edge_weight2, r_graph) ;
   dp.property("style", weight2) ;
   property_map<r_graph_t, edge_haha_t>::type haha =
       get(edge_haha, r_graph) ;
   dp.property("haha",haha) ;
   //boost::ref_property_map<r_graph_t*, std::string> style(
    //   get_property(r_graph,graph_graph_attribute)) ;
   //dp.property("style", style) ;
   //graph_property<r_graph_t, graph_edge_attribute_t>::type e_a =
       //get_property(r_graph, edge_weight2) ;
    //   get(edge_weight2, r_graph) ;
   //dp.property("style",e_a);
   // property_map<r_graph_t, graph_edge_attribute_t>::type edge_style =
   //   get(graph_edge_attribute, r_graph) ;
   // dp.property("style", edge_style) ;

// Use ref_property_map to turn a graph property into a property map
   boost::ref_property_map<r_graph_t*,std::string>
      gname(get_property(r_graph,graph_name));
   dp.property("name",gname);
   dp.property("size",gname) ;
   dp.property("ratio",gname) ;
//   boost::ref_property_map<r_graph_t*, std::string>
   //   estyle(get_property(r_graph, graph_edge_attribute)) ;
   //dp.property("style", estyle) ;

// Sample graph as an std::istream;
   std::string node_id = "node_id" ;
   std::ifstream file_in("ospf-graph.dot") ;
   bool status = read_graphviz(file_in,r_graph,dp);
   graph_traits<r_graph_t>::vertex_iterator it, it_end ;
   for(tie(it,it_end) = vertices(r_graph) ; it != it_end ; ++it) {
      std::cout << name[*it] << " " ;
      //std::cout << mass[*it] << " " ;
   }
   std::cout << std::endl ;
   graph_traits<r_graph_t>::edge_iterator ei, ei_end ;
   for(tie(ei,ei_end) = edges(r_graph); ei != ei_end ; ++ei) {
       std::cout << weight[*ei] << " "
           << weight2[*ei] << " " << haha[*ei]<< std::endl;
   }
  

   std::cout << status << std::endl ;
   return 0 ;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值