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.Mon, 07 Sep 2020 21:38:05 +0200Is it possible to know the corresponding graph labeling after using "relabel()"?https://ask.sagemath.org/question/53363/is-it-possible-to-know-the-corresponding-graph-labeling-after-using-relabel/**I am trying to generate the following cayley graph**
G=AlternatingGroup(5)
S=[(1,2,3),(1,2,4),(1,2,5)]
C=G.cayley_graph(generators=S, simple=True)
U=C.to_undirected()
U.vertices()
[(), (3,4,5), (3,5,4), (2,3)(4,5), (2,3,4), (2,3,5), (2,4,3), (2,4,5), (2,4)(3,5), (2,5,3), (2,5,4), (2,5)(3,4), (1,2)(4,5), (1,2)(3,4), (1,2)(3,5), (1,2,3), (1,2,3,4,5), (1,2,3,5,4), (1,2,4,5,3), (1,2,4), (1,2,4,3,5), (1,2,5,4,3), (1,2,5), (1,2,5,3,4), (1,3,2), (1,3,4,5,2), (1,3,5,4,2), (1,3)(4,5), (1,3,4), (1,3,5), (1,3)(2,4), (1,3,2,4,5), (1,3,5,2,4), (1,3)(2,5), (1,3,2,5,4), (1,3,4,2,5), (1,4,5,3,2), (1,4,2), (1,4,3,5,2), (1,4,3), (1,4,5), (1,4)(3,5), (1,4,5,2,3), (1,4)(2,3), (1,4,2,3,5), (1,4,2,5,3), (1,4,3,2,5), (1,4)(2,5), (1,5,4,3,2), (1,5,2), (1,5,3,4,2), (1,5,3), (1,5,4), (1,5)(3,4), (1,5,4,2,3), (1,5)(2,3), (1,5,2,3,4), (1,5,2,4,3), (1,5,3,2,4), (1,5)(2,4)]
**Here, I used the "relabel()" function and I got the following vertices**
U.relabel()
V= U.vertices()
V
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
**Is it possible to know the corresponding labels? Like for example what is the corresponding permutation for 0?**MKA47Mon, 07 Sep 2020 21:38:05 +0200https://ask.sagemath.org/question/53363/Display Vertex Label a Polytopehttps://ask.sagemath.org/question/45538/display-vertex-label-a-polytope/I want to display a polytope with labels of vertices. I guess I can do this by using the argument `vertex_labels = True` in the function `show()`. However, how can I input the labels of the vertices? More concretely, what should I include/change in the code below so that I can display, for example, A at (1,0), B at (0,1) and C at (1,1)?
P = Polyhedron(vertices = [(1,0), (0,1), (1,1)]) <br>
P.show(vertex_labels = True)
Additionally, I think the labels when shown will be on top of the vertices. How can I display the labels besides the vertices and hopefully outside of the polytope?
Thanks!ricomSun, 24 Feb 2019 11:46:58 +0100https://ask.sagemath.org/question/45538/Changing vertex labels on a randomly generated graphhttps://ask.sagemath.org/question/32702/changing-vertex-labels-on-a-randomly-generated-graph/ I know that if I want to create a graph on 4 vertices with vertex labels 1,2,3,4 then I can define my graph like this:
G = Graph({0: [1, 3], 1: [2, 3,4], 2: [1,4], 3: [], 4: []})
and then when I print in LaTeX using sagetex the labels show up as 1,2,3,4 but when I try to create a graph randomly
graphs.RandomGNM(4,5)).show(figsize=[4,4], graph_border=True)
the vertex labels are 0,1,2,3. How do I change the default vertex labels of a randomly created graph?dazedANDconfusedThu, 03 Mar 2016 16:06:39 +0100https://ask.sagemath.org/question/32702/I keep losing my node labels on graph exporthttps://ask.sagemath.org/question/32221/i-keep-losing-my-node-labels-on-graph-export/Hello! I often export Sage graphs by using networkx. This is a typical example:
import networkx
g = graphs.HerschelGraph()
h = g.networkx_graph()
networkx.write_graphml(h,'HerschelGraph.graphml')
However, when I open the graphml-file in the *YEd Graph Editor* (which is my favorite software for displaying graphs) I find that the node labels (that are clearly existent in the Sage version of the graph) have disappeared forever. Everything else works fine. Assuming that this is Sage's fault rather than the graph editor's fault: What can I do to export the node labels as well?
Thank you very much for your help.
MalteMalteSat, 16 Jan 2016 03:21:55 +0100https://ask.sagemath.org/question/32221/Can I draw a graph whose vertices have two kind of labels?https://ask.sagemath.org/question/25377/can-i-draw-a-graph-whose-vertices-have-two-kind-of-labels/ Hello.
I want to draw a graph.
Each vertex connects to another information.
For example,
G=graphs.EmptyGraph()
G.add_vertices([1,2,3,4])
for i in [1,2,3]:
for j in [i+1..4]:
if j%i==0:
G.add_edge([i,j])
V=[]
for i in G.vertices():
if i<3:
V=V+["Dog"]
else:
V=V+["Cat"]
Then 1,2 --> Dog and 3,4 --> Cat.
**I want to get a plotting graph which shows the second information Dog and Cat.**
Is that possible?
Thanks.SeminFri, 02 Jan 2015 14:14:14 +0100https://ask.sagemath.org/question/25377/graph vertex labels placement or alignmenthttps://ask.sagemath.org/question/11349/graph-vertex-labels-placement-or-alignment/I made a sage Graph() for visualizing a bibliography and found that there was no good way to align or change the placement of the vertex labels.
I wanted some labels to align left and others to align right, but they were all centred on their vertex. I ended up doubling the length of the label string with spaces and adding a period with some code like the following
lDict = {}
for v in G.vertices():
if <test for the type of vertex>:
lDict[v] = v + len(v)*' ' + '.'
else:
lDict[v] = ''.join(['.',len(v)*' ',v])
G.relabel(lDict)
I managed to get this (click for full sized image):
[![Graph](http://alejandroerickson.com/home/blog/im/small_bibgraph.jpg)](http://alejandroerickson.com/home/blog/im/full_sized_bibgraph.png)
Is there a way to manipulate the placement of the labels?alejandroericksonMon, 31 Mar 2014 09:40:01 +0200https://ask.sagemath.org/question/11349/DiGraph labels?https://ask.sagemath.org/question/7838/digraph-labels/Labels don't seem to work on DiGraphs. For example:
> g=DiGraph(vertex_labels=True)
> g.add_edge(2,3,label="label")
> g.show()
This just shows 2 and 3 as labels. Is this a bug or am I doing something wrong?
Thanks in advance.Eviatar BachSun, 02 Jan 2011 18:45:55 +0100https://ask.sagemath.org/question/7838/