Skip to main content
added 40 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Update 3: Styling and labeling edges individually can now be more conveniently done using new-in-version-12.1 function EdgeTaggedGraph:

labels = {"A", "B", "C", "D", "E", "F"};
edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b};
styles = ColorData[97] /@ Range[6];

labelededges =  MapThread[Style[Labeled[#, #2], #3] &, {edges, labels, styles}] ;

EdgeTaggedGraph[labelededges, EdgeLabels -> "Name", 
 ImageSize -> Medium, EdgeLabelStyle -> 16]

enter image description here

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> 
  ({Text[labels[[i++]]Text[Last[labels = RotateLeft[labels]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@labels = Reverse @ {"A","B","C","D"};
i=1;i = 1;
Graph[{a ->b> b, a ->b> b, a ->b> b, a ->b> b},
 EdgeShapeFunction- > ({Text[labels[[i++]],Mean@#] Mean @ #],Arrow@#Arrow @ #}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 3: Styling and labeling edges individually can now be more conveniently done using new-in-version-12.1 function EdgeTaggedGraph:

labels = {"A", "B", "C", "D", "E", "F"};
edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b};
styles = ColorData[97] /@ Range[6];

labelededges =  MapThread[Style[Labeled[#, #2], #3] &, {edges, labels, styles}] ;

EdgeTaggedGraph[labelededges, EdgeLabels -> "Name", 
 ImageSize -> Medium, EdgeLabelStyle -> 16]

enter image description here

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 3: Styling and labeling edges individually can now be more conveniently done using new-in-version-12.1 function EdgeTaggedGraph:

labels = {"A", "B", "C", "D", "E", "F"};
edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b};
styles = ColorData[97] /@ Range[6];

labelededges =  MapThread[Style[Labeled[#, #2], #3] &, {edges, labels, styles}] ;

EdgeTaggedGraph[labelededges, EdgeLabels -> "Name", 
 ImageSize -> Medium, EdgeLabelStyle -> 16]

enter image description here

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};

Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> 
  ({Text[Last[labels = RotateLeft[labels]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels = Reverse @ {"A","B","C","D"};
i = 1;
Graph[{a -> b, a -> b, a -> b, a -> b},
 EdgeShapeFunction- > ({Text[labels[[i++]], Mean @ #],Arrow @ #}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)
added 649 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Update 3: Styling and labeling edges individually can now be more conveniently done using new-in-version-12.1 function EdgeTaggedGraph:

labels = {"A", "B", "C", "D", "E", "F"};
edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b};
styles = ColorData[97] /@ Range[6];

labelededges =  MapThread[Style[Labeled[#, #2], #3] &, {edges, labels, styles}] ;

EdgeTaggedGraph[labelededges, EdgeLabels -> "Name", 
 ImageSize -> Medium, EdgeLabelStyle -> 16]

enter image description here

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 3: Styling and labeling edges individually can now be more conveniently done using new-in-version-12.1 function EdgeTaggedGraph:

labels = {"A", "B", "C", "D", "E", "F"};
edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b};
styles = ColorData[97] /@ Range[6];

labelededges =  MapThread[Style[Labeled[#, #2], #3] &, {edges, labels, styles}] ;

EdgeTaggedGraph[labelededges, EdgeLabels -> "Name", 
 ImageSize -> Medium, EdgeLabelStyle -> 16]

enter image description here

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)
deleted 1 character in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinatesLineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinates from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)

Update 2: Dealing with the issue raised by @Kuba in the comments:

Using the function LineScaledCoordinate from the GraphUtilities package to place the text labels:

Needs["GraphUtilities`"]

labels ={"A", "B", "C", "D", "E", "F"};
i = 1; 
Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b},  
EdgeShapeFunction -> ({Text[labels[[i++]], LineScaledCoordinate[#, 0.5]], Arrow@#} &),
VertexLabels->"Name"] 

enter image description here

Update: Using EdgeShapeFunction:

labels=Reverse@{"A","B","C","D"};
i=1;
Graph[{a->b,a->b,a->b, a->b},
 EdgeShapeFunction->({Text[labels[[i++]],Mean@#],Arrow@#}&)]

enter image description here


Simplest method to convert a Graph g to Graphics is to use Show[g] (see this answer by @becko).

We can post-process Show[g] to modify the Text primitives:

Show[Graph[{Labeled[a->b,"A"],Labeled[a->b,"B"]}]]/. 
   Text["A",{x_,y_/; (y<0.)},z___]:>Text["B",{x,y},z]

enter image description here

Or, we can construct a Graph with modified edge directions (and correct labels) and post-process it to change the edge directions:

Show[Graph[{Labeled[a->b,"A"], Labeled[b->a,"B"]}]]/. 
  BezierCurve[{{-1.,0.},m__,y_}]:>BezierCurve[{{1.,0.},m,{-1.,0.}}]
(* same picture *)
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link
Loading
deleted 35 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 568 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 293 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 273 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading