ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 10 Jan 2018 07:00:59 -0600Drawing a planar multigraph with loopshttps://ask.sagemath.org/question/40548/drawing-a-planar-multigraph-with-loops/ I would like to draw a planar graph with multiple edges and loops in Sage. Unfortunately, the default algorithm draws may intersecting edges and Sage is unable to compute an embedding for graphs with loops multiple edges.
Fortunately I know a planar embedding of this graph, so I tried using the `set_embedding` method, but it doesn't seem to work, either. If I only list a vertice's the neighbours, omitting their multiplicities, Sage complains that the list is shorter than the vertice's degree, while if I include multiple copies of each neighbour according to multiplicity, then Sage complains that elements of the list aren't unique.
Is there a way to achieve what I need?A.P.Wed, 10 Jan 2018 07:00:59 -0600https://ask.sagemath.org/question/40548/How to make pygraphviz and sage compatible?https://ask.sagemath.org/question/31070/how-to-make-pygraphviz-and-sage-compatible/ Hi,
I would like sage to help me when I am working with (un)directed graphs and quivers, and so on. After having played around with various possibilities, I would like to convert some stuff into a string and then let sage print something like a .ps - file that contains an image from dot (or something similar to this).
> Unfortunately, I came across the following issue(s) and have no idea what to do now. With the sage version I installed, there is python 2.x as a delivered package. But it seems that sage complains about python3, what doesn't make sense to me.
Could you help me understand and solve the following:
boehmler@boehmler-X55A:~/Schreibtisch/bb/sage-6.9-x86_64-Linux$ ./sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.9, Release Date: 2015-10-10 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: import networkx as nx
sage: import matplotlib.pyplot as plt
sage: import matplotlib.image as mpimg
sage: from cStringIO import StringIO
sage: g = nx.dodecahedral_graph()
sage: d = nx.to_pydot(g)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-0d33c400a5cf> in <module>()
----> 1 d = nx.to_pydot(g)
AttributeError: 'module' object has no attribute 'to_pydot'
sage: d = nx.to_agraph(g)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-d9254026fb59> in <module>()
----> 1 d = nx.to_agraph(g)
/home/boehmler/Schreibtisch/bb/sage-6.9-x86_64-Linux/local/lib/python/networkx/drawing/nx_agraph.pyc in
to_agraph(N)
132 raise ImportError('requires pygraphviz ',
133 'http://networkx.lanl.gov/pygraphviz ',
--> 134 '(not available for Python3)')
135 directed=N.is_directed()
136 strict=N.number_of_selfloops()==0 and not N.is_multigraph()
ImportError: ('requires pygraphviz ', 'http://networkx.lanl.gov/pygraphviz ', '(not available for Python3)')
sage:
Exiting Sage (CPU time 0m3.33s, Wall time 56m28.80s).
After typing
boehmler@boehmler-X55A:~/Schreibtisch/bb/sage-6.9-x86_64-Linux$ sudo -H pip install pygraphviz
I get the message
Wall -Wstrict-prototypes -fPIC -I/usr/include/graphviz -I/usr/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-2.7/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:130:21: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
# include <Python.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-6yZh3l/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-a6o8Fg-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6yZh3l/pygraphviz
in the end. I would be grateful for any hints how to solve / fix this.
Thanks for the help!
BernWed, 25 Nov 2015 20:42:50 -0600https://ask.sagemath.org/question/31070/Graph: colored edge labelshttps://ask.sagemath.org/question/25413/graph-colored-edge-labels/I'm trying to plot a graph with labels on the edges as follows:
G = Graph(multiedges=True)
G.add_edges( [(0,1,'a'),(1,2,'b'),(2,3,'c'),(3,4,'b'),(4,0,'a')] )
H = G.plot(edge_labels=True, graph_border=True)
H.show()
Is it possible to color the edge labels, e.g. making the "a" red, "b" blue etc?
herbTue, 06 Jan 2015 13:10:47 -0600https://ask.sagemath.org/question/25413/Graph theory: Make vertex labels in plots biggerhttps://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.
Thank you.G-SageWed, 12 Dec 2012 09:51:15 -0600https://ask.sagemath.org/question/9626/Graph theory exporting problemshttps://ask.sagemath.org/question/10549/graph-theory-exporting-problems/I type in the following SAGE code and get the graph on the screen that I would expect to get.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True)
When I try to export this to a file with the following code I get an "AssertionError" message.
g = Graph({0,[1,2,2]}); g
g.plot(graph_border = True).save('graph.pdf')
How can I fix this so that I can output this graph as a pdf file. I love how easy I can make nice looking graphs in SAGE, but it is useless if I can't export them to use in Latex.
Nick.BThu, 19 Sep 2013 13:20:10 -0500https://ask.sagemath.org/question/10549/SageTex and graphshttps://ask.sagemath.org/question/10474/sagetex-and-graphs/Hey guys,
Today i was looking for some graph plotting and i didn't arrived to use that piece of code in my .tex :
from sage.graphs.graph_coloring import edge_coloring
g = graphs.CompleteGraph(10)
g.graphplot(edge_colors=edge_coloring(g, hex_colors=True)).plot()
I can insert the first part in a block, but to plot I don't have the answer.
I tried : \sageplot{g.graphplot(edge_colors=edge_coloring(g, hex_colors=True)).plot()} and \sage{g.graphplot(edge_colors=edge_coloring(g, hex_colors=True))} but nothing works :/
Of course \sage{g} works but i'd like to have the graphical options !
Help plz :)
TyHolosmosTue, 27 Aug 2013 05:27:20 -0500https://ask.sagemath.org/question/10474/