Skip to main content
Commonmark migration
Source Link

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

###Update

Update

The above doesn't adjust the size of the arrow heads according to the multiplicity. If you think that should happen, then a another function is needed.

arrow[multipliciy_] := GraphElementData[{"FilledArrow", "ArrowSize" -> .018 + .01 multipliciy}] gr[adjMatrix_] := Module[{m, edges, style, arrows, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList@AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; arrows = Rule[#, arrow[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, EdgeShapeFunction -> arrows, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph-2

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

###Update

The above doesn't adjust the size of the arrow heads according to the multiplicity. If you think that should happen, then a another function is needed.

arrow[multipliciy_] := GraphElementData[{"FilledArrow", "ArrowSize" -> .018 + .01 multipliciy}] gr[adjMatrix_] := Module[{m, edges, style, arrows, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList@AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; arrows = Rule[#, arrow[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, EdgeShapeFunction -> arrows, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph-2

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

Update

The above doesn't adjust the size of the arrow heads according to the multiplicity. If you think that should happen, then a another function is needed.

arrow[multipliciy_] := GraphElementData[{"FilledArrow", "ArrowSize" -> .018 + .01 multipliciy}] gr[adjMatrix_] := Module[{m, edges, style, arrows, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList@AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; arrows = Rule[#, arrow[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, EdgeShapeFunction -> arrows, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph-2

Another example
Source Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

###Update

The above doesn't adjust the size of the arrow heads according to the multiplicity. If you think that should happen, then a another function is needed.

arrow[multipliciy_] := GraphElementData[{"FilledArrow", "ArrowSize" -> .018 + .01 multipliciy}] gr[adjMatrix_] := Module[{m, edges, style, arrows, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList@AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; arrows = Rule[#, arrow[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, EdgeShapeFunction -> arrows, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph-2

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

###Update

The above doesn't adjust the size of the arrow heads according to the multiplicity. If you think that should happen, then a another function is needed.

arrow[multipliciy_] := GraphElementData[{"FilledArrow", "ArrowSize" -> .018 + .01 multipliciy}] gr[adjMatrix_] := Module[{m, edges, style, arrows, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList@AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; arrows = Rule[#, arrow[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style, EdgeLabels -> lbls, EdgeShapeFunction -> arrows, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph-2

added 380 characters in body
Source Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263

GivenTaking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy]   

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, gedges, style, lbls},   m = Map[Boole[# > 0] &, adjMatrix, {2}];   gedges = EdgeList @ AdjacencyGraph[m];   style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ EdgeList[g];edges;   lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ EdgeList[g]; edges;   AdjacencyGraph[m,    EdgeStyle -> style,  EdgeLabels -> lbls,  VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

Given your edit, I propose the following

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy]   gr[adjMatrix_] := Module[{m, g, style, lbls},   m = Map[Boole[# > 0] &, adjMatrix, {2}];   g = AdjacencyGraph[m];   style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ EdgeList[g];   lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ EdgeList[g];   AdjacencyGraph[m,    EdgeStyle -> style, EdgeLabels -> lbls, VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

Taking into account the new information from your edit, I propose the following:

Function to produce the edge labels according to multiplicity indicated in the adjacency matrix.

 edgeLbl[multipliciy_] := Style[StringJoin @ ConstantArray["+", multipliciy], Background -> White] 

Function to style the edges according to multiplicity.

 edgeStyle[multipliciy_] := AbsoluteThickness[multipliciy] 

My reason for defining these functions is to make it easy to modify the look of graph edges without having to modify the main graph making function, which is:

gr[adjMatrix_] := Module[{m, edges, style, lbls}, m = Map[Boole[# > 0] &, adjMatrix, {2}]; edges = EdgeList @ AdjacencyGraph[m]; style = Rule[#, edgeStyle[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; lbls = Rule[#, edgeLbl[adjMatrix[[#[[1]], #[[2]]]]]] & /@ edges; AdjacencyGraph[m, EdgeStyle -> style,  EdgeLabels -> lbls,  VertexLabels -> "Name"]] gr[{{0, 1, 0}, {0, 0, 2}, {3, 0, 0}}] 

graph

Source Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263
Loading