ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 24 Feb 2019 04:46:58 -0600Display Vertex Label a Polytopehttp://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 04:46:58 -0600http://ask.sagemath.org/question/45538/Changing vertex labels on a randomly generated graphhttp://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 09:06:39 -0600http://ask.sagemath.org/question/32702/I keep losing my node labels on graph exporthttp://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.
MalteMalteFri, 15 Jan 2016 20:21:55 -0600http://ask.sagemath.org/question/32221/Can I draw a graph whose vertices have two kind of labels?http://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 07:14:14 -0600http://ask.sagemath.org/question/25377/graph vertex labels placement or alignmenthttp://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 02:40:01 -0500http://ask.sagemath.org/question/11349/DiGraph labels?http://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 11:45:55 -0600http://ask.sagemath.org/question/7838/