Recently in chat there was a link to MetaPost. I thought I would try it out, here is an example of some figures that I created with just a few minutes of tinkering to get an idea of how to use the program.
--
The Pest spec has been introduced as a replacement to tradional IRC, you can check it out over at Loper-OS.org. One of the factors that impelled its development was the way that the traditional IRC protocol limits server arrangements to a "binary spanning tree", meaning you can link servers in chains, but the server chains cannot form cycles. For example, servers A, B, C, and D can be linked thus:
The problem that happens is whenever servers A and B lose their connection there is a "netsplit", where A and C can talk, and B and D can talk, but the two sides cannot talk together. Pest uses duplicate message elimination to allow the formation of cyclic networks, like the one shown below:
This way, if A and B lose their connection there is still communication between all members of the network.
--
This is the code I used to generate the figures above using MetaPost. I make no claim that this is the best way to do this, it is just an example of what the code for this looks like.
outputtemplate := "%j-%c.svg";
outputformat := "svg";
beginfig (1);
numeric u;
u := 1cm;
% Put in some labels
label ("A", (0, 2u)) ;
label ("B", (4u,2u)) ;
label ("C", (0, 0 )) ;
label ("D", (4u,0 )) ;
% Connecting lines to show the network
draw (0, .5u) -- (0, 1.5u) ;
draw (.5u,2u) -- (3.5u,2u) ;
draw (4u,.5u) -- (4u,1.5u) ;
% Edges of labels are getting cut off, this is an ugly hack to
% expand the picture a tad
draw (-.5u,2.5u) -- (4.5u,2.5u) withcolor white;
endfig;
beginfig (2);
numeric u;
u := 1cm;
label ("A", (0, 2u)) ;
label ("B", (4u,2u)) ;
label ("C", (0, 0 )) ;
label ("D", (4u,0 )) ;
draw (0, .5u) -- (0, 1.5u) ;
draw (.5u,2u) -- (3.5u,2u ) ;
draw (4u,.5u) -- (4u, 1.5u) ;
draw (.5u,0 ) -- (3.5u,0 ) ;
draw (.5u,.25u) -- (3.5u,1.75u) ;
fill fullcircle scaled (2/5u) shifted (2u,1u) withcolor white ;
draw (.5u,1.75u) -- (3.5u,.25u) ;
draw (-.5u,2.5u) -- (4.5u,2.5u) withcolor white;
endfig;
end.
--
Edit:
Question was asked, can the graph be made with arrows instead?
Answer: Quite easily. Just replace the edges, instead of draw
, use drawdblarrow
.
Updated figures: