# Set EdgeStyles on a Directed Graph?

Posted 5 years ago
5086 Views
|
2 Replies
|
0 Total Likes
|
 Hello, I wonder if anyone can help me understand how to use EdgeStyles on a directed graph.On an un-directed graph I can do the following: Graph[{1<->2,3 <-> 2,1<->3}, EdgeStyle -> {1<->2-> Directive[Thickness[0.01],Blue], 3 <-> 2 -> Directive[Thickness[0.005],Red], 1<-> 3 -> Directive[Thickness[0.02],Green]}] But on a directed graph the following does not work: Graph[{1->2,3 -> 2,1->3}, EdgeStyle -> {1->2-> Directive[Thickness[0.01],Blue], 3 -> 2 -> Directive[Thickness[0.005],Red], 1-> 3 -> Directive[Thickness[0.02],Green]}] Can someone help me understand what I am missing here?Thank you, Grey
2 Replies
Sort By:
Posted 5 years ago
 To add to this question, I would like to ultimately have a directed graph with variable edge colors and edge widths to represent the varying strengths of (directed) interactions between nodes in a network. I would also like to be able to control the coordinates where each vertex is plotted.So far I have figured out that GraphPlot, allows specification of coordinates for vertices: GraphPlot[{1->2,2->3,3->1},VertexCoordinateRules->{1->{0,0},2->{1,1},3->{0,2}}]And Graph apparently allows full controls of the edge widths: Graph[{1<->2,3 <-> 2,1<->3}, EdgeStyle -> {1<->2-> Directive[Thickness[0.01],Blue], 3 <-> 2 -> Directive[Thickness[0.005],Red], 1<-> 3 -> Directive[Thickness[0.02],Green]}]But, the EdgeStyle Directives cannot be set for directed edges (as in the original question). Further, VertexCoordinateRules fors not work for Graph and EdgeStyle does not work for GraphPlot.Is there a way to get everything that I want (control over vertex coordinates, and also control over individual edge widths)?
 Just use parentheses: Graph[{1 -> 2, 3 -> 2, 1 -> 3}, EdgeStyle -> {(1 -> 2) -> Directive[Thickness[0.01], RGBColor[0, 0, 1]], (3 -> 2) -> Directive[Thickness[0.005], RGBColor[1, 0, 0]], (1 -> 3) -> Directive[Thickness[0.02], RGBColor[0, 1, 0]]}] `