3
$\begingroup$

I want to construct signal flow graphs using Mathematica. Below is a simple example. It works well enough except that it draws from right to left. In fact it seems to choose left to right or right to left in some mysterious way. I have been through all the Graph options and can't find one that will control this behavior.

What I really want is a linear left to right layout of the nodes, with any back-directed edges drawn above or below the linear layout

Any ideas?

Graph[{1 \[DirectedEdge] 2, 2 \[DirectedEdge] 3, 3 \[DirectedEdge] 4, 
  3 \[DirectedEdge] 2}, 
 VertexLabels -> {1 -> "In", 2 -> "y1''", 3 -> "y1'", 4 -> "y1"},
 EdgeLabels -> {2 \[DirectedEdge] 3 -> "1/s", 
   3 \[DirectedEdge] 4 -> "1/s", 3 \[DirectedEdge] 2 -> "-b/m"}]

Produces

enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$
$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global`*"]

Specify some of the VertexCoordinates

Graph[{1 \[DirectedEdge] 2, 2 \[DirectedEdge] 3, 3 \[DirectedEdge] 4, 
  3 \[DirectedEdge] 2},
 VertexLabels -> {1 -> "In", 2 -> "y1''", 3 -> "y1'", 4 -> "y1"},
 EdgeLabels -> {2 \[DirectedEdge] 3 -> "1/s", 3 \[DirectedEdge] 4 -> "1/s", 
   3 \[DirectedEdge] 2 -> "-b/m"},
 VertexCoordinates -> {1 -> {0, 0}, 4 -> {2, 0}}]

enter image description here

$\endgroup$
0

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.