1
$\begingroup$

I used "LayeredGraphPlot" in the simulation of a schema. I would like to remove the two green arrows while keeping their edges, and the other arrows of the graph. How should I proceed to control only these two arrows? Here's my code

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


```
$\endgroup$
1
  • 1
    $\begingroup$ add the directive Arrowheads[0] in Style[...] for the edges you want rendered as line. E.g., Style[Labeled["E" -> "S", Subscript[\[Beta], e]], Dashed, Green,Arrowheads[0], Thick] $\endgroup$
    – kglr
    May 26, 2021 at 21:01

2 Answers 2

3
$\begingroup$

You may replace the "->" with [UndirectedEdge] specifically on those two green edges, that makes the edges undirected.

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

I hope it helps.

$\endgroup$
1
  • $\begingroup$ Dear Charmbracelet, thank you so much! Yes, it helped me a lot! :) $\endgroup$ May 26, 2021 at 14:59
2
$\begingroup$

Add the directive Arrowheads[0] in Style[...] for the edges you wish to render as lines:

colors = {"S" -> White, "I" -> Yellow, "R" | "D" -> Red}; 

LayeredGraphPlot[{Style[Labeled["S" -> "E", F], Red, Thick], 
  Style[Labeled["E" -> "S", Subscript[β, e]], Dashed, Green, 
   Thick, Arrowheads[0]], 
  Style[Labeled["I" -> "S", Subscript[β, i]], Dashed, Green, 
   Thick, Arrowheads[0]], 
  Style[Labeled["E" -> "I", Subscript[e, i]], Brown, Thick], 
  Style[Labeled["I" -> "H", Subscript[i, h]], Brown, Thick], 
  Style[Labeled["I" -> "R", Subscript[i, r]], Dashed, Purple, Thick], 
  Style[Labeled["H" -> "R", Subscript[h, r]], Dashed, Purple, Thick], 
  Style[Labeled["E" -> "R", Subscript[e, r]], Dashed, Purple, Thick], 
  Style[Labeled["H" -> "D", Subscript[h, d]], Dashed, Purple, 
   Thick]}, 
 Left, 
 PlotStyle -> Bold, 
 VertexLabels -> Placed[Automatic, Center], 
 PerformanceGoal -> "Quality", 
 VertexShapeFunction -> 
   {"S" -> "Square", "R" -> "ConcaveHexagon", "D" -> "ConcaveHexagon"}, 
 VertexStyle -> colors, 
 VertexSize -> Large, 
 EdgeLabelStyle -> Directive[10, Background -> White]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Perfect! Thank you kglr. :) $\endgroup$ Dec 25, 2023 at 16:26

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.