Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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.) – whuber Jan 17 '12 at 22:38
Using just the basis is a good solution. It also occurred to me that this is a special case of visualizing HyperGraphs. – tlehman Jan 17 '12 at 22:52
up vote 10 down vote accepted

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 @@@ #] &@

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

RandomTopoTable[n_] := 
Module[{Sets = 
  RandomSample[#, RandomChoice[Range[Length[#]]]] &[
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".

share|improve this answer
I like this, the visualization is reminiscent of a cellular automata. – tlehman Jan 18 '12 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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