Example #1
0
void const_graph_visitort::graph_explore(event_grapht& egraph, unsigned next,
  unsigned end, std::list<unsigned>& old_path, std::set<unsigned>& edges)
{
  if(next == end) {
    /* inserts all the pos collected from old_path in edges */
    std::list<unsigned>::const_iterator it=old_path.begin();
    std::list<unsigned>::const_iterator next_it=it;
    ++next_it;
    for(;next_it!=old_path.end() && it!=old_path.end(); ++it, ++next_it)
    {
      /* it should be a po_s, and not a po_s^+ */
      assert(egraph.has_po_edge(*it,*next_it));
      edges.insert(fence_inserter.add_edge(edget(*it,*next_it)));
    }
  }
  else if(egraph.po_out(next).size()==0) {
    /* this path is not connecting a to b => return */
  }
  else {
    for(graph<abstract_eventt>::edgest::const_iterator
      next_it=egraph.po_out(next).begin();
      next_it!=egraph.po_out(next).end();
      ++next_it)
    {
      if(visited_nodes.find(next_it->first)!=visited_nodes.end())
        continue;
      visited_nodes.insert(next_it->first);

      old_path.push_back/*front*/(next_it->first);
      graph_explore(egraph, next_it->first, end, old_path, edges);
      old_path.pop_back/*front*/();
    }
  }
}
Example #2
0
void const_graph_visitort::PT(
  const edget &e,
  std::set<unsigned> &edges)
{
  visited_nodes.clear();

//  if(!e.is_po) /* e is in po^+\po */ is_po is a flag set manually, do not
//  use it for checks!!
  const wmm_grapht::edgest &list_po_out=
    fence_inserter.instrumenter.egraph.po_out(e.first);
  if(list_po_out.find(e.second)==list_po_out.end())
  {
#ifdef BTWN1
    event_grapht &egraph=fence_inserter.instrumenter.egraph;

    /// all the pos in between
    for(wmm_grapht::edgest::const_iterator
      next_it=egraph.po_out(e.first).begin();
      next_it!=egraph.po_out(e.first).end();
      ++next_it)
    {
      std::list<event_idt> new_path;
      new_path.push_back(e.first);
      new_path.push_back(next_it->first);
      graph_explore(egraph, next_it->first, e.second, new_path, edges);
    }
#elif defined BTWN4
    /* all the pos+ intersections inbetween */
    /* TODO */
    /* when detecting intersections, add them to a map thread->edges
       then for BTWN4, enumerates all the edges of the thread of e and
       check whether e.first-po-> edge.first /\ edge.second-po->e.second,
       using egraph.are_po_ordered. */
#else
    throw "BTWN definition not selected!"; // NOLINT(readability/throw)
#endif
  }
  else
    /* reflexive -- only when in pos */
    edges.insert(fence_inserter.map_from_e[e]);
}