Message Boards Message Boards

1
|
3882 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Constructing cyclic graphs that are as pair-wise disjoint as possible

Posted 3 years ago

I cross-posted this on Mathematica Stack Exchange but haven't received any traction there. Perhaps someone on this forum has an idea. I've re-written the description somewhat in hopes this is more clear.

I have an application for which I need a set of circle graphs, where by circle, I mean that the graph forms a single complete loop. So with n vertices, it starts at one vertex, goes to another and finally loops back on itself. An example small circle graph:

aGraph=Graph[DirectedEdge @@ # & /@ 
  Partition[RandomSample[Range[10]], 2, 1, {1, 1}]]

For a set of such graphs (really edge lists), I want to find out their pairwise intersection. I don't know if it is the right way, but I use this:

GraphEdgeIntersections[edgePairs_List] := 
  With[{intersection = Intersection @@ edgePairs},
   If[intersection == {}, 0, 
    Max@Flatten[GraphDistanceMatrix[intersection] /. Infinity -> 0]]
   ];

I know how to construct a set of "perfect" circles where the pairwise intersections yield the null set for the case I really care about, circles with 23 vertices:

anExampleSet = 
  Table[DirectedEdge @@ # & /@ 
    Transpose[{Range[23], RotateRight[Range[23], i]}], {i, 1, 22}];
Partition[GraphEdgeIntersections[#] & /@ Tuples[anExampleSet, 2], 
  22] // MatrixForm

You see that the diagonals have a path length of 22 and all other entries are 0 (indicating that they are completely orthogonal). When I look at the number of edges in the flattened set, it is 506, which is exactly the same as the total possible edges in a set of 23.

Length[Select[Tuples[Range[23], 2], #[[1]] != #[[2]] &]]

Is there a method to construct the best set of circles so that I minimize the intersections when going beyond the 22 (or any similar set of 22) shown above?

As part of this work, I came up with a way to visualize the "goodness" of the resulting set using "Image". For this, I construct the graph edge intersection matrix and "color" it according to whether I'm looking for "goodness" or "badness". The idea is to take the matrix and change the values into {R,G,B} pixels at each point according to the rules I want. Since I don't know how many entries are in the resulting set, I wrote a function to generate the replacement rules. I should probably have called the last parameter "badNotGoodP" but this is what I first wrote:

ConstructReplacementRule::usage = 
  "ConstructReplacementRule[values_,blackValue_,threshold_,\
redNotGreen_]";
ConstructReplacementRule[values_, blackValue_, threshold_, 
   redNotGreen_] := 
  Block[{white = {1, 1, 1}, black = {0, 0, 0}, red = {1, 0, 0}, 
    green = {0, 1, 0}, replacementValues, valuesNoDuplicates},
   valuesNoDuplicates = DeleteDuplicates[Flatten@values];
   replacementValues = 
    Cases[valuesNoDuplicates, 
     a_ :> 
      If[a == blackValue, black, 
       If[redNotGreen, If[a > threshold, red, white], 
        If[a < threshold, green, white]]]];
   Thread[valuesNoDuplicates -> replacementValues]
   ];

This is used for example in the following way:

someRandomGraphs = 
  With[{randomSample = #}, 
     DirectedEdge @@ # & /@ 
      Partition[Append[randomSample, randomSample[[1]]], 2, 1]] & /@ 
   Table[RandomSample[Range[23]], {i, 1, 256}];
gei = Partition[
   GraphEdgeIntersections[#] & /@ Tuples[someRandomGraphs, 2], 256];

Now, if I want to show an image with green pixels for any point in the cross-matrix where we have 0 or 1 intersection, I do this:

Image[gei /. ConstructReplacementRule[gei, 22, 2, False]]

Or if I want to know cases where there are only 0 overlaps, I use this:

Image[gei /. 
  ConstructReplacementRule[DeleteDuplicates@Flatten@gei, 22, 1, 
   False]]

If I want to show "badness", I invert the last argument to the rule replacement.

Image[gei /. 
  ConstructReplacementRule[DeleteDuplicates@Flatten@gei, 22, 1, True]]

I have some generators for producing circle graphs that yield decent results but they aren't perfect. I'm hoping someone with a good background in graphs knows a construction method that yields a better result. One of my methods gives this result for a set of 256 tables:

Results for a set of circles

Repeating, the objective is to get as many "0" and "1" overlaps as possible. For this table, there are 65536 entries and of those, 256 are the diagonal where the overlap is complete, yielding the count of 22. The unweighted percentage "badness" for the set I'm providing is (3248+222+16+2)/65280 = 5.34%. Another construction method gives 5.37% "badness". Are there any with 0% badness?

I cannot "brute force" this since the total possible sets is huge (23!).

If you've read this far, I appreciate your time and any help you may give.

POSTED BY: Mark Ross

I think if you would add some actual outputs (maybe few samples) and images it would be more comprehensive and readable. It is hard to understand what is going on, and not everyone has Mathematica at hand to copy paste code. I read this on iPad for example.

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract