user2843179
user2843179

Reputation: 1

An unusual graph definition for merge operations?

I have a graph G which has single-key and double-key nodes. Single-key nodes are labeled with chars:

a, b, ..., z

double-key nodes are given:

(ab), (ac), ..., (az),        

(bc), (bd), ..., (bz),            

...

(xy), (xz), 

(yz)

double-key nodes are organized such that (key1 < key2).

In total, 26 single-key nodes + 25x26/2 double-key nodes. Our goal is to write a merge function (which starts a chain reaction)

If x = y merge these nodes on the graph.

I defined a multi-index for searching y in all columns so I can update with x.

struct Edge {  //A directed edge     ab --> cd 
  char  a;  // if a is 0 then Edge defines    b --> cd 
  char  b;
  char  c;
  char  d;
  struct Ea{}; struct Eb {}; struct Ec {}; struct Ed {}; struct Eabcd {};

  Edge(
    const char a_, const char b_, char c_, const char d_):
    a(a_),b(b_),c(c_),d(d_)
  {}
};

typedef boost::multi_index_container<Edge,
indexed_by<
    ordered_non_unique< tag<Edge::Ea>, member<Edge,short,&Edge::a> >,
    ordered_non_unique< tag<Edge::Eb>, member<Edge,short,&Edge::b> >,
    ordered_non_unique< tag<Edge::Ec>, member<Edge,short,&Edge::c> >,
    ordered_non_unique< tag<Edge::Ed>, member<Edge,short,&Edge::d> >,
//ordered_unique<tag<Edge::Eabcd>, member<&Edge::a, &Edge::b, &Edge::c>> // key 1 then key 2 then key 3
    ordered_unique<tag<Edge::Eabcd>,
        composite_key< Edge ,
            member<Edge, short, &Edge::a>,
            member<Edge, short, &Edge::b>,
            member<Edge, short, &Edge::c>,
            member<Edge, short, &Edge::d>> >>
> Edge_Container;

Unfortunately, I could not merge all other double-key nodes that has x's and y's?

Merge (mx, mz) forall m != x,y


Another unusual merge operation is here:
if x = yz then

  y = xz

  z =  xy

How can I define such a graph?

Upvotes: -2

Views: 55

Answers (0)

Related Questions