diff --git a/gap/gv.gd b/gap/gv.gd index 8a12abd..f10049e 100644 --- a/gap/gv.gd +++ b/gap/gv.gd @@ -12,15 +12,7 @@ ## graphviz package. DeclareOperation("GV_GetCounter", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_IncCounter", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifyGraphHead", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifyDigraphHead", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifySubgraphHead", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifyContextHead", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifyNode", [IsGraphvizNode]); -DeclareOperation("GV_StringifyGraphAttrs", [IsGraphvizGraphDigraphOrContext]); -DeclareOperation("GV_StringifyNodeEdgeAttrs", [IsRecord]); DeclareOperation("GV_StringifyGraph", [IsGraphvizGraphDigraphOrContext, IsBool]); @@ -33,8 +25,6 @@ DeclareAttribute("GV_Filter", IsGraphvizDigraph); DeclareOperation("GV_Subgraph", [IsGraphvizGraphDigraphOrContext, IsString]); DeclareOperation("GV_Context", [IsGraphvizGraphDigraphOrContext, IsString]); -DeclareOperation("GV_HasNode", [IsGraphvizGraphDigraphOrContext, IsObject]); - DeclareOperation("GV_GetParent", [IsGraphvizObject]); DeclareOperation("GV_GraphTreeSearch", [IsGraphvizGraphDigraphOrContext, IsFunction]); @@ -43,130 +33,10 @@ DeclareOperation("GV_GraphSearchChildren", DeclareOperation("GV_FindGraphWithNode", [IsGraphvizGraphDigraphOrContext, IsString]); DeclareOperation("GV_GetRoot", [IsGraphvizObject]); -DeclareOperation("GV_EnclosingNonContext", [IsGraphvizObject]); DeclareOperation("GV_AddNode", [IsGraphvizGraphDigraphOrContext, IsGraphvizNode]); DeclareOperation("GV_AddEdge", [IsGraphvizGraphDigraphOrContext, IsGraphvizEdge]); -DeclareOperation("GV_GetIdx", [IsGraphvizObject]); -DeclareOperation("GV_ConstructHistory", [IsGraphvizGraphDigraphOrContext]); DeclareGlobalFunction("GV_IsValidColor"); DeclareGlobalFunction("GV_ErrorIfNotNodeColoring"); -DeclareGlobalFunction("GV_ErrorIfNotValidLabel"); - -BindGlobal("GV_ValidColorNames", - ["aliceblue", "antiquewhite", "antiquewhite1", "antiquewhite2", - "antiquewhite3", "antiquewhite4", "aquamarine", "aquamarine1", "aquamarine2", - "aquamarine3", "aquamarine4", "azure", "azure1", "azure2", "azure3", - "azure4", "beige", "bisque", "bisque1", "bisque2", "bisque3", "bisque4", - "black", "blanchedalmond", "blue", "blue1", "blue2", "blue3", "blue4", - "blueviolet", "brown", "brown1", "brown2", "brown3", "brown4", "burlywood", - "burlywood1", "burlywood2", "burlywood3", "burlywood4", "cadetblue", - "cadetblue1", "cadetblue2", "cadetblue3", "cadetblue4", "chartreuse", - "chartreuse1", "chartreuse2", "chartreuse3", "chartreuse4", "chocolate", - "chocolate1", "chocolate2", "chocolate3", "chocolate4", "coral", "coral1", - "coral2", "coral3", "coral4", "cornflowerblue", "cornsilk", "cornsilk1", - "cornsilk2", "cornsilk3", "cornsilk4", "crimson", "cyan", "cyan1", "cyan2", - "cyan3", "cyan4", "darkgoldenrod", "darkgoldenrod1", "darkgoldenrod2", - "darkgoldenrod3", "darkgoldenrod4", "darkgreen", "darkkhaki", - "darkolivegreen", "darkolivegreen1", "darkolivegreen2", "darkolivegreen3", - "darkolivegreen4", "darkorange", "darkorange1", "darkorange2", "darkorange3", - "darkorange4", "darkorchid", "darkorchid1", "darkorchid2", "darkorchid3", - "darkorchid4", "darksalmon", "darkseagreen", "darkseagreen1", - "darkseagreen2", "darkseagreen3", "darkseagreen4", "darkslateblue", - "darkslategray", "darkslategray1", "darkslategray2", "darkslategray3", - "darkslategray4", "darkslategrey", "darkturquoise", "darkviolet", "deeppink", - "deeppink1", "deeppink2", "deeppink3", "deeppink4", "deepskyblue", - "deepskyblue1", "deepskyblue2", "deepskyblue3", "deepskyblue4", "dimgray", - "dimgrey", "dodgerblue", "dodgerblue1", "dodgerblue2", "dodgerblue3", - "dodgerblue4", "firebrick", "firebrick1", "firebrick2", "firebrick3", - "firebrick4", "floralwhite", "forestgreen", "gainsboro", "ghostwhite", - "gold", "gold1", "gold2", "gold3", "gold4", "goldenrod", "goldenrod1", - "goldenrod2", "goldenrod3", "goldenrod4", "gray", "gray0", "gray1", "gray10", - "gray100", "gray11", "gray12", "gray13", "gray14", "gray15", "gray16", - "gray17", "gray18", "gray19", "gray2", "gray20", "gray21", "gray22", - "gray23", "gray24", "gray25", "gray26", "gray27", "gray28", "gray29", - "gray3", "gray30", "gray31", "gray32", "gray33", "gray34", "gray35", - "gray36", "gray37", "gray38", "gray39", "gray4", "gray40", "gray41", - "gray42", "gray43", "gray44", "gray45", "gray46", "gray47", "gray48", - "gray49", "gray5", "gray50", "gray51", "gray52", "gray53", "gray54", - "gray55", "gray56", "gray57", "gray58", "gray59", "gray6", "gray60", - "gray61", "gray62", "gray63", "gray64", "gray65", "gray66", "gray67", - "gray68", "gray69", "gray7", "gray70", "gray71", "gray72", "gray73", - "gray74", "gray75", "gray76", "gray77", "gray78", "gray79", "gray8", - "gray80", "gray81", "gray82", "gray83", "gray84", "gray85", "gray86", - "gray87", "gray88", "gray89", "gray9", "gray90", "gray91", "gray92", - "gray93", "gray94", "gray95", "gray96", "gray97", "gray98", "gray99", - "green", "green1", "green2", "green3", "green4", "greenyellow", "grey", - "grey0", "grey1", "grey10", "grey100", "grey11", "grey12", "grey13", - "grey14", "grey15", "grey16", "grey17", "grey18", "grey19", "grey2", - "grey20", "grey21", "grey22", "grey23", "grey24", "grey25", "grey26", - "grey27", "grey28", "grey29", "grey3", "grey30", "grey31", "grey32", - "grey33", "grey34", "grey35", "grey36", "grey37", "grey38", "grey39", - "grey4", "grey40", "grey41", "grey42", "grey43", "grey44", "grey45", - "grey46", "grey47", "grey48", "grey49", "grey5", "grey50", "grey51", - "grey52", "grey53", "grey54", "grey55", "grey56", "grey57", "grey58", - "grey59", "grey6", "grey60", "grey61", "grey62", "grey63", "grey64", - "grey65", "grey66", "grey67", "grey68", "grey69", "grey7", "grey70", - "grey71", "grey72", "grey73", "grey74", "grey75", "grey76", "grey77", - "grey78", "grey79", "grey8", "grey80", "grey81", "grey82", "grey83", - "grey84", "grey85", "grey86", "grey87", "grey88", "grey89", "grey9", - "grey90", "grey91", "grey92", "grey93", "grey94", "grey95", "grey96", - "grey97", "grey98", "grey99", "honeydew", "honeydew1", "honeydew2", - "honeydew3", "honeydew4", "hotpink", "hotpink1", "hotpink2", "hotpink3", - "hotpink4", "indianred", "indianred1", "indianred2", "indianred3", - "indianred4", "indigo", "invis", "ivory", "ivory1", "ivory2", "ivory3", - "ivory4", "khaki", "khaki1", "khaki2", "khaki3", "khaki4", "lavender", - "lavenderblush", "lavenderblush1", "lavenderblush2", "lavenderblush3", - "lavenderblush4", "lawngreen", "lemonchiffon", "lemonchiffon1", - "lemonchiffon2", "lemonchiffon3", "lemonchiffon4", "lightblue", "lightblue1", - "lightblue2", "lightblue3", "lightblue4", "lightcoral", "lightcyan", - "lightcyan1", "lightcyan2", "lightcyan3", "lightcyan4", "lightgoldenrod", - "lightgoldenrod1", "lightgoldenrod2", "lightgoldenrod3", "lightgoldenrod4", - "lightgoldenrodyellow", "lightgray", "lightgrey", "lightpink", "lightpink1", - "lightpink2", "lightpink3", "lightpink4", "lightsalmon", "lightsalmon1", - "lightsalmon2", "lightsalmon3", "lightsalmon4", "lightseagreen", - "lightskyblue", "lightskyblue1", "lightskyblue2", "lightskyblue3", - "lightskyblue4", "lightslateblue", "lightslategray", "lightslategrey", - "lightsteelblue", "lightsteelblue1", "lightsteelblue2", "lightsteelblue3", - "lightsteelblue4", "lightyellow", "lightyellow1", "lightyellow2", - "lightyellow3", "lightyellow4", "limegreen", "linen", "magenta", "magenta1", - "magenta2", "magenta3", "magenta4", "maroon", "maroon1", "maroon2", - "maroon3", "maroon4", "mediumaquamarine", "mediumblue", "mediumorchid", - "mediumorchid1", "mediumorchid2", "mediumorchid3", "mediumorchid4", - "mediumpurple", "mediumpurple1", "mediumpurple2", "mediumpurple3", - "mediumpurple4", "mediumseagreen", "mediumslateblue", "mediumspringgreen", - "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", - "mistyrose", "mistyrose1", "mistyrose2", "mistyrose3", "mistyrose4", - "moccasin", "navajowhite", "navajowhite1", "navajowhite2", "navajowhite3", - "navajowhite4", "navy", "navyblue", "none", "oldlace", "olivedrab", - "olivedrab1", "olivedrab2", "olivedrab3", "olivedrab4", "orange", "orange1", - "orange2", "orange3", "orange4", "orangered", "orangered1", "orangered2", - "orangered3", "orangered4", "orchid", "orchid1", "orchid2", "orchid3", - "orchid4", "palegoldenrod", "palegreen", "palegreen1", "palegreen2", - "palegreen3", "palegreen4", "paleturquoise", "paleturquoise1", - "paleturquoise2", "paleturquoise3", "paleturquoise4", "palevioletred", - "palevioletred1", "palevioletred2", "palevioletred3", "palevioletred4", - "papayawhip", "peachpuff", "peachpuff1", "peachpuff2", "peachpuff3", - "peachpuff4", "peru", "pink", "pink1", "pink2", "pink3", "pink4", "plum", - "plum1", "plum2", "plum3", "plum4", "powderblue", "purple", "purple1", - "purple2", "purple3", "purple4", "red", "red1", "red2", "red3", "red4", - "rosybrown", "rosybrown1", "rosybrown2", "rosybrown3", "rosybrown4", - "royalblue", "royalblue1", "royalblue2", "royalblue3", "royalblue4", - "saddlebrown", "salmon", "salmon1", "salmon2", "salmon3", "salmon4", - "sandybrown", "seagreen", "seagreen1", "seagreen2", "seagreen3", "seagreen4", - "seashell", "seashell1", "seashell2", "seashell3", "seashell4", "sienna", - "sienna1", "sienna2", "sienna3", "sienna4", "skyblue", "skyblue1", - "skyblue2", "skyblue3", "skyblue4", "slateblue", "slateblue1", "slateblue2", - "slateblue3", "slateblue4", "slategray", "slategray1", "slategray2", - "slategray3", "slategray4", "slategrey", "snow", "snow1", "snow2", "snow3", - "snow4", "springgreen", "springgreen1", "springgreen2", "springgreen3", - "springgreen4", "steelblue", "steelblue1", "steelblue2", "steelblue3", - "steelblue4", "tan", "tan1", "tan2", "tan3", "tan4", "thistle", "thistle1", - "thistle2", "thistle3", "thistle4", "tomato", "tomato1", "tomato2", - "tomato3", "tomato4", "transparent", "turquoise", "turquoise1", "turquoise2", - "turquoise3", "turquoise4", "violet", "violetred", "violetred1", - "violetred2", "violetred3", "violetred4", "wheat", "wheat1", "wheat2", - "wheat3", "wheat4", "white", "whitesmoke", "yellow", "yellow1", "yellow2", - "yellow3", "yellow4", "yellowgreen"]); diff --git a/gap/gv.gi b/gap/gv.gi index 258b38c..8ec4c77 100644 --- a/gap/gv.gi +++ b/gap/gv.gi @@ -37,6 +37,17 @@ BindGlobal("GV_GraphDigraphOrContextType", # Constructors etc ############################################################################### +# Graph child counter functions + +BindGlobal("GV_IncCounter", +function(x) + x!.Counter := x!.Counter + 1; +end); + +InstallMethod(GV_GetCounter, "for a graphviz graph", +[IsGraphvizGraphDigraphOrContext], +x -> x!.Counter); + InstallMethod(GV_Node, "for a string", [IsGraphvizGraphDigraphOrContext, IsString], function(graph, name) @@ -124,26 +135,8 @@ function(parent, name) return out; end); -# Graph child counter functions - -InstallMethod(GV_IncCounter, -"for a graphviz graph", -[IsGraphvizGraphDigraphOrContext], -function(x) - x!.Counter := x!.Counter + 1; -end); - -InstallMethod(GV_GetCounter, "for a graphviz graph", -[IsGraphvizGraphDigraphOrContext], -x -> x!.Counter); - # Nodes -InstallMethod(GV_HasNode, -"for a graphviz graph", -[IsGraphvizGraphDigraphOrContext, IsString], -{g, name} -> name in RecNames(GraphvizNodes(g))); - InstallMethod(GV_GetParent, "for a graphviz object", [IsGraphvizObject], graph -> graph!.Parent); @@ -246,18 +239,6 @@ function(graph) return graph; end); -InstallMethod(GV_EnclosingNonContext, -"for a graphviz object with subobjects", -[IsGraphvizObject], -function(graph) - local parent; - - repeat - parent := GV_GetParent(graph); - until parent = fail or not IsGraphvizContext(parent); - return parent; -end); - InstallMethod(GV_AddNode, "for a graphviz graph and node", [IsGraphvizGraphDigraphOrContext, IsGraphvizNode], @@ -282,20 +263,19 @@ end); ############################################################################### # @ Return DOT graph head line. -InstallMethod(GV_StringifyGraphHead, "for a string", [IsGraphvizGraph], +BindGlobal("GV_StringifyGraphHead", graph -> StringFormatted("graph {} {{\n", GraphvizName(graph))); # @ Return DOT digraph head line. -InstallMethod(GV_StringifyDigraphHead, "for a string", [IsGraphvizDigraph], +BindGlobal("GV_StringifyDigraphHead", graph -> StringFormatted("digraph {} {{\n", GraphvizName(graph))); # @ Return DOT subgraph head line. -InstallMethod(GV_StringifySubgraphHead, "for a string", -[IsGraphvizGraphDigraphOrContext], +BindGlobal("GV_StringifySubgraphHead", graph -> StringFormatted("subgraph {} {{\n", GraphvizName(graph))); # @ Return DOT subgraph head line. -InstallMethod(GV_StringifyContextHead, "for a string", [IsGraphvizContext], +BindGlobal("GV_StringifyContextHead", graph -> StringFormatted("// {} context \n{{\n", GraphvizName(graph))); BindGlobal("GV_StringifyNodeName", @@ -354,8 +334,7 @@ function(attrs) end); # @ Return DOT node statement line. -InstallMethod(GV_StringifyNode, "for string and record", -[IsGraphvizNode], +BindGlobal("GV_StringifyNode", function(node) local name, attrs; name := GV_StringifyNodeName(node); @@ -381,14 +360,9 @@ function(edge, edge_str) GV_StringifyAttrList(attrs)); end); -InstallMethod(GV_GetIdx, -"for a graphviz object", -[IsGraphvizObject], -x -> x!.Idx); +BindGlobal("GV_GetIdx", x -> x!.Idx); -InstallMethod(GV_ConstructHistory, -"for a graphviz graph", -[IsGraphvizGraphDigraphOrContext], +BindGlobal("GV_ConstructHistory", function(graph) local ctxs, nodes, edges, subs, ctxs_hist, node_hist, edge_hist, subs_hist, hist; @@ -462,6 +436,122 @@ function(graph, is_subgraph) return result; end); +BindGlobal("GV_ValidColorNames", + ["aliceblue", "antiquewhite", "antiquewhite1", "antiquewhite2", + "antiquewhite3", "antiquewhite4", "aquamarine", "aquamarine1", "aquamarine2", + "aquamarine3", "aquamarine4", "azure", "azure1", "azure2", "azure3", + "azure4", "beige", "bisque", "bisque1", "bisque2", "bisque3", "bisque4", + "black", "blanchedalmond", "blue", "blue1", "blue2", "blue3", "blue4", + "blueviolet", "brown", "brown1", "brown2", "brown3", "brown4", "burlywood", + "burlywood1", "burlywood2", "burlywood3", "burlywood4", "cadetblue", + "cadetblue1", "cadetblue2", "cadetblue3", "cadetblue4", "chartreuse", + "chartreuse1", "chartreuse2", "chartreuse3", "chartreuse4", "chocolate", + "chocolate1", "chocolate2", "chocolate3", "chocolate4", "coral", "coral1", + "coral2", "coral3", "coral4", "cornflowerblue", "cornsilk", "cornsilk1", + "cornsilk2", "cornsilk3", "cornsilk4", "crimson", "cyan", "cyan1", "cyan2", + "cyan3", "cyan4", "darkgoldenrod", "darkgoldenrod1", "darkgoldenrod2", + "darkgoldenrod3", "darkgoldenrod4", "darkgreen", "darkkhaki", + "darkolivegreen", "darkolivegreen1", "darkolivegreen2", "darkolivegreen3", + "darkolivegreen4", "darkorange", "darkorange1", "darkorange2", "darkorange3", + "darkorange4", "darkorchid", "darkorchid1", "darkorchid2", "darkorchid3", + "darkorchid4", "darksalmon", "darkseagreen", "darkseagreen1", + "darkseagreen2", "darkseagreen3", "darkseagreen4", "darkslateblue", + "darkslategray", "darkslategray1", "darkslategray2", "darkslategray3", + "darkslategray4", "darkslategrey", "darkturquoise", "darkviolet", "deeppink", + "deeppink1", "deeppink2", "deeppink3", "deeppink4", "deepskyblue", + "deepskyblue1", "deepskyblue2", "deepskyblue3", "deepskyblue4", "dimgray", + "dimgrey", "dodgerblue", "dodgerblue1", "dodgerblue2", "dodgerblue3", + "dodgerblue4", "firebrick", "firebrick1", "firebrick2", "firebrick3", + "firebrick4", "floralwhite", "forestgreen", "gainsboro", "ghostwhite", + "gold", "gold1", "gold2", "gold3", "gold4", "goldenrod", "goldenrod1", + "goldenrod2", "goldenrod3", "goldenrod4", "gray", "gray0", "gray1", "gray10", + "gray100", "gray11", "gray12", "gray13", "gray14", "gray15", "gray16", + "gray17", "gray18", "gray19", "gray2", "gray20", "gray21", "gray22", + "gray23", "gray24", "gray25", "gray26", "gray27", "gray28", "gray29", + "gray3", "gray30", "gray31", "gray32", "gray33", "gray34", "gray35", + "gray36", "gray37", "gray38", "gray39", "gray4", "gray40", "gray41", + "gray42", "gray43", "gray44", "gray45", "gray46", "gray47", "gray48", + "gray49", "gray5", "gray50", "gray51", "gray52", "gray53", "gray54", + "gray55", "gray56", "gray57", "gray58", "gray59", "gray6", "gray60", + "gray61", "gray62", "gray63", "gray64", "gray65", "gray66", "gray67", + "gray68", "gray69", "gray7", "gray70", "gray71", "gray72", "gray73", + "gray74", "gray75", "gray76", "gray77", "gray78", "gray79", "gray8", + "gray80", "gray81", "gray82", "gray83", "gray84", "gray85", "gray86", + "gray87", "gray88", "gray89", "gray9", "gray90", "gray91", "gray92", + "gray93", "gray94", "gray95", "gray96", "gray97", "gray98", "gray99", + "green", "green1", "green2", "green3", "green4", "greenyellow", "grey", + "grey0", "grey1", "grey10", "grey100", "grey11", "grey12", "grey13", + "grey14", "grey15", "grey16", "grey17", "grey18", "grey19", "grey2", + "grey20", "grey21", "grey22", "grey23", "grey24", "grey25", "grey26", + "grey27", "grey28", "grey29", "grey3", "grey30", "grey31", "grey32", + "grey33", "grey34", "grey35", "grey36", "grey37", "grey38", "grey39", + "grey4", "grey40", "grey41", "grey42", "grey43", "grey44", "grey45", + "grey46", "grey47", "grey48", "grey49", "grey5", "grey50", "grey51", + "grey52", "grey53", "grey54", "grey55", "grey56", "grey57", "grey58", + "grey59", "grey6", "grey60", "grey61", "grey62", "grey63", "grey64", + "grey65", "grey66", "grey67", "grey68", "grey69", "grey7", "grey70", + "grey71", "grey72", "grey73", "grey74", "grey75", "grey76", "grey77", + "grey78", "grey79", "grey8", "grey80", "grey81", "grey82", "grey83", + "grey84", "grey85", "grey86", "grey87", "grey88", "grey89", "grey9", + "grey90", "grey91", "grey92", "grey93", "grey94", "grey95", "grey96", + "grey97", "grey98", "grey99", "honeydew", "honeydew1", "honeydew2", + "honeydew3", "honeydew4", "hotpink", "hotpink1", "hotpink2", "hotpink3", + "hotpink4", "indianred", "indianred1", "indianred2", "indianred3", + "indianred4", "indigo", "invis", "ivory", "ivory1", "ivory2", "ivory3", + "ivory4", "khaki", "khaki1", "khaki2", "khaki3", "khaki4", "lavender", + "lavenderblush", "lavenderblush1", "lavenderblush2", "lavenderblush3", + "lavenderblush4", "lawngreen", "lemonchiffon", "lemonchiffon1", + "lemonchiffon2", "lemonchiffon3", "lemonchiffon4", "lightblue", "lightblue1", + "lightblue2", "lightblue3", "lightblue4", "lightcoral", "lightcyan", + "lightcyan1", "lightcyan2", "lightcyan3", "lightcyan4", "lightgoldenrod", + "lightgoldenrod1", "lightgoldenrod2", "lightgoldenrod3", "lightgoldenrod4", + "lightgoldenrodyellow", "lightgray", "lightgrey", "lightpink", "lightpink1", + "lightpink2", "lightpink3", "lightpink4", "lightsalmon", "lightsalmon1", + "lightsalmon2", "lightsalmon3", "lightsalmon4", "lightseagreen", + "lightskyblue", "lightskyblue1", "lightskyblue2", "lightskyblue3", + "lightskyblue4", "lightslateblue", "lightslategray", "lightslategrey", + "lightsteelblue", "lightsteelblue1", "lightsteelblue2", "lightsteelblue3", + "lightsteelblue4", "lightyellow", "lightyellow1", "lightyellow2", + "lightyellow3", "lightyellow4", "limegreen", "linen", "magenta", "magenta1", + "magenta2", "magenta3", "magenta4", "maroon", "maroon1", "maroon2", + "maroon3", "maroon4", "mediumaquamarine", "mediumblue", "mediumorchid", + "mediumorchid1", "mediumorchid2", "mediumorchid3", "mediumorchid4", + "mediumpurple", "mediumpurple1", "mediumpurple2", "mediumpurple3", + "mediumpurple4", "mediumseagreen", "mediumslateblue", "mediumspringgreen", + "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", + "mistyrose", "mistyrose1", "mistyrose2", "mistyrose3", "mistyrose4", + "moccasin", "navajowhite", "navajowhite1", "navajowhite2", "navajowhite3", + "navajowhite4", "navy", "navyblue", "none", "oldlace", "olivedrab", + "olivedrab1", "olivedrab2", "olivedrab3", "olivedrab4", "orange", "orange1", + "orange2", "orange3", "orange4", "orangered", "orangered1", "orangered2", + "orangered3", "orangered4", "orchid", "orchid1", "orchid2", "orchid3", + "orchid4", "palegoldenrod", "palegreen", "palegreen1", "palegreen2", + "palegreen3", "palegreen4", "paleturquoise", "paleturquoise1", + "paleturquoise2", "paleturquoise3", "paleturquoise4", "palevioletred", + "palevioletred1", "palevioletred2", "palevioletred3", "palevioletred4", + "papayawhip", "peachpuff", "peachpuff1", "peachpuff2", "peachpuff3", + "peachpuff4", "peru", "pink", "pink1", "pink2", "pink3", "pink4", "plum", + "plum1", "plum2", "plum3", "plum4", "powderblue", "purple", "purple1", + "purple2", "purple3", "purple4", "red", "red1", "red2", "red3", "red4", + "rosybrown", "rosybrown1", "rosybrown2", "rosybrown3", "rosybrown4", + "royalblue", "royalblue1", "royalblue2", "royalblue3", "royalblue4", + "saddlebrown", "salmon", "salmon1", "salmon2", "salmon3", "salmon4", + "sandybrown", "seagreen", "seagreen1", "seagreen2", "seagreen3", "seagreen4", + "seashell", "seashell1", "seashell2", "seashell3", "seashell4", "sienna", + "sienna1", "sienna2", "sienna3", "sienna4", "skyblue", "skyblue1", + "skyblue2", "skyblue3", "skyblue4", "slateblue", "slateblue1", "slateblue2", + "slateblue3", "slateblue4", "slategray", "slategray1", "slategray2", + "slategray3", "slategray4", "slategrey", "snow", "snow1", "snow2", "snow3", + "snow4", "springgreen", "springgreen1", "springgreen2", "springgreen3", + "springgreen4", "steelblue", "steelblue1", "steelblue2", "steelblue3", + "steelblue4", "tan", "tan1", "tan2", "tan3", "tan4", "thistle", "thistle1", + "thistle2", "thistle3", "thistle4", "tomato", "tomato1", "tomato2", + "tomato3", "tomato4", "transparent", "turquoise", "turquoise1", "turquoise2", + "turquoise3", "turquoise4", "violet", "violetred", "violetred1", + "violetred2", "violetred3", "violetred4", "wheat", "wheat1", "wheat2", + "wheat3", "wheat4", "white", "whitesmoke", "yellow", "yellow1", "yellow2", + "yellow3", "yellow4", "yellowgreen"]); + BindGlobal("GV_IsValidRGBColor", function(str) local valid, i; @@ -494,38 +584,3 @@ function(gv, colors) fi; Perform(colors, ErrorIfNotValidColor); end); - -InstallGlobalFunction(GV_ErrorIfNotValidLabel, -function(label) - local cond; - - if Length(label) = 0 then - ErrorFormatted("invalid label \"{}\", valid DOT labels ", - "cannot be empty strings", label); - fi; - - # double quoted string - if StartsWith(label, "\"") and EndsWith(label, "\"")then - return; - fi; - # HTML string - if StartsWith(label, "<") and EndsWith(label, ">")then - return; - fi; - - # numeral - if Int(label) <> fail then - return; - fi; - - cond := not IsDigitChar(label[1]); - cond := cond and ForAll(label, c -> IsAlphaChar(c) or IsDigitChar(c) - or c = '_' or ('\200' <= c and c <= '\377')); - if cond then - return; - fi; - - ErrorFormatted("invalid label \"{}\", valid DOT labels ", - "https://graphviz.org/doc/info/lang.html", - label); -end); diff --git a/tst/graph.tst b/tst/graph.tst index c8a36b2..6eba0ac 100644 --- a/tst/graph.tst +++ b/tst/graph.tst @@ -52,15 +52,6 @@ gap> GraphvizAddNode(g, "x"); gap> GraphvizNodes(g); rec( n := , x := ) -# Test has nodes -gap> g := GraphvizGraph();; -gap> n := GraphvizAddNode(g, "n"); - -gap> GV_HasNode(g, "n"); -true -gap> GV_HasNode(g, "x"); -false - # Test adding edges gap> g := GraphvizGraph();; gap> a := GraphvizAddNode(g, "a");;