title: Detecting Cycles During Insertion
body: <p>I have a directed graph.  New edges are added and removed dynamically at run time.  If an edge that is about to be added to the graph creates a cycle, then that edge should not be added.  How would I do this with BGL?</p>
  
  <pre><code>typedef boost::adjacency_list&lt;
    boost::listS, boost::vecS,
    boost::directedS
    &gt; Graph;
  
  int main(int, char*[]){
  
    Graph G;
    add_edge(0, 1, G);
    add_edge(1, 2, G);
    add_edge(2, 3, G);
    add_edge(3, 0, G);  //creates cycle, should abort.
  
  }
  </code></pre>