Skip to content

Commit d92d66f

Browse files
Updates for the Digraphs package
1 parent 384f9c1 commit d92d66f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2213
-294
lines changed

PackageInfo.g

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#
2-
# graphviz: This package facilitates the creation of graph descriptions in the
3-
# DOT language of the Graphviz graph drawing software from GAP
4-
#
5-
# This file contains package meta data. For additional information on
6-
# the meaning and correct usage of these fields, please consult the
7-
# manual of the "Example" package as well as the comments in its
8-
# PackageInfo.g file.
9-
#
1+
#############################################################################
2+
##
3+
## PackageInfo.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
1011
SetPackageInfo(rec(
1112

1213
PackageName := "graphviz",
@@ -26,12 +27,24 @@ Persons := [
2627
PostalAddress := Concatenation("Mathematical Institute, North Haugh,",
2728
" St Andrews, Fife, KY16 9SS, Scotland"),
2829
Place := "St Andrews",
30+
Institution := "University of St Andrews"),
31+
rec(
32+
FirstNames := "Matthew",
33+
LastName := "Pancer",
34+
Email := "[email protected]",
35+
IsAuthor := true,
36+
IsMaintainer := true,
37+
PostalAddress := Concatenation("Mathematical Institute, North Haugh,",
38+
" St Andrews, Fife, KY16 9SS, Scotland"),
39+
# TODO correct? Or should be cs?
40+
Place := "St Andrews",
2941
Institution := "University of St Andrews")],
3042

3143
SourceRepository := rec(Type := "git",
3244
URL := "https://github.com/digraphs/graphviz"),
3345
IssueTrackerURL := "https://github.com/digraphs/graphviz/issues",
34-
PackageWWWHome := "TODO",
46+
PackageWWWHome := Concatenation("https://digraphs.github.io/",
47+
~.PackageName),
3548

3649
PackageInfoURL := Concatenation(~.PackageWWWHome, "PackageInfo.g"),
3750
README_URL := Concatenation(~.PackageWWWHome, "README.md"),

etc/gaplint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
4+
gaplint --disable W004 $@ *.g gap/* read.g init.g PackageInfo.g makedoc.g tst/testall.g tst/*.tst tst/examples/*.tst

etc/tst-local-vars.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This simple script adds the local variables used in a GAP tst file to the top
4+
of the file.
5+
"""
6+
import os
7+
import re
8+
import sys
9+
import textwrap
10+
11+
import yaml
12+
from bs4 import BeautifulSoup
13+
14+
15+
def main():
16+
if sys.version_info[0] < 3:
17+
raise Exception("Python 3 is required")
18+
args = sys.argv[1:]
19+
pattern1 = re.compile(r"(\w+)\s*:=")
20+
pattern2 = re.compile(r"for (\w+) in")
21+
for fname in args:
22+
lvars = []
23+
with open(fname, "r") as f:
24+
lines = f.read()
25+
lvars.extend([x.group(1) for x in re.finditer(pattern1, lines)])
26+
lvars.extend([x.group(1) for x in re.finditer(pattern2, lines)])
27+
lvars = ", ".join(sorted([*{*lvars}]))
28+
lvars = [x if x[-1] != "," else x[:-1] for x in textwrap.wrap(lvars, width=72)]
29+
lvars = [""] + ["#@local " + x for x in lvars]
30+
lines = lines.split("\n")
31+
pos = next(i for i in range(len(lines)) if "START_TEST" in lines[i])
32+
lines = lines[:pos] + lvars + lines[pos:]
33+
lines = "\n".join(lines)
34+
with open(fname, "w") as f:
35+
print(f"Writing local variables to {fname}...")
36+
f.write(lines)
37+
38+
39+
if __name__ == "__main__":
40+
main()

examples/angles.gi examples/angles.g

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#############################################################################
2+
##
3+
## angles.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
212
# https://www.graphviz.org/Gallery/gradient/angles.html
313

@@ -21,7 +31,7 @@ for pair in pairs do
2131
od;
2232
GraphvizSetAttr(cluster1,
2333
"label",
24-
"\"Linear Angle Variations (white to black gradient)\"");
34+
"Linear Angle Variations (white to black gradient)");
2535

2636
cluster2 := GraphvizAddSubgraph(g, "cluster_2");
2737
GraphvizSetAttr(cluster2, "fontcolor", "white");
@@ -38,7 +48,9 @@ for pair in pairs do
3848
pair[1], pair[2]));
3949
od;
4050
GraphvizSetAttr(cluster2, "label",
41-
"\"Radial Angle Variations (white to black gradient)\"");
51+
"Radial Angle Variations (white to black gradient)");
4252

4353
GraphvizAddEdge(g, "n5", "n14");
44-
Print(AsString(g), "\n");
54+
Print(AsString(g));
55+
Splash(g);
56+
QUIT;

examples/btree.g

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#############################################################################
2+
##
3+
## btree.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
11+
# https://graphviz.readthedocs.io/en/stable/examples.html
12+
# https://graphviz.org/Gallery/directed/unix.html
13+
LoadPackage("graphviz");
14+
15+
s := GraphvizDigraph("g");
16+
GraphvizSetAttr(s, "node [shape=record, height=.1]");
17+
18+
GraphvizSetAttr(GraphvizAddNode(s, "node0"), "label", "<f0> |<f1> G|<f2>");
19+
GraphvizSetAttr(GraphvizAddNode(s, "node1"), "label", "<f0> |<f1> E|<f2>");
20+
GraphvizSetAttr(GraphvizAddNode(s, "node2"), "label", "<f0> |<f1> B|<f2>");
21+
GraphvizSetAttr(GraphvizAddNode(s, "node3"), "label", "<f0> |<f1> F|<f2>");
22+
GraphvizSetAttr(GraphvizAddNode(s, "node4"), "label", "<f0> |<f1> R|<f2>");
23+
GraphvizSetAttr(GraphvizAddNode(s, "node5"), "label", "<f0> |<f1> H|<f2>");
24+
GraphvizSetAttr(GraphvizAddNode(s, "node6"), "label", "<f0> |<f1> Y|<f2>");
25+
GraphvizSetAttr(GraphvizAddNode(s, "node7"), "label", "<f0> |<f1> A|<f2>");
26+
GraphvizSetAttr(GraphvizAddNode(s, "node8"), "label", "<f0> |<f1> C|<f2>");
27+
28+
GraphvizAddEdge(s, "node0:f2", "node4:f1");
29+
GraphvizAddEdge(s, "node0:f0", "node1:f1");
30+
GraphvizAddEdge(s, "node1:f0", "node2:f1");
31+
GraphvizAddEdge(s, "node1:f2", "node3:f1");
32+
GraphvizAddEdge(s, "node2:f2", "node8:f1");
33+
GraphvizAddEdge(s, "node2:f0", "node7:f1");
34+
GraphvizAddEdge(s, "node4:f2", "node6:f1");
35+
GraphvizAddEdge(s, "node4:f0", "node5:f1");
36+
37+
Print(AsString(s));
38+
Splash(s);
39+
QUIT;

examples/btree.gi

-27
This file was deleted.

examples/cluster.gi examples/cluster.g

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#############################################################################
2+
##
3+
## cluster.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
212
LoadPackage("graphviz");
313
graph := GraphvizDigraph("G");
@@ -31,3 +41,5 @@ GraphvizSetAttr(graph["start"], "shape", "Mdiamond");
3141
GraphvizSetAttr(graph["end"], "shape", "Msquare");
3242

3343
Print(AsString(graph));
44+
Splash(graph);
45+
QUIT;

examples/cluster_edge.gi examples/cluster_edge.g

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
#############################################################################
2+
##
3+
## cluster_edge.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
2-
# """https://www.graphviz.org/pdf/dotguide.pdf, Figure 20"""
12+
# https://www.graphviz.org/pdf/dotguide.pdf, Figure 20
313

414
LoadPackage("graphviz");
515

@@ -28,4 +38,5 @@ GraphvizSetAttr(e, "ltail", "cluster0");
2838

2939
GraphvizAddEdge(g, "d", "h");
3040

31-
Print(AsString(g));
41+
Splash(g);
42+
QUIT;

examples/colors.g

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#############################################################################
2+
##
3+
## colors.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
11+
# https://graphviz.readthedocs.io/en/stable/examples.html
12+
# https://graphviz.org/docs/attr-types/color
13+
14+
LoadPackage("graphviz");
15+
g := GraphvizGraph();
16+
17+
node := GraphvizAddNode(g, "RGB: #40e0d0");
18+
GraphvizSetAttr(node, "style", "filled");
19+
GraphvizSetAttr(node, "fillcolor", "\"#40e0d0\"");
20+
21+
node := GraphvizAddNode(g, "RGBA: #ff000042");
22+
GraphvizSetAttr(node, "style", "filled");
23+
GraphvizSetAttr(node, "fillcolor", "\"#ff000042\"");
24+
25+
node := GraphvizAddNode(g, "HSV: 0.051 0.718 0.627");
26+
GraphvizSetAttr(node, "style", "filled");
27+
GraphvizSetAttr(node, "fillcolor", "0.051 0.718 0.627");
28+
29+
node := GraphvizAddNode(g, "name: deeppink");
30+
GraphvizSetAttr(node, "style", "filled");
31+
GraphvizSetAttr(node, "fillcolor", "deeppink");
32+
33+
Print(AsString(g));
34+
Splash(g);
35+
QUIT;

examples/colors.gi

-23
This file was deleted.

examples/er.gi examples/er.g

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
#############################################################################
2+
##
3+
## er.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
2-
# """https://graphviz.org/Gallery/undirected/ER.html"""
12+
# https://graphviz.org/Gallery/undirected/ER.html
313
LoadPackage("graphviz");
414
e := GraphvizGraph("ER");
515
GraphvizSetAttr(e, "engine=\"neato\"");
@@ -49,3 +59,5 @@ GraphvizSetAttr(e, "label=\"Entity Relation Diagram\ndrawn by NEATO\"");
4959
GraphvizSetAttr(e, "fontsize=\"20\"");
5060

5161
Print(AsString(e));
62+
Splash(e);
63+
QUIT;

examples/fsm.gi examples/fsm.g

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
#############################################################################
2+
##
3+
## fsm.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
2-
# """https://graphviz.org/Gallery/directed/fsm.html"""
12+
# https://graphviz.org/Gallery/directed/fsm.html
313
LoadPackage("graphviz");
414

515
f := GraphvizDigraph("finite_state_machine");
@@ -31,3 +41,5 @@ GraphvizSetAttr(GraphvizAddEdge(nodes, "LR_8", "LR_6"), "label", "\"S(b)\"");
3141
GraphvizSetAttr(GraphvizAddEdge(nodes, "LR_8", "LR_5"), "label", "\"S(a)\"");
3242

3343
Print(AsString(f));
44+
Splash(f);
45+
QUIT;

examples/g_c_n.gi examples/g_c_n.g

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
#############################################################################
2+
##
3+
## g_c_n.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
111
# https://graphviz.readthedocs.io/en/stable/examples.html
2-
# """https://www.graphviz.org/Gallery/gradient/g_c_n.html"""
12+
# https://www.graphviz.org/Gallery/gradient/g_c_n.html
313

414
LoadPackage("graphviz");
515

@@ -16,3 +26,5 @@ GraphvizSetAttr(cluster1, Concatenation(
1626
GraphvizAddNode(cluster1, "anode");
1727

1828
Print(AsString(g));
29+
Splash(g);
30+
QUIT;

examples/hello.g

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#############################################################################
2+
##
3+
## hello.g
4+
## Copyright (C) 2024 Matthew Pancer
5+
##
6+
## Licensing information can be found in the README file of this package.
7+
##
8+
#############################################################################
9+
##
10+
11+
# https://graphviz.readthedocs.io/en/stable/examples.html
12+
LoadPackage("graphviz");
13+
graph := GraphvizDigraph("G");
14+
GraphvizAddEdge(graph, "hello", "world");
15+
Print(AsString(graph));
16+
Splash(graph);
17+
QUIT;

examples/hello.gi

-6
This file was deleted.

0 commit comments

Comments
 (0)