Only dash some edges in a graph?

68 views
Skip to first unread message

Ursula Whitcher

unread,
May 27, 2014, 6:29:31 PM5/27/14
to sage-s...@googlegroups.com
Is it possible to display a directed graph in Sage so that only some of the edges are dashed?  I found the edge_style option, but that seems to apply to all of the edges simultaneously.

UAW

kcrisman

unread,
May 27, 2014, 8:16:58 PM5/27/14
to sage-s...@googlegroups.com
I don't know but that is a great question!

P Purkayastha

unread,
May 31, 2014, 2:47:54 AM5/31/14
to sage-s...@googlegroups.com
Perhaps you can try using different colors instead of different line styles.  There is an option called 'color_by_label', where you can set a label for some edges and color them accordingly.

Ursula Whitcher

unread,
May 31, 2014, 11:07:20 AM5/31/14
to sage-s...@googlegroups.com
On 5/30/2014 11:47 PM, P Purkayastha wrote:
> Perhaps you can try using different colors instead of different line
> styles. There is an option called 'color_by_label', where you can set a
> label for some edges and color them accordingly.

I am aware of this option, but I want to be able to color AND dash lines.

--Ursula.

P Purkayastha

unread,
Jun 1, 2014, 2:00:33 AM6/1/14
to sage-s...@googlegroups.com

Tom Boothby

unread,
Jun 1, 2014, 4:36:49 PM6/1/14
to sage-s...@googlegroups.com
If you partition the edges into several graphs, you can sum their
plots. Just remember axes=false when you show().
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

Tom Boothby

unread,
Jun 1, 2014, 4:49:45 PM6/1/14
to sage-s...@googlegroups.com
g = Graph([(i,(i+1)%6,i%2) for i in range(6)])
h = Graph([(i,(i+2)%6,i%2) for i in range(6)])
k = Graph([(i,(i+3)%6,i%2) for i in range(6) if i<3])
pos = graphs.CycleGraph(6).get_pos()
g.set_pos(pos)
h.set_pos(pos)
k.set_pos(pos)
p = g.plot(color_by_label={0:'blue', 1:'red'}, edge_style='dashed',
vertex_labels=False,vertex_size=0)
p+= h.plot(color_by_label={0:'blue', 1:'green'},
vertex_labels=False,vertex_size=0)
p+= k.plot(color_by_label={0:'brown', 1:'black'}, edge_style='dotted')
p.show(axes=False)

Ursula Whitcher

unread,
Jun 3, 2014, 6:00:54 PM6/3/14
to sage-s...@googlegroups.com
On 6/1/2014 3:49 PM, Tom Boothby wrote:
> g = Graph([(i,(i+1)%6,i%2) for i in range(6)])
> h = Graph([(i,(i+2)%6,i%2) for i in range(6)])
> k = Graph([(i,(i+3)%6,i%2) for i in range(6) if i<3])
[...]

Nice. Thanks!

--Ursula.
Reply all
Reply to author
Forward
0 new messages