1
$\begingroup$

I have the code you see below which displays the network that you see. However, I want to structure it so that it is flipped horizontally, and the 2, 3, 4, 5 quadrilateral is a square, and so that the 1, 2, 3 triangle is equilateral. How can I do this in Mathematica? Thanks.enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ Did you try any other layouts? GraphLayout -> "LayeredEmbedding" is pretty close and 2,3,4,5 is square but the 1,2,3 triangle is not quite equilateral. $\endgroup$
    – flinty
    Commented May 12, 2021 at 15:25

2 Answers 2

3
$\begingroup$
Clear["Global`*"]

Graph[{1 -> 2, 2 -> 3, 1 -> 3, 2 -> 4, 3 -> 5, 4 -> 5},
 VertexLabels -> Placed[Automatic, Center],
 VertexSize -> 0.1,
 VertexCoordinates -> {4 -> {0, 0}, 5 -> {1, 0}, 2 -> {0, 1},
   3 -> {1, 1}, 1 -> {1/2, 1 + Sqrt[3/4]}},
 ImageSize -> Small]

enter image description here

$\endgroup$
0
$\begingroup$

You can use GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {1, 2, 2}}

 g = Graph[{1 -> 2, 2 -> 3, 1 -> 3, 2 -> 4, 3 -> 5, 4 -> 5}, 
  PlotTheme -> "IndexLabeled",
  GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {1, 2, 2}}, 
  ImageSize -> Medium]

enter image description here

and post-process to change the orientation:

SetProperty[g, VertexCoordinates -> RotationTransform[-Pi/2]@GraphEmbedding[g]] 

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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