Skip to main content
added 2 characters in body; edited tags
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

I am trying to visualize some basic multi-graphs. However, the visualization is not giving correct results. I am not sure if it is a bug or I am doing something wrong.

edgeList = {UndirectedEdge[1, 2], UndirectedEdge[1, 4], 
  UndirectedEdge[1, 6], UndirectedEdge[1, 8], UndirectedEdge[2, 4], 
  UndirectedEdge[2, 5], UndirectedEdge[2, 7], UndirectedEdge[3, 4], 
  UndirectedEdge[3, 6], 
     UndirectedEdge[3, 7], UndirectedEdge[4, 5], 
  UndirectedEdge[4, 7], UndirectedEdge[4, 8], UndirectedEdge[5, 7], 
  UndirectedEdge[6, 8], DirectedEdge[1, 2]}     

   
styles = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;
Graph[edgeList, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles[[i++]], Arrow@#} &)]

enter image description here

The following minimal code works slightly better, though it gives an arrowhead for an undirercted edge. I could bypass that by specifying Arrowheads[0.0]. Another small note, I am not able to save any graph correctly. It does not give the same result when I do "Save Graphics As..".

edgeList1 = {UndirectedEdge[1, 2], DirectedEdge[1, 2]}
styles1 = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;

Graph[edgeList1, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles1[[i++]], Arrow@#} &)]

System details:

  1. MathematicaMathematica 11.2
  2. Ubuntu 16.04

I am trying to visualize some basic multi-graphs. However, the visualization is not giving correct results. I am not sure if it is a bug or I am doing something wrong.

edgeList = {UndirectedEdge[1, 2], UndirectedEdge[1, 4], 
  UndirectedEdge[1, 6], UndirectedEdge[1, 8], UndirectedEdge[2, 4], 
  UndirectedEdge[2, 5], UndirectedEdge[2, 7], UndirectedEdge[3, 4], 
  UndirectedEdge[3, 6], 
     UndirectedEdge[3, 7], UndirectedEdge[4, 5], 
  UndirectedEdge[4, 7], UndirectedEdge[4, 8], UndirectedEdge[5, 7], 
  UndirectedEdge[6, 8], DirectedEdge[1, 2]}     

   
styles = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;
Graph[edgeList, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles[[i++]], Arrow@#} &)]

enter image description here

The following minimal code works slightly better, though it gives an arrowhead for an undirercted edge. I could bypass that by specifying Arrowheads[0.0]. Another small note, I am not able to save any graph correctly. It does not give the same result when I do "Save Graphics As..".

edgeList1 = {UndirectedEdge[1, 2], DirectedEdge[1, 2]}
styles1 = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;

Graph[edgeList1, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles1[[i++]], Arrow@#} &)]

System details:

  1. Mathematica 11.2
  2. Ubuntu 16.04

I am trying to visualize some basic multi-graphs. However, the visualization is not giving correct results. I am not sure if it is a bug or I am doing something wrong.

edgeList = {UndirectedEdge[1, 2], UndirectedEdge[1, 4], 
  UndirectedEdge[1, 6], UndirectedEdge[1, 8], UndirectedEdge[2, 4], 
  UndirectedEdge[2, 5], UndirectedEdge[2, 7], UndirectedEdge[3, 4], 
  UndirectedEdge[3, 6], 
     UndirectedEdge[3, 7], UndirectedEdge[4, 5], 
  UndirectedEdge[4, 7], UndirectedEdge[4, 8], UndirectedEdge[5, 7], 
  UndirectedEdge[6, 8], DirectedEdge[1, 2]}     

   
styles = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;
Graph[edgeList, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles[[i++]], Arrow@#} &)]

enter image description here

The following minimal code works slightly better, though it gives an arrowhead for an undirercted edge. I could bypass that by specifying Arrowheads[0.0]. Another small note, I am not able to save any graph correctly. It does not give the same result when I do "Save Graphics As..".

edgeList1 = {UndirectedEdge[1, 2], DirectedEdge[1, 2]}
styles1 = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;

Graph[edgeList1, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles1[[i++]], Arrow@#} &)]

System details:

  1. Mathematica 11.2
  2. Ubuntu 16.04
Source Link
Marvin
  • 604
  • 4
  • 11

Graph not displaying correctly

I am trying to visualize some basic multi-graphs. However, the visualization is not giving correct results. I am not sure if it is a bug or I am doing something wrong.

edgeList = {UndirectedEdge[1, 2], UndirectedEdge[1, 4], 
  UndirectedEdge[1, 6], UndirectedEdge[1, 8], UndirectedEdge[2, 4], 
  UndirectedEdge[2, 5], UndirectedEdge[2, 7], UndirectedEdge[3, 4], 
  UndirectedEdge[3, 6], 
     UndirectedEdge[3, 7], UndirectedEdge[4, 5], 
  UndirectedEdge[4, 7], UndirectedEdge[4, 8], UndirectedEdge[5, 7], 
  UndirectedEdge[6, 8], DirectedEdge[1, 2]}     

   
styles = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;
Graph[edgeList, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles[[i++]], Arrow@#} &)]

enter image description here

The following minimal code works slightly better, though it gives an arrowhead for an undirercted edge. I could bypass that by specifying Arrowheads[0.0]. Another small note, I am not able to save any graph correctly. It does not give the same result when I do "Save Graphics As..".

edgeList1 = {UndirectedEdge[1, 2], DirectedEdge[1, 2]}
styles1 = {Directive[Thickness[Large], RGBColor[0, 0, 1]], 
  Directive[Arrowheads[0.03`], Dashing[{Small, Small}], RGBColor[
   1, 0, 0]]}

i = 1;

Graph[edgeList1, VertexLabels -> Automatic, 
 EdgeShapeFunction -> ({styles1[[i++]], Arrow@#} &)]

System details:

  1. Mathematica 11.2
  2. Ubuntu 16.04