4
$\begingroup$

I would like to obtain entrance edge and output edges as in the following figure enter image description here

My code is the following:

vertices = vertices = {"S", "E", "I", "R"};
groups = {{"S"}, {"E", "I"}, {"R"}};
colors = Flatten@
   MapThread[Thread@*Rule, {groups, {White, Yellow, Red}}];



chart = LayeredGraphPlot[{Style[Labeled["S" -> "E", F], Red, Thick], 
   Style[Labeled["E" \[UndirectedEdge] "S", \[Beta]], Dashed, Green, 
    Thick], Style[Labeled["E" -> "I", Subscript[\[Gamma], e]], Brown, 
    Thick], Style[Labeled["I" -> "R", Subscript[\[Gamma], i] ], 
    Dashed, Purple, Thick], 
   Style[Labeled["R" -> "S", Subscript[\[Gamma], r] ], Dashed, Cyan, 
    Thick], Style[Labeled["S" -> "R", Subscript[\[Gamma], s] ], 
    Dashed, Purple, Thick]}, Left, 
  PlotStyle -> {"TemperatureMap", Bold},
  VertexLabels -> Placed[Automatic, Center], 
  PerformanceGoal -> "Quality",
  {VertexShapeFunction -> {"S" -> "Square", 
     "R" -> "ConcaveHexagon"}}, VertexStyle -> colors, 
  VertexShapeFunction -> ({EdgeForm[Black], Disk[#1, 0.2], 
      Text[#2, #1]} &), VertexSize -> Large, 
  EdgeLabelStyle -> Directive[10, Background -> White]]

$\endgroup$

1 Answer 1

3
$\begingroup$
 edges = {Style[Labeled["S" -> "E", F], Red, Thick], 
   Style[Labeled["E" \[UndirectedEdge] "S", β], Dashed, Green, Thick], 
   Style[Labeled["E" -> "I", Subscript[γ, e]], Brown,Thick], 
   Style[Labeled["I" -> "R", Subscript[γ, i]], Dashed, Purple, Thick], 
   Style[Labeled["R" -> "S", Subscript[γ, r]], Dashed, Cyan, Thick], 
   Style[Labeled["S" -> "R", Subscript[γ, s]], Dashed, Purple, Thick]};

You can add new edges and use None as VertexShapeFunction to make some vertices invisible:

invisiblevertices = {"Eb", "Ib", "Rb", "Sb"};

newedges = {"Sb" -> "S", "R" -> "Rb", "I" -> "Ib", "E" -> "Eb"};

newedgelabels = {μ, μR, μI, μE};

edges2 = Join[edges, MapThread[Labeled, {newedges, newedgelabels}]];

options = { VertexLabels -> {_ -> Placed[Automatic, Center], 
       Alternatives @@ invisiblevertices -> None}, 
    VertexShapeFunction -> {"S" -> "Square", "R" -> "ConcaveHexagon", 
       Alternatives @@ invisiblevertices -> None},
    VertexStyle -> colors, VertexSize -> Large, ImageSize -> 700,
    PerformanceGoal -> "Quality", 
    EdgeLabelStyle -> Directive[10, Background -> White]};
 
LayeredGraphPlot[edges2, Left, options]

enter image description here

LayeredGraphPlot[edges2, Left, options , 
  EdgeShapeFunction -> {("E" -> "Eb") -> (Arrow[{#[[1]], #[[1]] + {0, -1}}] &), 
     ("I" -> "Ib") -> (Arrow[{#[[1]], #[[1]] + {0, -1}}] &)}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot!! :) This is what I really wanted! $\endgroup$ Jun 7, 2021 at 8:37

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.