ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 13 Oct 2017 16:00:23 +0200Edge color for undirected multiedge graphshttps://ask.sagemath.org/question/39153/edge-color-for-undirected-multiedge-graphs/ It seems that there is a bug with specifying the color of undirected multiedges. Here's an example:
G=graphs.PathGraph(2)
G.allow_multiple_edges(True)
G.add_edge((0,1))
G.plot(edge_colors={"red":[(1,0)]})
The graph plotted has then four edges, two black and two red. It seems that the multiedge to be colored red is seen as a different one than the already present one, even though they are actually the same since the graph is undirected. I get the intended plot if I change the last line to:
G.plot(edge_colors={"red":[(0,1)]})AckslFri, 13 Oct 2017 16:00:23 +0200https://ask.sagemath.org/question/39153/edge_style for different edges in a multigraphhttps://ask.sagemath.org/question/33228/edge_style-for-different-edges-in-a-multigraph/I'm trying to make a directed multigraph in which different edges have colors/edge styles so that they can be easy read either in color or in black and white.
I can make a graph with different colors:
D = DiGraph(multiedges=True)
var('A,B')
D.add_edge(A,B,'edge1')
D.add_edge(A,B,'edge2')
D.graphplot(color_by_label={'edge1':'green','edge2':'blue'}).show()
I can also make a graph with different styles, but overlayed:
G1 = DiGraph(multiedges=True)
G2 = DiGraph(multiedges=True)
var('A,B')
G1.add_edge(A,B,'edge1')
G2.add_edge(A,B,'edge2')
G1.set_pos({A:[0,0],B:[1,0]})
G2.set_pos({A:[0,0],B:[1,0]})
G = G1.graphplot(color_by_label={'edge1':'green'}, edge_style='--').plot() + G2.graphplot(color_by_label={'edge2':'blue'}, edge_style=':').plot()
G.show(axes=False)
and a very hack-y solution which looks nicer, but still bad:
G1 = DiGraph(multiedges=True)
G2 = DiGraph(multiedges=True)
var('A,B')
G1.add_edge(A,B,'edge1')
G2.add_edge(A,B,'edge2')
G1.add_edge(A,B,'edge2')
G2.add_edge(A,B,'edge1')
G1.set_pos({A:[0,0],B:[1,0]})
G2.set_pos({A:[0,0],B:[1,0]})
G = G1.graphplot(color_by_label={'edge1':'green','edge2':'white'}, edge_style='--').plot() + G2.graphplot(color_by_label={'edge2':'blue','edge1':'white'}, edge_style=':').plot()
G.show(axes=False)
I'd love to be able to have a multigraph where the edges are both different colors and different styles and don't completely overlap, but I'm not seeing a way to do this. Any help is appreciated!mthomasTue, 26 Apr 2016 02:17:33 +0200https://ask.sagemath.org/question/33228/