Skip to content

Commit

Permalink
Don't use symbolic variables for graph plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
rlmill committed Feb 21, 2009
1 parent 9e0e470 commit f9efd6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5863,6 +5863,12 @@ def plot(self, **options):
sage: g.add_edges([(0,0,'a'),(0,0,'b'),(0,1,'c'),(0,1,'d'),
... (0,1,'e'),(0,1,'f'),(0,1,'f'),(2,1,'g'),(2,2,'h')])
sage: g.plot(edge_labels=True, color_by_label=True, edge_style='dashed')
sage: S = SupersingularModule(389)
sage: H = S.hecke_matrix(2)
sage: D = DiGraph(H)
sage: P = D.plot()
"""
from sage.graphs.graph_plot import GraphPlot
return GraphPlot(graph=self, options=options).plot()
Expand Down
12 changes: 5 additions & 7 deletions src/sage/graphs/graph_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,30 +431,28 @@ def set_edges(self, **edge_options):
elif len(edges_to_draw[(a,b)]) > 1:
# Multi-edge
local_labels = edges_to_draw.pop((a,b))
x = SymbolicVariable('x')
d = SymbolicVariable('d')

# Compute perpendicular bisector
p1 = self._pos[a]
p2 = self._pos[b]
M = ((p1[0]+p2[0])/2, (p1[1]+p2[1])/2) # midpoint
if not p1[1] == p2[1]:
S = (p1[0]-p2[0])/(p2[1]-p1[1]) # perp slope
y = S*x-S*M[0]+M[1] # perp bisector line
y = lambda x : S*x-S*M[0]+M[1] # perp bisector line

# f,g are functions of distance d to determine x values
# on line y at d from point M
f = Sqrt(d**2/(1+S**2)) + M[0]
g = -Sqrt(d**2/(1+S**2)) + M[0]
f = lambda d : sqrt(d**2/(1+S**2)) + M[0]
g = lambda d : -sqrt(d**2/(1+S**2)) + M[0]

odd_x = f
even_x = g
if p1[0] == p2[0]:
odd_y = lambda d : M[1]
even_y = odd_y
else:
odd_y = y(f)
even_y = y(g)
odd_y = lambda x : y(f(x))
even_y = lambda x : y(g(x))
else:
odd_x = lambda d : M[0]
even_x = odd_x
Expand Down

0 comments on commit f9efd6e

Please sign in to comment.