Skip to main content
edited tags
Link
Tweeted twitter.com/#!/StackMma/status/390816083894358016
edited tags
Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263
added 247 characters in body; edited title
Source Link
István Zachar
  • 47.2k
  • 20
  • 147
  • 307

Curved Edges with EdgeShapeFunction using BezierCurve, in EdgeShapeFunction fails when used on multiedges graph

I would like to create a network graph with curvescurved edges. To do this, I wrote wthis funcytionthis function:

edgeFun[pts_, e_] := Module[{controlPts}, controlPts = pts /. {a_, b_} :> {a, {a[[1]] + .1 b[[1]], a[[2]]}, {a[[1]] + 0.1 b[[1]], b[[2]]}, b}; BezierCurve[controlPts]];

pts = {1 -> 2, 2 -> 3, 3 -> 1}

edgeFun[pts_, e_] := Module[{controlPts}, controlPts = pts /. {a_, b_} :> {a, {a[[1]] + .1 b[[1]], a[[2]]}, {a[[1]] + 0.1 b[[1]], b[[2]]}, b}; BezierCurve[controlPts] ]; 

With onley Undirected edgesno multiedges the edgeFun funcgtionedgeFun function works fine:

pts = {1 -> 2, 2 -> 3, 3 -> 1}; Graph[pts, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun] 

Graph[pts, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun].Mathematica graphics

But when I want to create a network with DirectedEdges like

pts1 = {1multiple edges -> 2, 2(note -> 3, 31 -> 2 and -> 12 -> 1, 2 -> 1}

Then Mathemativca givesMathematica complains and the messagesgraph is pinked out:

Part::partd: "Part specification 0.496922[[1]] is longer than depth of object"

pts1 = {1 -> 2, 2 -> 3, 3 -> 1, 2 -> 1}; Graph[pts1, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun] 
Part::partd: "Part specification 0.496922[[1]] is longer than depth of object" 

Does anyone knowsknow how to solve this problem.?

Curved Edges with EdgeShapeFunction using BezierCurve,

I would like to create a network graph with curves edges. To do this, I wrote wthis funcytion:

edgeFun[pts_, e_] := Module[{controlPts}, controlPts = pts /. {a_, b_} :> {a, {a[[1]] + .1 b[[1]], a[[2]]}, {a[[1]] + 0.1 b[[1]], b[[2]]}, b}; BezierCurve[controlPts]];

pts = {1 -> 2, 2 -> 3, 3 -> 1}

With onley Undirected edges the edgeFun funcgtion works fine

Graph[pts, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun].

But when I want to create a network with DirectedEdges like

pts1 = {1 -> 2, 2 -> 3, 3 -> 1, 2 -> 1}

Then Mathemativca gives the messages:

Part::partd: "Part specification 0.496922[[1]] is longer than depth of object"

Does anyone knows how to solve this problem.

BezierCurve in EdgeShapeFunction fails when used on multiedges graph

I would like to create a network graph with curved edges. To do this, I wrote this function:

edgeFun[pts_, e_] := Module[{controlPts}, controlPts = pts /. {a_, b_} :> {a, {a[[1]] + .1 b[[1]], a[[2]]}, {a[[1]] + 0.1 b[[1]], b[[2]]}, b}; BezierCurve[controlPts] ]; 

With no multiedges the edgeFun function works fine:

pts = {1 -> 2, 2 -> 3, 3 -> 1}; Graph[pts, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun] 

Mathematica graphics

But when I want to create a network with multiple edges (note 1 -> 2 and 2 -> 1, Mathematica complains and the graph is pinked out:

pts1 = {1 -> 2, 2 -> 3, 3 -> 1, 2 -> 1}; Graph[pts1, VertexLabels -> Placed["Name", Center], EdgeShapeFunction -> edgeFun] 
Part::partd: "Part specification 0.496922[[1]] is longer than depth of object" 

Does anyone know how to solve this problem?

Source Link
Loading