There is a network of up to 26 nodes (named
z as per your wish). Every pair of nodes may be connected or disconnected. A node may be connected to at most 4 other nodes. Your task is to draw the network in a 2D diagram. Input will be given such that this task is possible (see more constraints in output section).
- Pairs of letters (
zas per your wish). They are not sorted in any order.
- Optional – number of pairs
- An ASCII drawing that shows the actual links between the nodes. Nodes are given by
-for horizontal links and
|for vertical links. Links may be of any (non-zero) length but they should be straight horizontal/vertical lines that do not bend. Spaces can be added provided they don’t disfigure the picture.
You may not use built-ins that help in layout of the graph. Other graph-related built-ins may be allowed (though solutions without built-ins would be more appreciated). Shortest code wins.
A B B F B L F K L K K R K S R P S J S P J A T V V N
A - B - F T - V | | | | | L - K - R N | | | J ----- S - P
H C G H A B B F B C F G C D D A
A - B ----- F | | | D - C - H - G