From 24c4e9c8d476d439c634c281860b3db5a4378198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 10 Oct 2024 15:02:15 +0200 Subject: [PATCH 01/10] adding method tikz to class Graph --- src/sage/graphs/generic_graph.py | 137 +++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index c55dfc08f92..133b254ed58 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -938,6 +938,143 @@ def _latex_(self): return self.latex_options().latex() + def tikz(self, format='dot2tex', edge_labels=None, + color_by_label=False, prog='dot', rankdir='down', + use_sage_preamble=None, **kwds): + r""" + Return a TikzPicture of the graph. + + INPUT: + + - ``format`` -- string (default: ``None``), ``'dot2tex'`` or + ``'tkz_graph'``. If ``None``, it is set to ``'dot2tex'`` if + dot2tex is present, otherwise it is set to ``'tkz_graph'``. + - ``edge_labels`` -- bool (default: ``None``), if ``None`` + it is set to ``True`` if and only if format is ``'dot2tex'`` + - ``color_by_label`` -- bool (default: ``False``) + - ``use_sage_preamble`` -- bool (default: ``None``), if ``None`` + it is set to ``True`` if and only if format is ``'tkz_graph'`` + + When using format ``'dot2tex'``, the following inputs are considered: + + - ``prog`` -- string (default: ``'dot'``) the program used for the + layout corresponding to one of the software of the graphviz + suite: 'dot', 'neato', 'twopi', 'circo' or 'fdp'. + - ``rankdir`` -- string (default: ``'down'``) + - ``subgraph_clusters`` -- (default: ``[]``) a list of lists of + vertices, if supported by the layout engine, nodes belonging to + the same cluster subgraph are drawn together, with the entire + drawing of the cluster contained within a bounding rectangle. + + OUTPUT: + + An instance of :mod:`sage.misc.latex_standalone.TikzPicture`. + + .. NOTE:: + + Prerequisite: dot2tex optional Sage package and graphviz must be + installed when using format ``'dot2tex'``. + + EXAMPLES:: + + sage: g = graphs.PetersenGraph() + sage: tikz = g.tikz() # optional - dot2tex graphviz + sage: _ = tikz.pdf() # not tested + + :: + + sage: tikz = g.tikz(format='tkz_graph') + sage: _ = tikz.pdf() # not tested + + Using another value for ``prog``:: + + sage: tikz = g.tikz(prog='neato', # long time (3s), optional - dot2tex graphviz + ....: color_by_label=True) + sage: _ = tikz.pdf() # not tested + + Using another value for ``rankdir``:: + + sage: tikz = g.tikz(rankdir='right') # long time (3s), optional - dot2tex graphviz + sage: _ = tikz.pdf() # not tested + + Using subgraphs clusters (broken when using labels, see + :issue:`22070`):: + + sage: S = FiniteSetMaps(5) + sage: I = S((0,1,2,3,4)) + sage: a = S((0,1,3,0,0)) + sage: b = S((0,2,4,1,0)) + sage: roots = [I] + sage: succ = lambda v: [v*a,v*b,a*v,b*v] + sage: R = RecursivelyEnumeratedSet(roots, succ) + sage: G = R.to_digraph() + sage: G + Looped multi-digraph on 27 vertices + sage: C = G.strongly_connected_components() + sage: tikz = G.tikz(subgraph_clusters=C) # optional - dot2tex graphviz + sage: _ = tikz.pdf() # not tested + + An example coming from ``graphviz_string`` documentation in SageMath:: + + sage: # needs sage.symbolic + sage: f(x) = -1 / x + sage: g(x) = 1 / (x + 1) + sage: G = DiGraph() + sage: G.add_edges((i, f(i), f) for i in (1, 2, 1/2, 1/4)) + sage: G.add_edges((i, g(i), g) for i in (1, 2, 1/2, 1/4)) + sage: tikz = G.tikz(format='dot2tex') # optional - dot2tex graphviz + sage: _ = tikz.pdf() # not tested + sage: def edge_options(data): + ....: u, v, label = data + ....: options = {"color": {f: "red", g: "blue"}[label]} + ....: if (u,v) == (1/2, -2): options["label"] = "coucou"; options["label_style"] = "string" + ....: if (u,v) == (1/2,2/3): options["dot"] = "x=1,y=2" + ....: if (u,v) == (1, -1): options["label_style"] = "latex" + ....: if (u,v) == (1, 1/2): options["dir"] = "back" + ....: return options + sage: tikz = G.tikz(format='dot2tex', # optional - dot2tex graphviz + ....: edge_options=edge_options) + sage: _ = tikz.pdf() # not tested + + """ + # use format dot2tex by default + if format is None: + from sage.features import PythonModule + if PythonModule("dot2tex").is_present(): + format = 'dot2tex' + else: + format = 'tkz_graph' + + # by default draw edge_labels only for dot2tex (because tkz_graph + # puts None everywhere which is ugly) + if edge_labels is None: + if format == 'tkz_graph': + edge_labels = False + elif format == 'dot2tex': + edge_labels = True + else: + raise ValueError("invalid format(={}), should be 'dot2tex'" + "or 'tkz_graph'".format(format)) + + # by default use sage preamble only for format tkz_graph + if use_sage_preamble is None: + if format == 'tkz_graph': + use_sage_preamble = True + elif format == 'dot2tex': + use_sage_preamble = False + else: + raise ValueError("invalid format(={}), should be 'dot2tex'" + "or 'tkz_graph'".format(format)) + + self.latex_options().set_options(format=format, + edge_labels=edge_labels, color_by_label=color_by_label, + prog=prog, rankdir=rankdir, **kwds) + + from sage.misc.latex_standalone import TikzPicture + return TikzPicture(self._latex_(), + standalone_config=["border=4mm"], + use_sage_preamble=use_sage_preamble) + def _matrix_(self, R=None, vertices=None): """ Return the adjacency matrix of the graph over the specified ring. From ba599522781aee6a6d79354f61691d791d740107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 10 Oct 2024 21:11:16 +0200 Subject: [PATCH 02/10] unindent output line + added an item in the header doc --- src/sage/graphs/generic_graph.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 133b254ed58..69c55941325 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -296,6 +296,7 @@ :meth:`~GenericGraph.show3d` | Plot the graph using :class:`~sage.plot.plot3d.tachyon.Tachyon`, and shows the resulting plot. :meth:`~GenericGraph.graphviz_string` | Return a representation in the ``dot`` language. :meth:`~GenericGraph.graphviz_to_file_named` | Write a representation in the ``dot`` language in a file. + :meth:`~GenericGraph.tikz` | Return a :class:`~sage.misc.latex_standalone.TikzPicture` object representing the (di)graph. **Algorithmically hard stuff:** @@ -968,7 +969,7 @@ def tikz(self, format='dot2tex', edge_labels=None, OUTPUT: - An instance of :mod:`sage.misc.latex_standalone.TikzPicture`. + An instance of :mod:`sage.misc.latex_standalone.TikzPicture`. .. NOTE:: From 28fe8dba64c2bdb568d2ac34a3e3d61628ccf7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 17 Oct 2024 11:55:34 +0200 Subject: [PATCH 03/10] PR #38798: add possible values for rankdir --- src/sage/graphs/generic_graph.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 69c55941325..9fa86b1effc 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -961,7 +961,9 @@ def tikz(self, format='dot2tex', edge_labels=None, - ``prog`` -- string (default: ``'dot'``) the program used for the layout corresponding to one of the software of the graphviz suite: 'dot', 'neato', 'twopi', 'circo' or 'fdp'. - - ``rankdir`` -- string (default: ``'down'``) + - ``rankdir`` -- string (default: ``'down'``), direction of graph layout + when prog is ``'dot'``, possible values are ``'down'``, + ``'up'``, ``'right'`` and ``'left'``. - ``subgraph_clusters`` -- (default: ``[]``) a list of lists of vertices, if supported by the layout engine, nodes belonging to the same cluster subgraph are drawn together, with the entire From f306705182c5e00a6d9b2d06a1fa8bcbc4fc3652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 17 Oct 2024 13:30:28 +0200 Subject: [PATCH 04/10] PR #38798: expanded documentation for argument --- src/sage/graphs/generic_graph.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 9fa86b1effc..f91febc67e2 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -952,7 +952,11 @@ def tikz(self, format='dot2tex', edge_labels=None, dot2tex is present, otherwise it is set to ``'tkz_graph'``. - ``edge_labels`` -- bool (default: ``None``), if ``None`` it is set to ``True`` if and only if format is ``'dot2tex'`` - - ``color_by_label`` -- bool (default: ``False``) + - ``color_by_label`` -- boolean or dictionary or function (default: + ``False``); whether to color each edge with a different color + according to its label; the colors are chosen along a rainbow, unless + they are specified by a function or dictionary mapping labels to + colors; - ``use_sage_preamble`` -- bool (default: ``None``), if ``None`` it is set to ``True`` if and only if format is ``'tkz_graph'`` @@ -991,10 +995,29 @@ def tikz(self, format='dot2tex', edge_labels=None, Using another value for ``prog``:: - sage: tikz = g.tikz(prog='neato', # long time (3s), optional - dot2tex graphviz - ....: color_by_label=True) + sage: tikz = g.tikz(prog='neato') # long time (1s), optional - dot2tex graphviz sage: _ = tikz.pdf() # not tested + Using ``color_by_label`` with default rainbow colors:: + + sage: G = DiGraph({0: {1: 333, 2: 444}, 1: {0: 444}, 2: {0: 555}}) + sage: t = G.tikz(color_by_label=True) # optional - dot2tex graphviz # long time + sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time + + Using ``color_by_label`` with colors given as a dictionary:: + + sage: G = DiGraph({0: {1: 333, 2: 444}, 1: {0: 444}, 2: {0: 555}}) + sage: cbl = {333:'orange', 444: 'yellow', 555: 'purple'} + sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time + sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time + + Using ``color_by_label`` with colors given as a function:: + + sage: G = DiGraph({0: {1: -333, 2: -444}, 1: {0: 444}, 2: {0: 555}}) + sage: cbl = lambda label:'green' if label >= 0 else 'orange' + sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time + sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time + Using another value for ``rankdir``:: sage: tikz = g.tikz(rankdir='right') # long time (3s), optional - dot2tex graphviz From f68b84678eb654c5fbd7b6adac8ad077205963fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 17 Oct 2024 14:04:53 +0200 Subject: [PATCH 05/10] PR #38798: add documentation for all possible options --- src/sage/graphs/generic_graph.py | 38 +++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index f91febc67e2..c2f73859512 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -941,10 +941,15 @@ def _latex_(self): def tikz(self, format='dot2tex', edge_labels=None, color_by_label=False, prog='dot', rankdir='down', + standalone_config=None, usepackage=None, + usetikzlibrary=None, macros=None, use_sage_preamble=None, **kwds): r""" Return a TikzPicture of the graph. + If graphviz and dot2tex are available, it uses these packages for + placements of vertices and edges. + INPUT: - ``format`` -- string (default: ``None``), ``'dot2tex'`` or @@ -957,8 +962,6 @@ def tikz(self, format='dot2tex', edge_labels=None, according to its label; the colors are chosen along a rainbow, unless they are specified by a function or dictionary mapping labels to colors; - - ``use_sage_preamble`` -- bool (default: ``None``), if ``None`` - it is set to ``True`` if and only if format is ``'tkz_graph'`` When using format ``'dot2tex'``, the following inputs are considered: @@ -973,6 +976,23 @@ def tikz(self, format='dot2tex', edge_labels=None, the same cluster subgraph are drawn together, with the entire drawing of the cluster contained within a bounding rectangle. + Additionnal keywords arguments are forwarded to + :meth:`sage.graphs.graph_latex.GraphLatex.set_option`. + + The following inputs define the preamble of the latex standalone + document class file containing the tikzpicture: + + - ``standalone_config`` -- list of strings (default: ``["border=4mm"]``); + latex document class standalone configuration options + - ``usepackage`` -- list of strings (default: ``[]``); latex + packages + - ``usetikzlibrary`` -- list of strings (default: ``[]``); tikz + libraries to use + - ``macros`` -- list of strings (default: ``[]``); list of + newcommands needed for the picture + - ``use_sage_preamble`` -- bool (default: ``None``), if ``None`` + it is set to ``True`` if and only if format is ``'tkz_graph'`` + OUTPUT: An instance of :mod:`sage.misc.latex_standalone.TikzPicture`. @@ -1082,6 +1102,10 @@ def tikz(self, format='dot2tex', edge_labels=None, raise ValueError("invalid format(={}), should be 'dot2tex'" "or 'tkz_graph'".format(format)) + self.latex_options().set_options(format=format, + edge_labels=edge_labels, color_by_label=color_by_label, + prog=prog, rankdir=rankdir, **kwds) + # by default use sage preamble only for format tkz_graph if use_sage_preamble is None: if format == 'tkz_graph': @@ -1092,13 +1116,15 @@ def tikz(self, format='dot2tex', edge_labels=None, raise ValueError("invalid format(={}), should be 'dot2tex'" "or 'tkz_graph'".format(format)) - self.latex_options().set_options(format=format, - edge_labels=edge_labels, color_by_label=color_by_label, - prog=prog, rankdir=rankdir, **kwds) + if standalone_config is None: + standalone_config=["border=4mm"] from sage.misc.latex_standalone import TikzPicture return TikzPicture(self._latex_(), - standalone_config=["border=4mm"], + standalone_config=standalone_config, + usepackage=usepackage, + usetikzlibrary=usetikzlibrary, + macros=macros, use_sage_preamble=use_sage_preamble) def _matrix_(self, R=None, vertices=None): From f49902d9b6d46ba206d19a946050203c0dfa5e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 17 Oct 2024 14:07:18 +0200 Subject: [PATCH 06/10] PR #38798: add missing dependency on amstext usepackage --- src/sage/graphs/generic_graph.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index c2f73859512..7dba7a9a132 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1057,8 +1057,9 @@ def tikz(self, format='dot2tex', edge_labels=None, sage: G Looped multi-digraph on 27 vertices sage: C = G.strongly_connected_components() - sage: tikz = G.tikz(subgraph_clusters=C) # optional - dot2tex graphviz - sage: _ = tikz.pdf() # not tested + sage: tikz = G.tikz(subgraph_clusters=C) # optional - dot2tex graphviz # long time + sage: tikz.add_usepackage('amstext') # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf() # optional - dot2tex graphviz latex # long time An example coming from ``graphviz_string`` documentation in SageMath:: From 026fd9352cebbcceda9acc085cd0e78978e94c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 17 Oct 2024 17:28:34 +0200 Subject: [PATCH 07/10] PR #38798: do not check for format value, since this is done in set_options method already --- src/sage/graphs/generic_graph.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 7dba7a9a132..7a263415d1b 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1092,30 +1092,26 @@ def tikz(self, format='dot2tex', edge_labels=None, else: format = 'tkz_graph' - # by default draw edge_labels only for dot2tex (because tkz_graph - # puts None everywhere which is ugly) + # by default draw edge_labels for dot2tex but not for tkz_graph + # (because tkz_graph draws None everywhere which is ugly, whereas + # dot2tex ignores the labels when they are ``None``) if edge_labels is None: if format == 'tkz_graph': edge_labels = False elif format == 'dot2tex': edge_labels = True - else: - raise ValueError("invalid format(={}), should be 'dot2tex'" - "or 'tkz_graph'".format(format)) self.latex_options().set_options(format=format, edge_labels=edge_labels, color_by_label=color_by_label, prog=prog, rankdir=rankdir, **kwds) # by default use sage preamble only for format tkz_graph + # because content generated by tkz_graph depends on it if use_sage_preamble is None: if format == 'tkz_graph': use_sage_preamble = True elif format == 'dot2tex': use_sage_preamble = False - else: - raise ValueError("invalid format(={}), should be 'dot2tex'" - "or 'tkz_graph'".format(format)) if standalone_config is None: standalone_config=["border=4mm"] From 4fb2d5ddb37ac7f607eb8acbd3869c7e5c1c6c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Fri, 18 Oct 2024 15:20:48 +0200 Subject: [PATCH 08/10] PR #38798: removed unnecessary empty line --- src/sage/graphs/generic_graph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 7a263415d1b..9b268b8ffc3 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1082,7 +1082,6 @@ def tikz(self, format='dot2tex', edge_labels=None, sage: tikz = G.tikz(format='dot2tex', # optional - dot2tex graphviz ....: edge_options=edge_options) sage: _ = tikz.pdf() # not tested - """ # use format dot2tex by default if format is None: From 486cec1821880dd8466e79130d4248eadc50e70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Fri, 18 Oct 2024 15:32:27 +0200 Subject: [PATCH 09/10] PR #38798: updated doctests tags (let's test them all, otherwise, they get broken...) --- src/sage/graphs/generic_graph.py | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 9b268b8ffc3..936abace1e0 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1005,18 +1005,18 @@ def tikz(self, format='dot2tex', edge_labels=None, EXAMPLES:: sage: g = graphs.PetersenGraph() - sage: tikz = g.tikz() # optional - dot2tex graphviz - sage: _ = tikz.pdf() # not tested + sage: tikz = g.tikz() # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf(view=False) # optional - dot2tex graphviz latex # long time :: sage: tikz = g.tikz(format='tkz_graph') - sage: _ = tikz.pdf() # not tested + sage: _ = tikz.pdf(view=False) # optional - latex Using another value for ``prog``:: - sage: tikz = g.tikz(prog='neato') # long time (1s), optional - dot2tex graphviz - sage: _ = tikz.pdf() # not tested + sage: tikz = g.tikz(prog='neato') # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf() # optional - dot2tex graphviz latex # long time Using ``color_by_label`` with default rainbow colors:: @@ -1028,20 +1028,20 @@ def tikz(self, format='dot2tex', edge_labels=None, sage: G = DiGraph({0: {1: 333, 2: 444}, 1: {0: 444}, 2: {0: 555}}) sage: cbl = {333:'orange', 444: 'yellow', 555: 'purple'} - sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time - sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time + sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time + sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time Using ``color_by_label`` with colors given as a function:: sage: G = DiGraph({0: {1: -333, 2: -444}, 1: {0: 444}, 2: {0: 555}}) sage: cbl = lambda label:'green' if label >= 0 else 'orange' - sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time - sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time + sage: t = G.tikz(color_by_label=cbl) # optional - dot2tex graphviz # long time + sage: _ = t.pdf(view=False) # optional - dot2tex graphviz latex # long time Using another value for ``rankdir``:: - sage: tikz = g.tikz(rankdir='right') # long time (3s), optional - dot2tex graphviz - sage: _ = tikz.pdf() # not tested + sage: tikz = g.tikz(rankdir='right') # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf(view=False) # optional - dot2tex graphviz latex # long time Using subgraphs clusters (broken when using labels, see :issue:`22070`):: @@ -1057,9 +1057,9 @@ def tikz(self, format='dot2tex', edge_labels=None, sage: G Looped multi-digraph on 27 vertices sage: C = G.strongly_connected_components() - sage: tikz = G.tikz(subgraph_clusters=C) # optional - dot2tex graphviz # long time - sage: tikz.add_usepackage('amstext') # optional - dot2tex graphviz # long time - sage: _ = tikz.pdf() # optional - dot2tex graphviz latex # long time + sage: tikz = G.tikz(subgraph_clusters=C)# optional - dot2tex graphviz # long time + sage: tikz.add_usepackage('amstext') # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf(view=False) # optional - dot2tex graphviz latex # long time An example coming from ``graphviz_string`` documentation in SageMath:: @@ -1069,8 +1069,8 @@ def tikz(self, format='dot2tex', edge_labels=None, sage: G = DiGraph() sage: G.add_edges((i, f(i), f) for i in (1, 2, 1/2, 1/4)) sage: G.add_edges((i, g(i), g) for i in (1, 2, 1/2, 1/4)) - sage: tikz = G.tikz(format='dot2tex') # optional - dot2tex graphviz - sage: _ = tikz.pdf() # not tested + sage: tikz = G.tikz(format='dot2tex') # optional - dot2tex graphviz # long time + sage: _ = tikz.pdf(view=False) # optional - dot2tex graphviz latex # long time sage: def edge_options(data): ....: u, v, label = data ....: options = {"color": {f: "red", g: "blue"}[label]} @@ -1079,9 +1079,9 @@ def tikz(self, format='dot2tex', edge_labels=None, ....: if (u,v) == (1, -1): options["label_style"] = "latex" ....: if (u,v) == (1, 1/2): options["dir"] = "back" ....: return options - sage: tikz = G.tikz(format='dot2tex', # optional - dot2tex graphviz + sage: tikz = G.tikz(format='dot2tex', # optional - dot2tex graphviz # long time ....: edge_options=edge_options) - sage: _ = tikz.pdf() # not tested + sage: _ = tikz.pdf(view=False) # optional - dot2tex graphviz latex # long time """ # use format dot2tex by default if format is None: From 2a5b4d722478b96106367ddee34c706c87fdf058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Fri, 18 Oct 2024 15:43:08 +0200 Subject: [PATCH 10/10] PR #38798: fixing warning --- src/sage/graphs/generic_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 936abace1e0..862c4ee15a0 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1113,7 +1113,7 @@ def tikz(self, format='dot2tex', edge_labels=None, use_sage_preamble = False if standalone_config is None: - standalone_config=["border=4mm"] + standalone_config = ["border=4mm"] from sage.misc.latex_standalone import TikzPicture return TikzPicture(self._latex_(),