Message Boards Message Boards

0
|
472 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to use option StraightLine in an EdgeTaggedGraph

Posted 2 months ago

I'm having trouble with "EdgeLayout" -> "StraightLine" in the GraphLayout of EdgeTaggedGraph.

Here's an example without the StraightLine option:

Remove[vsf];
vsf[width_][pos_, label_, _] := 
  Inset[Framed[Pane[label, UpTo[width]], Background -> White], pos];
EdgeTaggedGraph[
 Flatten[Table[{
    Annotation[
     Column[{"Vertex", v}] \[DirectedEdge] 
      Column[{"Vertex", Mod[v + 1, 4]}], 
     EdgeLabels -> Placed[(v + 0.1), {1/3, {0.5, 0.5}}]],
    Annotation[
     Column[{"Vertex", Mod[v + 1, 4]}] \[DirectedEdge] 
      Column[{"Vertex", v}], 
     EdgeLabels -> Placed[(v + 0.2), {1/2, {0.5, 0.5}}]],
    Annotation[
     Column[{"Vertex", v}] \[DirectedEdge] 
      Column[{"Vertex", Mod[v + 1, 4]}], 
     EdgeLabels -> Placed[(v + 0.3), {2/3, {0.5, 0.5}}]]},
   {v, 0, 3}], 1],
 BaseStyle -> {Arrowheads[0.04], Black},
 PerformanceGoal -> "Quality",
 VertexShapeFunction -> vsf[32],
 AspectRatio -> 1,
 GraphLayout -> {"VertexLayout" -> "LayeredEmbedding"},
 ImageSize -> {3*72, Automatic}
 ]

example1

Changing GraphLayout to

GraphLayout -> {"VertexLayout" -> "LayeredEmbedding", 
  "EdgeLayout" -> "StraightLine"}

Produces this result:

example2

Is there a remedy for this?

POSTED BY: Richard Frost
2 Replies

Thank you Rohit.

I see that if arrowheads are not needed, then

EdgeShapeFunction -> {Line[#1] &}

is very good. It also appears that

GraphLayout -> {"EdgeLayout" -> "StraightLine"}

was quickly implemented with

EdgeShapeFunction -> {Line[{First[#1], Last[#1]}] &}

instead of the arduous task of accounting for separate edges.

So I also decided to punt on the whole matter, and instead use VertexCoordinates to adjust the placement of my 14 vertices among the 47 bezier edges.

POSTED BY: Richard Frost
Posted 2 months ago

Hi Richard,

This is a little better, but the arrowheads are missing. It must be possible based on the examples in the documentation for EdgeShapeFunction. I did not try.

esf[points_, edge_] := {Line[points]}

EdgeShapeFunction -> esf
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract