13
$\begingroup$

Over on StackOverflow I asked a similar question for the n=3 case, but the answer given doesn't easily generalize.

How can I make a diagram such as this:

Finite Topological Spaces

But for a general n-element space instead?

$\endgroup$
  • $\begingroup$ It is unclear how such diagrams would work for n>=4: you face a problem similar to that of drawing Venn diagrams. What solution do you have in mind to make clear diagrams? (One idea would be to limit the marked subsets to a basis for the topology rather than attempting to show every open set in it.) $\endgroup$ – whuber Jan 17 '12 at 22:38
  • 2
    $\begingroup$ Using just the basis is a good solution. It also occurred to me that this is a special case of visualizing HyperGraphs. $\endgroup$ – tlehman Jan 17 '12 at 22:52
10
$\begingroup$

I suspect this is a fundamentally difficult problem, because as you pointed out, it boils down to drawing hypergraphs which, it seems, Mathematica does not have built in support for.

It isn't hard though, to automatically generate some kind of visualization of topologies.

I used the elegant topologyQ function proposed by kguler over at the stackoverflow question you linked to:

topologyQ[x_List] := Intersection[x, #] === # &[
Union[{Union @@ x}, Intersection @@@ Rest@#, Union @@@ #] &@
Subsets@x]

And then a little bit of (substantially less elegant) code I wrote myself:

RandomTopoTable[n_] := 
Module[{Sets = 
 Reverse[Sort[
  RandomSample[#, RandomChoice[Range[Length[#]]]] &[
   Subsets[Range[n]]]]], 
GenerateRow = 
 Function[{set}, {#, Background -> If[MemberQ[set, #], Red, White],
     Frame -> True} & /@ Range[n]]}, 
{If[topologyQ[Sets] && MemberQ[Sets, Range[n]],
  Style["GOOD", Darker[Green]], Style["BAD", Red]], 
  Grid[({Range[n]}~Join~((Item @@@ # &) /@ (GenerateRow /@ Sets))), 
  Frame -> All, Background -> {Lighter[Gray], None}]}];

Table[Column[RandomTopoTable[3]], {20}]

And this is the output for n=3, but it works for other choices of n too:

output of my code

This is presenting a random sample of the subsets of the subsets of original set, e.g. a random selection of "potential topologies".

$\endgroup$
  • $\begingroup$ I like this, the visualization is reminiscent of a cellular automata. $\endgroup$ – tlehman Jan 18 '12 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.