hi,
      i  started using BGL for my project.
      strangely all the examples i tried to learn BGL worked fine. But when i write the
      actual code for my project, it started giving me this error.

     Problem:
             While adding second edge to the boost graph using boost::add_edge(u,v,g)
      it is giving out a seg fault.

Please help with this prob.

Iam also attaching the code that's giving the error

/*********Code that's giving this error****************/
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stdlib.h>
#include<string>
#include<sstream>
#include<boost/graph/graph_traits.hpp>
#include<boost/graph/adjacency_list.hpp>

class Node{
   
        public:
        std::string id;
        double Energy;
        Node() {}

};

class EdgeProperties {
    public:
    int targetI;
    int sourceI;
    EdgeProperties(int s,int t):sourceI(s),targetI(t) { }
};

typedef boost::adjacency_list<boost::listS,boost::listS,boost::bidirectionalS,
                                Node *,EdgeProperties *> Graph;

typedef boost::graph_traits<Graph> GraphTraits;
typedef GraphTraits::vertex_descriptor Vertex;
typedef GraphTraits::edge_descriptor Edge;

namespace boost {

    Vertex getVertexbyId(std::string id,Graph g){
        std::cout << "getVID called for " << id << std::endl;
        fflush(stdout);
        GraphTraits::vertex_iterator vstart,vend;
        for(boost::tie(vstart,vend) = boost::vertices(g); vstart!=vend; vstart++) {
            if(g[*vstart]->id == (id)) return *vstart;
        }
        std::cout << "Critical Error: |" << id << "| referencing node not present in graph " << std::endl;
        return NULL;
    }
}

int main(){
   
    Graph g;
   
    // populate Graph with all the vertices and edges.
    std::cout << "* Populating graph with Vertices and Edges " << std::endl;
    fflush(stdout);
   
    Vertex v = boost::add_vertex(g);
    g[v] = new Node();
    g[v]->id = "xor_1";
    g[v]->Energy = 2.3;
   
    std::cout << "Inserted xor_1" << std::endl;
    fflush(stdout);
   
   
    v = boost::add_vertex(g);
    g[v] = (new Node());
    g[v]->id = "and_1";
    g[v]->Energy = 1.9;
       
    std::cout << "Inserted and_1" << std::endl;
    fflush(stdout);
   
    v = boost::add_vertex(g);
    g[v] = (new Node());
    g[v]->id = "i_1";
    std::cout << "Inserted i_1" << std::endl;
    fflush(stdout);
   
    // add Edges
   
    std::pair<Edge,bool> e;
   
    EdgeProperties *ep = new EdgeProperties(1,1);
    e = boost::add_edge(boost::getVertexbyId("i_1",g),boost::getVertexbyId("and_1",g),ep,g);
    std::cout << "Inserted Edge 1" << std::endl;
    fflush(stdout);
   
    ep = new EdgeProperties(1,2);
    e = boost::add_edge(boost::getVertexbyId("i_1",g),boost::getVertexbyId("xor_1",g),ep,g);
    std::cout << "Inserted Edge 2" << std::endl;
    fflush(stdout);
   
}


/*******************************************************/

-
Phani.