Porblem in Graph (object oriented) using Boost Graph Library

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Man4ish
    New Member
    • Mar 2008
    • 151

    Porblem in Graph (object oriented) using Boost Graph Library

    namespace ve/////////////////ve.h
    {
    struct VertexPropertie s
    {
    std::size_t index;
    boost::default_ color_type color;
    };
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    namespace ed///////////////////////ed.h
    {
    struct EdgeProperties
    {
    EdgeProperties( const std::string& n) : name(n) { }
    std::string name;
    };
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    #include <boost/config.hpp>
    #include <iostream>
    #include <vector>
    #include <utility>
    #include <string>
    #include <boost/graph/adjacency_list. hpp>
    #include <boost/graph/graph_utility.h pp>
    #include <boost/property_map.hp p>
    #include "ed.h"
    #include "ve.h"
    using namespace boost;
    using namespace std;
    class Construct
    {
    public:

    void create_graph(in t s1[],int s2[],int s3[])
    {
    typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
    const int V = 50;
    Graph g(V);
    property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type
    id = get(&ve::Vertex Properties::ind ex, g);
    property_map<Gr aph, std::string ed::EdgePropert ies::*>::type
    name = get(&ed::EdgePr operties::name, g);
    boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
    int vnum = 0;
    for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
    id[*vi] = vnum++;
    for (int i = 0; i <50 ; i++)
    {
    if(s3[i]==1){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("single bond"), g);
    }
    if(s3[i]==2){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("double bond"), g);
    }
    if(s3[i]==3){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("triple_bon d"), g);
    }
    }
    graph_traits<Gr aph>::vertex_it erator i, end;
    graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
    for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
    {
    cout << id[*i] << " ";
    for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
    cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
    cout << endl;
    }
    print_edges(g, id);
    }
    };



    int main(int , char* [])
    {
    Construct h;
    int s1[]={1,1,2,2,3,3,4 ,4,5,5,6,6,6,7, 7,7,8,8,8,8,9,9 ,10,10,11,11,12 ,12,13,14,17,19 ,19,19,20,20,20 ,21,21,21};
    int s2[]={13,19,14,20,1 5,21,16,18,17,1 8,16,27,28,18,3 8,39,9,10,22,23 ,11,12,16,17,14 ,24,13,25,15,15 ,26,29,30,31,32 ,33,34,35,36,37 };
    int s3[]={1,1,1,1,1,1,2 ,1,1,2,1,1,1,1, 1,1,1,1,1,1,2,1 ,1,2,1,1,2,1,1, 2,1,1,1,1,1,1,1 ,1,1,1};
    h.create_graph( s1,s2,s3);
    return 0;
    }

    This is program is working fine but i want to return the graph object in one function.
    and need to pass the graph object in other function for printing the adjacency list
    like ...
    #include <boost/config.hpp>
    #include <iostream>
    #include <vector>
    #include <utility>
    #include <string>
    #include <boost/graph/adjacency_list. hpp>
    #include <boost/graph/graph_utility.h pp>
    #include <boost/property_map.hp p>
    #include "ed.h"
    #include "ve.h"
    using namespace boost;
    using namespace std;
    class Gra
    {
    public:
    typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
    Graph& create_graph(in t s1[],int s2[],int s3[])
    {
    typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
    const int V = 50;
    Graph g(V);
    property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type
    id = get(&ve::Vertex Properties::ind ex, g);
    property_map<Gr aph, std::string ed::EdgePropert ies::*>::type
    name = get(&ed::EdgePr operties::name, g);
    boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
    int vnum = 0;
    for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
    id[*vi] = vnum++;
    for (int i = 0; i <40 ; i++)
    {
    if(s3[i]==1){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("single bond"), g);
    }
    if(s3[i]==2){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("double bond"), g);
    }
    if(s3[i]==3){
    add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("triple_bon d"), g);
    }
    }
    /*graph_traits<G raph>::vertex_i terator i, end;
    graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
    for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
    {
    cout << id[*i] << " ";
    for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
    cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
    cout << endl;
    }
    print_edges(g, id);
    * */
    return g;
    }
    void get_edges(const Graph& g)
    {
    property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type id = get(&ve::Vertex Properties::ind ex, g);
    property_map<Gr aph, std::string ed::EdgePropert ies::*>::type name = get(&ed::EdgePr operties::name, g);
    boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
    int vnum = 0;
    for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
    id[*vi] = vnum++;
    graph_traits<Gr aph>::vertex_it erator i, end;
    graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
    for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
    {
    cout << id[*i] << " ";
    for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
    cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
    cout << endl;
    }
    print_edges(g, id);
    }


    };



    int main(int , char* [])
    {
    Gra h;
    int s1[]={1,1,2,2,3,3,4 ,4,5,5,6,6,6,7, 7,7,8,8,8,8,9,9 ,10,10,11,11,12 ,12,13,14,17,19 ,19,19,20,20,20 ,21,21,21};
    int s2[]={13,19,14,20,1 5,21,16,18,17,1 8,16,27,28,18,3 8,39,9,10,22,23 ,11,12,16,17,14 ,24,13,25,15,15 ,26,29,30,31,32 ,33,34,35,36,37 };
    int s3[]={1,1,1,1,1,1,2 ,1,1,2,1,1,1,1, 1,1,1,1,1,1,2,1 ,1,2,1,1,2,1,1, 2,1,1,1,1,1,1,1 ,1,1,1};
    h.create_graph( s1,s2,s3);
    h.get_edges(h.c reate_graph(s1, s2,s3));
    return 0;
    }
    1.
    It is giving the following error
    create_graph1.c pp:57: error: conversion from ‘boost::bundle_ property_map<co nst boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, const unsigned int>’ to non-scalar type ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, unsigned int>’ requested
    2.
    create_graph1.c pp:58: error: conversion from ‘boost::bundle_ property_map<co nst boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::detail:: edge_desc_impl< boost::undirect ed_tag, void*>, ed::EdgePropert ies, const std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >’ to non-scalar type ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::detail:: edge_desc_impl< boost::undirect ed_tag, void*>, ed::EdgePropert ies, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >’ requested

    can you help me in doing this.I will be very thankful to you .
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by Man4ish
    create_graph1.c pp:57: error:
    Which line is line 57?

    Comment

    • Man4ish
      New Member
      • Mar 2008
      • 151

      #3
      Originally posted by Man4ish
      namespace ve/////////////////ve.h
      {
      struct VertexPropertie s
      {
      std::size_t index;
      boost::default_ color_type color;
      };
      }
      ///////////////////////////////////////////////////////////////////////////////////////////////////
      namespace ed///////////////////////ed.h
      {
      struct EdgeProperties
      {
      EdgeProperties( const std::string& n) : name(n) { }
      std::string name;
      };
      }
      ////////////////////////////////////////////////////////////////////////////////////////////////////

      #include <boost/config.hpp>
      #include <iostream>
      #include <vector>
      #include <utility>
      #include <string>
      #include <boost/graph/adjacency_list. hpp>
      #include <boost/graph/graph_utility.h pp>
      #include <boost/property_map.hp p>
      #include "ed.h"
      #include "ve.h"
      using namespace boost;
      using namespace std;
      class Construct
      {
      public:

      void create_graph(in t s1[],int s2[],int s3[])
      {
      typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
      const int V = 50;
      Graph g(V);
      property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type
      id = get(&ve::Vertex Properties::ind ex, g);
      property_map<Gr aph, std::string ed::EdgePropert ies::*>::type
      name = get(&ed::EdgePr operties::name, g);
      boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
      int vnum = 0;
      for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
      id[*vi] = vnum++;
      for (int i = 0; i <50 ; i++)
      {
      if(s3[i]==1){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("single bond"), g);
      }
      if(s3[i]==2){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("double bond"), g);
      }
      if(s3[i]==3){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("triple_bon d"), g);
      }
      }
      graph_traits<Gr aph>::vertex_it erator i, end;
      graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
      for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
      {
      cout << id[*i] << " ";
      for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
      cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
      cout << endl;
      }
      print_edges(g, id);
      }
      };



      int main(int , char* [])
      {
      Construct h;
      int s1[]={1,1,2,2,3,3,4 ,4,5,5,6,6,6,7, 7,7,8,8,8,8,9,9 ,10,10,11,11,12 ,12,13,14,17,19 ,19,19,20,20,20 ,21,21,21};
      int s2[]={13,19,14,20,1 5,21,16,18,17,1 8,16,27,28,18,3 8,39,9,10,22,23 ,11,12,16,17,14 ,24,13,25,15,15 ,26,29,30,31,32 ,33,34,35,36,37 };
      int s3[]={1,1,1,1,1,1,2 ,1,1,2,1,1,1,1, 1,1,1,1,1,1,2,1 ,1,2,1,1,2,1,1, 2,1,1,1,1,1,1,1 ,1,1,1};
      h.create_graph( s1,s2,s3);
      return 0;
      }

      This is program is working fine but i want to return the graph object in one function.
      and need to pass the graph object in other function for printing the adjacency list
      like ...
      #include <boost/config.hpp>
      #include <iostream>
      #include <vector>
      #include <utility>
      #include <string>
      #include <boost/graph/adjacency_list. hpp>
      #include <boost/graph/graph_utility.h pp>
      #include <boost/property_map.hp p>
      #include "ed.h"
      #include "ve.h"
      using namespace boost;
      using namespace std;
      class Gra
      {
      public:
      typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
      Graph& create_graph(in t s1[],int s2[],int s3[])
      {
      typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
      const int V = 50;
      Graph g(V);
      property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type
      id = get(&ve::Vertex Properties::ind ex, g);
      property_map<Gr aph, std::string ed::EdgePropert ies::*>::type
      name = get(&ed::EdgePr operties::name, g);
      boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
      int vnum = 0;
      for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
      id[*vi] = vnum++;
      for (int i = 0; i <40 ; i++)
      {
      if(s3[i]==1){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("single bond"), g);
      }
      if(s3[i]==2){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("double bond"), g);
      }
      if(s3[i]==3){
      add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("triple_bon d"), g);
      }
      }
      /*graph_traits<G raph>::vertex_i terator i, end;
      graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
      for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
      {
      cout << id[*i] << " ";
      for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
      cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
      cout << endl;
      }
      print_edges(g, id);
      * */
      return g;
      }
      void get_edges(const Graph& g)
      {
      property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type id = get(&ve::Vertex Properties::ind ex, g);
      property_map<Gr aph, std::string ed::EdgePropert ies::*>::type name = get(&ed::EdgePr operties::name, g);
      boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
      int vnum = 0;
      for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
      id[*vi] = vnum++;
      graph_traits<Gr aph>::vertex_it erator i, end;
      graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
      for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
      {
      cout << id[*i] << " ";
      for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
      cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
      cout << endl;
      }
      print_edges(g, id);
      }


      };



      int main(int , char* [])
      {
      Gra h;
      int s1[]={1,1,2,2,3,3,4 ,4,5,5,6,6,6,7, 7,7,8,8,8,8,9,9 ,10,10,11,11,12 ,12,13,14,17,19 ,19,19,20,20,20 ,21,21,21};
      int s2[]={13,19,14,20,1 5,21,16,18,17,1 8,16,27,28,18,3 8,39,9,10,22,23 ,11,12,16,17,14 ,24,13,25,15,15 ,26,29,30,31,32 ,33,34,35,36,37 };
      int s3[]={1,1,1,1,1,1,2 ,1,1,2,1,1,1,1, 1,1,1,1,1,1,2,1 ,1,2,1,1,2,1,1, 2,1,1,1,1,1,1,1 ,1,1,1};
      h.create_graph( s1,s2,s3);
      h.get_edges(h.c reate_graph(s1, s2,s3));
      return 0;
      }
      1.
      It is giving the following error
      create_graph1.c pp:57: error: conversion from ‘boost::bundle_ property_map<co nst boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, const unsigned int>’ to non-scalar type ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, unsigned int>’ requested
      2.
      create_graph1.c pp:58: error: conversion from ‘boost::bundle_ property_map<co nst boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::detail:: edge_desc_impl< boost::undirect ed_tag, void*>, ed::EdgePropert ies, const std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >’ to non-scalar type ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::detail:: edge_desc_impl< boost::undirect ed_tag, void*>, ed::EdgePropert ies, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >’ requested

      can you help me in doing this.I will be very thankful to you .

      Actually i am trying to do object oriented programming , for that i need graph object to be returned by the function and i can pass that object to different boost graph functions like print edges,detect cycles,print vertices.
      But I am facing the pblm in line 57 and 58(using two namespaces ,ve and ed in files ve.h and ed.h respectively).







      Line No-57
      property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type id = get(&ve::Vertex Properties::ind ex, g);

      Line -58
      property_map<Gr aph, std::string ed::EdgePropert ies::*>::type name = get(&ed::EdgePr operties::name, g);

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The error on line 57 is using this:

        ‘boost::bundle_ property_map<const boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, const unsigned int>’

        And you are using:

        ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, unsigned int>’ requested

        Notice there is no const.

        The errror occurs because a const cannot be converted to a non-const.

        The compiler fears that a const adjacancy list used in a non-const manner will cause a crash should the list need to be updated. Same problem with the VertexPropertie s.

        Maybe this will help.

        Comment

        • Man4ish
          New Member
          • Mar 2008
          • 151

          #5
          Originally posted by weaknessforcats
          The error on line 57 is using this:

          ‘boost::bundle_ property_map<const boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, const unsigned int>’

          And you are using:

          ‘boost::bundle_ property_map<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, void*, ve::VertexPrope rties, unsigned int>’ requested

          Notice there is no const.

          The errror occurs because a const cannot be converted to a non-const.

          The compiler fears that a const adjacancy list used in a non-const manner will cause a crash should the list need to be updated. Same problem with the VertexPropertie s.

          Maybe this will help.



          Thanks Sir,
          That pblm is solved but still i facing the pblm in Graph object creation.
          I have created Graph object without vertex and edge property.It is working fine.

          #include <boost/config.hpp>
          #include <iostream>
          #include <vector>
          #include <string>
          #include <boost/graph/adjacency_list. hpp>
          #include <boost/tuple/tuple.hpp>
          #include <set>
          using namespace std;
          using namespace boost;
          class hello
          {
          public:
          typedef adjacency_list< > Graph;

          Graph create_Graph(ve ctor <int> s1,vector <int> s2,int count_vetices)
          {
          typedef adjacency_list <>Graph;
          Graph g(count_vetices );
          for (unsigned int i = 0; i < s1.size(); i++)
          {
          add_edge(s1[i], s2[i], g);
          }
          return g;
          }

          int no_of_elements( vector<int> v2,vector<int> v3)
          {
          vector<int> v4;
          for (unsigned int i = 0; i < v2.size(); i++)
          {
          v4.push_back(v2[i]);
          v4.push_back(v3[i]);
          }
          std::set< int, std::less< int > > doubleSet( v4.begin(), v4.end());;
          return doubleSet.size( );
          }

          void get_adjacencyLi st(const Graph&g)
          {
          int name[]={0,1,2,3,4,5,6 ,7,8,9};
          graph_traits < adjacency_list <> >::vertex_itera tor i, end;
          graph_traits < adjacency_list <> >::adjacency_it erator ai, a_end;
          property_map < adjacency_list <>, vertex_index_t >::type
          index_map = get(vertex_inde x, g);

          for (tie(i, end) = vertices(g); i != end; ++i)
          {
          std::cout << name[get(index_map, *i)];
          tie(ai, a_end) = adjacent_vertic es(*i, g);
          if (ai == a_end)
          std::cout << " no children";
          else
          std::cout << " is the parent of ";
          for (; ai != a_end; ++ai)
          {
          std::cout << name[get(index_map, *ai)];
          if (boost::next(ai ) != a_end)
          std::cout << ", ";
          }
          std::cout << std::endl;
          }
          }

          };
          int main()
          {
          using namespace boost;
          hello h;
          typedef adjacency_list <>Graph;
          vector<int> s1,s2;
          s1.push_back(1) ;
          s1.push_back(2) ;
          s1.push_back(3) ;
          s1.push_back(4) ;
          s1.push_back(5) ;
          s1.push_back(6) ;
          s2.push_back(7) ;
          s2.push_back(8) ;
          s2.push_back(4) ;
          s2.push_back(1) ;
          s2.push_back(9) ;
          s2.push_back(5) ;
          int n=h.no_of_eleme nts(s1,s2);
          cout<<"no of elements ="<< h.no_of_element s(s1,s2)<<endl;
          Graph g = h.create_Graph( s1,s2,n);////////////////getting graph object
          h.get_adjacency List(g);
          return EXIT_SUCCESS;
          }

          But when i am trying with vertex and edge property.


          #include <boost/config.hpp>
          #include <iostream>
          #include <vector>
          #include <utility>
          #include <string>
          #include <boost/graph/adjacency_list. hpp>
          #include <boost/graph/graph_utility.h pp>
          #include <boost/property_map.hp p>
          #include "ed.h"
          #include "ve.h"
          using namespace boost;
          using namespace std;
          class Network
          {
          public:
          typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
          Graph create_graph(in t s1[],int s2[],int s3[])
          {
          typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
          const int V = 50;
          Graph g(V);
          property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type
          id = get(&ve::Vertex Properties::ind ex, g);
          property_map<Gr aph, std::string ed::EdgePropert ies::*>::type
          name = get(&ed::EdgePr operties::name, g);
          boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
          int vnum = 0;
          for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
          id[*vi] = vnum++;
          for (int i = 0; i <40 ; i++)
          {
          if(s3[i]==1){
          add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("single bond"), g);
          }
          if(s3[i]==2)
          {
          add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("double bond"), g);
          }
          if(s3[i]==3){
          add_edge(vertex (s1[i], g), vertex(s2[i], g), ed::EdgePropert ies("triple_bon d"), g);
          }
          }
          return g;
          }

          void get_edges( Graph g)
          {
          property_map<Gr aph, std::size_t ve::VertexPrope rties::*>::type id = get(&ve::Vertex Properties::ind ex, g);
          property_map<Gr aph, std::string ed::EdgePropert ies::*>::type name = get(&ed::EdgePr operties::name, g);
          boost::graph_tr aits<Graph>::ve rtex_iterator vi, viend;
          int vnum = 0;
          for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi)
          id[*vi] = vnum++;
          graph_traits<Gr aph>::vertex_it erator i, end;
          graph_traits<Gr aph>::out_edge_ iterator ei, edge_end;
          for (boost::tie(i,e nd) = vertices(g); i != end; ++i)
          {
          cout << id[*i] << " ";
          for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei)
          cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " ";
          cout << endl;
          }
          print_edges(g, id);
          }

          };



          int main(int , char* [])
          {
          Network h;
          typedef adjacency_list< boost::vecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies> Graph;
          int s1[]={1,1,2,2,3,3,4 ,4,5,5,6,6,6,7, 7,7,8,8,8,8,9,9 ,10,10,11,11,12 ,12,13,14,17,19 ,19,19,20,20,20 ,21,21,21};
          int s2[]={13,19,14,20,1 5,21,16,18,17,1 8,16,27,28,18,3 8,39, 9,10,22,23,11,1 2,16,17,14,24,1 3,25,15,15,26,2 9,30, 31,32,33,34,35, 36,37};
          int s3[]={1,1,1,1,1,1,2 ,1,1,2,1,1,1,1, 1,1,1,1,1,1,2,1 ,1,2, 1,1,2,1,1,2,1,1 ,1,1,1,1,1,1,1, 1};
          Graph obj= h.create_graph( s1,s2,s3);
          h.get_edges(obj );
          return 0;
          }


          /usr/include/boost/graph/detail/adjacency_list. hpp:986: instantiated from ‘std::pair<type name Config::edge_de scriptor, bool> boost::add_edge (typename Config::vertex_ descriptor, typename Config::vertex_ descriptor, boost::undirect ed_graph_helper <C>&) [with Config = boost::detail:: adj_list_gen<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::listS, boost::vecS, boost::undirect edS, boost::property <boost::vertex_ bundle_t, ve::VertexPrope rties, boost::no_prope rty>, boost::property <boost::edge_bu ndle_t, ed::EdgePropert ies, boost::no_prope rty>, boost::no_prope rty, boost::listS>:: config]’

          /usr/include/boost/graph/detail/adjacency_list. hpp:986: instantiated from ‘std::pair<type name Config::edge_de scriptor, bool> boost::add_edge (typename Config::vertex_ descriptor, typename Config::vertex_ descriptor, boost::undirect ed_graph_helper <C>&) [with Config = boost::detail:: adj_list_gen<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::listS, boost::vecS, boost::undirect edS, boost::property <boost::vertex_ bundle_t, ve::VertexPrope rties, boost::no_prope rty>, boost::property <boost::edge_bu ndle_t, ed::EdgePropert ies, boost::no_prope rty>, boost::no_prope rty, boost::listS>:: config]’

          /usr/include/boost/graph/detail/adjacency_list. hpp:1705: instantiated from ‘boost::adj_lis t_impl<Derived, Config, Base>::adj_list _impl(const boost::adj_list _impl<Derived, Config, Base>&) [with Derived = boost::adjacenc y_list<boost::v ecS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, Config = boost::detail:: adj_list_gen<bo ost::adjacency_ list<boost::vec S, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::listS, boost::vecS, boost::undirect edS, boost::property <boost::vertex_ bundle_t, ve::VertexPrope rties, boost::no_prope rty>, boost::property <boost::edge_bu ndle_t, ed::EdgePropert ies, boost::no_prope rty>, boost::no_prope rty, boost::listS>:: config, Base = boost::undirect ed_graph_helper <boost::detail: :adj_list_gen<b oost::adjacency _list<boost::ve cS, boost::listS, boost::undirect edS, ve::VertexPrope rties, ed::EdgePropert ies, boost::no_prope rty, boost::listS>, boost::listS, boost::vecS, boost::undirect edS, boost::property <boost::vertex_ bundle_t, ve::VertexPrope rties, boost::no_prope rty>, boost::property <boost::edge_bu ndle_t, ed::EdgePropert ies, boost::no_prope rty>, boost::no_prope rty, boost::listS>:: config>]’

          /usr/include/boost/graph/adjacency_list. hpp:368: instantiated from ‘boost::adjacen cy_list<OutEdge ListS, VertexListS, DirectedS, VertexProperty, EdgeProperty, GraphProperty, EdgeListS>::adj acency_list(con st boost::adjacenc y_list<OutEdgeL istS, VertexListS, DirectedS, VertexProperty, EdgeProperty, GraphProperty, EdgeListS>&) [with OutEdgeListS = boost::vecS, VertexListS = boost::listS, DirectedS = boost::undirect edS, VertexProperty = ve::VertexPrope rties, EdgeProperty = ed::EdgePropert ies, GraphProperty = boost::no_prope rty, EdgeListS = boost::listS]’

          create_object.c pp:43: instantiated from here
          Please help me out of this pblm .I will be thankful to you.

          Comment

          Working...