graph-easy 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
graph_easy/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """graph-easy — a Python port of Graph::Easy (GPL-2.0-or-later).
2
+
3
+ Port of Graph::Easy (c) Tels, 2004-2008, <http://bloodgate.com/>.
4
+ """
5
+
6
+ from graph_easy.parser import Edge, Graph, parse_graph
7
+ from graph_easy.render import render
8
+
9
+ __version__ = "0.0.1"
10
+ __all__ = ["Edge", "Graph", "parse_graph", "render", "__version__"]
graph_easy/cli.py ADDED
@@ -0,0 +1,56 @@
1
+ """Command-line entry point — read graph DSL on stdin, print ASCII art."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from graph_easy.parser import parse_graph
9
+ from graph_easy.render import render
10
+
11
+
12
+ def main(argv: list[str] | None = None) -> int:
13
+ ap = argparse.ArgumentParser(
14
+ prog="graph-easy",
15
+ description="Layout and render a graph as ASCII art (Python port of Graph::Easy).",
16
+ )
17
+ ap.add_argument(
18
+ "file",
19
+ nargs="?",
20
+ help="read DSL from FILE instead of stdin ('-' = stdin)",
21
+ )
22
+ ap.add_argument(
23
+ "--ascii",
24
+ action="store_true",
25
+ help="use plain ASCII box/line characters (default: Unicode)",
26
+ )
27
+ ap.add_argument(
28
+ "--color",
29
+ action="store_true",
30
+ help="apply ANSI colours from fill/color attributes",
31
+ )
32
+ ap.add_argument(
33
+ "--no-color",
34
+ dest="color",
35
+ action="store_false",
36
+ help="disable ANSI colours (default when output is piped)",
37
+ )
38
+ ap.set_defaults(color=None)
39
+ args = ap.parse_args(argv)
40
+
41
+ if args.file and args.file != "-":
42
+ with open(args.file, encoding="utf-8") as fh:
43
+ text = fh.read()
44
+ else:
45
+ text = sys.stdin.read()
46
+
47
+ if args.color is None:
48
+ args.color = sys.stdout.isatty()
49
+ graph = parse_graph(text)
50
+ output = render(graph, ascii_style=args.ascii, color=args.color)
51
+ sys.stdout.write(output + "\n")
52
+ return 0
53
+
54
+
55
+ if __name__ == "__main__":
56
+ raise SystemExit(main())
graph_easy/node.py ADDED
@@ -0,0 +1,60 @@
1
+ """Graph::Easy node model — a labelled text box drawn in ASCII.
2
+
3
+ Faithful Python port of ``Graph::Easy::Node`` dimensions/label semantics.
4
+ A node knows its multi-line label and computes its own rendered box size;
5
+ drawing is delegated to the renderer (``graph_easy.render``).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass, field
11
+
12
+
13
+ @dataclass
14
+ class Node:
15
+ """A rectangular labelled node.
16
+
17
+ Mirrors the upstream notion that a node's box encloses a (possibly
18
+ multi-line) label with a one-cell padding border on every side, drawn as
19
+ boxes (`+---+`-style corners with `|` and `-` edges).
20
+
21
+ Columns are counted in *display cells*; a label line never shrinks the box
22
+ below its widest line.
23
+ """
24
+
25
+ label: str
26
+ attr_label: str | None = None
27
+ padding_x: int = 1
28
+ padding_y: int = 0
29
+ _width: int = 0
30
+ _height: int = 0
31
+ shape: str = "normal"
32
+ attrs: dict[str, str] = field(default_factory=dict)
33
+
34
+ def label_lines(self) -> list[str]:
35
+ """Split the label into display lines; `\\n` escapes expand to newlines."""
36
+ src = self.attr_label if self.attr_label is not None else self.label
37
+ return src.replace(r"\n", "\n").split("\n")
38
+
39
+ def inner_width(self) -> int:
40
+ """Width of the label area in cells (widest line, >= 1)."""
41
+ lines = self.label_lines()
42
+ if not lines:
43
+ return 1
44
+ return max(len(line) for line in lines) or 1
45
+
46
+ def inner_height(self) -> int:
47
+ return max(len(self.label_lines()), 1)
48
+
49
+ def width(self) -> int:
50
+ """Total box width = 2 borders + padding_x*2 + inner_width."""
51
+ return 2 + self.padding_x * 2 + self.inner_width()
52
+
53
+ def height(self) -> int:
54
+ """Total box height = 2 borders + padding_y*2 + inner_height."""
55
+ return 2 + self.padding_y * 2 + self.inner_height()
56
+
57
+ def recompute(self) -> None:
58
+ """Recompute cached extents after label mutation (upstream api)."""
59
+ self._width = self.width()
60
+ self._height = self.height()
graph_easy/parser.py ADDED
@@ -0,0 +1,216 @@
1
+ """Graph::Easy DSL parser — text graph language.
2
+
3
+ Faithful translation of the upstream grammar subset::
4
+
5
+ [ node label ] --> [ other node ]
6
+ A -> B <- C
7
+ [ A ] -- label width 40 --> [ B ]
8
+
9
+ Supported tokens (subset of upstream ``Parser``)::
10
+
11
+ node := '[' label ']' | bare_word
12
+ edge := '<'? connector '>'? with connector = one+ of '-' '=' '.'
13
+
14
+ "--" undirected "-->" directed to target
15
+ "<--" directed from target "<-->" bidirectional
16
+
17
+ Arbitrary repeated dashes (``--->``, ``<----`` ...) are tolerated.
18
+ Comment lines (``# ...``) are ignored.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import re
24
+ from dataclasses import dataclass, field
25
+
26
+ from graph_easy.node import Node
27
+
28
+ _TOK = re.compile(
29
+ r"\s*"
30
+ r"(?:"
31
+ r"(\[[^\]]*\])" # 1: bracketed node
32
+ r"|(<[=.\-~#]*[=.\-~#]>?)" # 2: edge with leading '<'
33
+ r"|([=.\-~#]*[=.\-~#]>?)" # 3: edge without '<'
34
+ r"|(\{[^{}]*\})" # 4: attribute block { k: v; }
35
+ r"|([()])" # 5: group open/close
36
+ r"|([^\s]+)" # 6: bare word
37
+ r")"
38
+ )
39
+
40
+
41
+ def _parse_attrs(block: str) -> dict[str, str]:
42
+ """Parse ``{ key: value; key2: value2; }`` into a dict (lenient)."""
43
+ attrs: dict[str, str] = {}
44
+ for part in block.strip("{}").split(";"):
45
+ if ":" not in part:
46
+ continue
47
+ k, _, v = part.partition(":")
48
+ k = k.strip()
49
+ v = v.strip()
50
+ if k:
51
+ attrs[k] = v
52
+ return attrs
53
+
54
+
55
+ @dataclass
56
+ class Edge:
57
+ """Directed/undirected connection between two nodes."""
58
+
59
+ source: str
60
+ target: str
61
+ label: str | None = None
62
+ directed_to_target: bool = True # arrow at the target ('-->')
63
+ directed_from_source: bool = False # arrow at the source ('<--')
64
+ style: str | None = None
65
+ attrs: dict[str, str] = field(default_factory=dict)
66
+
67
+
68
+ @dataclass
69
+ class Graph:
70
+ """Parsed in-memory graph."""
71
+
72
+ nodes: dict[str, Node] = field(default_factory=dict)
73
+ edges: list[Edge] = field(default_factory=list)
74
+ link_labels: list[str] = field(default_factory=list)
75
+
76
+ def add_node(self, label: str) -> Node:
77
+ if label not in self.nodes:
78
+ self.nodes[label] = Node(label=label)
79
+ return self.nodes[label]
80
+
81
+
82
+ _LABELLED_EDGE = re.compile(
83
+ r"\s*(?P<style1>[-=.]+)\s+(?P<label>[^{<>\s][^<>\n]*?)\s+"
84
+ r"(?P<style2>[-=.]+)(?P<after>>)?"
85
+ )
86
+
87
+
88
+ def _tokens(line: str) -> list[tuple[str, str]]:
89
+ """Tokenise one line into (kind, value) pairs: ('node'|'edge', text).
90
+
91
+ An edge written ``-- label -->`` yields an ``edge`` token immediately
92
+ followed by a ``label`` token; ``_stitch`` attaches the label to the edge.
93
+ """
94
+ out: list[tuple[str, str]] = []
95
+ pos = 0
96
+ while pos < len(line):
97
+ m = _TOK.match(line, pos)
98
+ if not m:
99
+ pos += 1
100
+ continue
101
+ pos = m.end()
102
+ if m.group(2) is not None or m.group(3) is not None:
103
+ op = m.group(2) or m.group(3)
104
+ le = _LABELLED_EDGE.match(line, m.start())
105
+ if le:
106
+ out.append(("edge", op))
107
+ out.append(("label", le.group("label")))
108
+ pos = le.end()
109
+ else:
110
+ out.append(("edge", op))
111
+ elif m.group(1) is not None:
112
+ out.append(("node", m.group(1)[1:-1].strip()))
113
+ elif m.group(4) is not None:
114
+ out.append(("attr", m.group(4)))
115
+ elif m.group(5) is not None:
116
+ if m.group(5) == "(":
117
+ out.append(("group_open", ""))
118
+ else:
119
+ out.append(("group_close", ""))
120
+ else:
121
+ out.append(("node", m.group(6)))
122
+ return out
123
+
124
+
125
+ def _edge_style(op: str) -> str | None:
126
+ """Map a connector string to a style name (upstream Parser::_edge_style)."""
127
+ if re.fullmatch(r"=+", op):
128
+ return "double"
129
+ if re.fullmatch(r"\.+", op):
130
+ return "dotted"
131
+ if re.fullmatch(r"~+", op):
132
+ return "wave"
133
+ if re.fullmatch(r"#+", op):
134
+ return "bold"
135
+ if re.fullmatch(r"(\.-)+", op):
136
+ return "dot-dash"
137
+ if re.fullmatch(r"(\.\.-)+", op):
138
+ return "dot-dot-dash"
139
+ return None
140
+
141
+
142
+ def _stitch(g: Graph, tokens: list[tuple[str, str]]) -> None:
143
+ """Turn a token stream (node edge node edge ...) into edges on ``g``.
144
+
145
+ Attribute blocks ``{ k: v; }`` attach to the most recent object: the
146
+ pending edge when one is open (``-- { a } -->``), else the last node.
147
+ """
148
+ prev: str | None = None
149
+ pending_op: str | None = None
150
+ pending_label: str | None = None
151
+ pending_attrs: dict[str, str] = {}
152
+ group_name: str | None = None
153
+ expect_group_name = False
154
+ i = 0
155
+ while i < len(tokens):
156
+ kind, value = tokens[i]
157
+ if kind == "group_open":
158
+ expect_group_name = True
159
+ i += 1
160
+ continue
161
+ if kind == "group_close":
162
+ group_name = None
163
+ expect_group_name = False
164
+ i += 1
165
+ continue
166
+ if kind == "label":
167
+ pending_label = value
168
+ i += 1
169
+ continue
170
+ if kind == "edge":
171
+ pending_op = value
172
+ i += 1
173
+ continue
174
+ if kind == "attr":
175
+ if pending_op is None:
176
+ if prev is not None:
177
+ g.nodes[prev].attrs.update(_parse_attrs(value))
178
+ else:
179
+ pending_attrs.update(_parse_attrs(value))
180
+ i += 1
181
+ continue
182
+ if expect_group_name and group_name is None:
183
+ group_name = value
184
+ expect_group_name = False
185
+ i += 1
186
+ continue
187
+ g.add_node(value)
188
+ if group_name is not None:
189
+ g.nodes[value].attrs["group"] = group_name
190
+ if pending_op is not None and prev is not None:
191
+ e = Edge(source=prev, target=value)
192
+ e.directed_to_target = pending_op.endswith(">")
193
+ e.directed_from_source = pending_op.startswith("<")
194
+ e.label = pending_label
195
+ e.style = _edge_style(pending_op.strip("<>"))
196
+ e.attrs = dict(pending_attrs)
197
+ g.edges.append(e)
198
+ elif pending_attrs:
199
+ g.nodes[value].attrs.update(pending_attrs)
200
+ pending_op = None
201
+ pending_label = None
202
+ pending_attrs = {}
203
+ prev = value
204
+ i += 1
205
+
206
+
207
+ def parse_graph(text: str, *, link_as_default_label: bool = False) -> Graph:
208
+ """Parse graph DSL text into a :class:`Graph`."""
209
+
210
+ g = Graph()
211
+ for raw in text.splitlines():
212
+ line = raw.strip()
213
+ if not line or line.startswith("#"):
214
+ continue
215
+ _stitch(g, _tokens(line))
216
+ return g
graph_easy/render.py ADDED
@@ -0,0 +1,377 @@
1
+ """ASCII renderer — draw parsed graphs as terminal box-and-wire diagrams.
2
+
3
+ Port of the visual semantics of ``Graph::Easy::As_ascii`` for the supported
4
+ subset, laid out on a character canvas:
5
+
6
+ * nodes are boxed and grouped into horizontal layers (longest-path layering)
7
+ * within a layer, nodes stack vertically
8
+ * edges connect layers with arrows; the connector style selects the line
9
+ characters (``--`` solid, ``..`` dotted, ``==`` double, ``~~`` wave,
10
+ ``##`` bold); vertical runs and arrowheads follow the same style.
11
+
12
+ Independent components render as separate stacked diagrams.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from collections import deque
18
+
19
+ from graph_easy.node import Node
20
+ from graph_easy.parser import Edge, Graph
21
+
22
+ _CHANNEL = 9
23
+
24
+ _BoxChars = tuple[str, str, str, str, str, str] # tl, tr, bl, br, v, h
25
+
26
+ _BOX_UNICODE: _BoxChars = ("┌", "┐", "└", "┘", "│", "─")
27
+ _BOX_ASCII: _BoxChars = ("+", "+", "+", "+", "|", "-")
28
+
29
+ _STYLE_UNICODE: dict[str, tuple[str, str, str]] = {
30
+ "solid": ("─", "│", "┼"),
31
+ "double": ("═", "║", "╬"),
32
+ "dotted": ("·", ":", "┼"),
33
+ "dashed": ("╴", "╵", "┼"),
34
+ "wave": ("∼", "≀", "┼"),
35
+ "bold": ("━", "┃", "╋"),
36
+ "dot-dash": ("·", "!", "┼"),
37
+ "dot-dot-dash": ("·", "!", "┼"),
38
+ }
39
+ _STYLE_ASCII: dict[str, tuple[str, str, str]] = {
40
+ "solid": ("-", "|", "+"),
41
+ "double": ("=", '"', "#"),
42
+ "dotted": (".", ":", "+"),
43
+ "dashed": ("-", "'", "+"),
44
+ "wave": ("~", "~", "~"),
45
+ "bold": ("#", "#", "#"),
46
+ "dot-dash": (".", ":", "+"),
47
+ "dot-dot-dash": (".", ":", "+"),
48
+ }
49
+ _STYLE_DEFAULT = "solid"
50
+
51
+ # ANSI colour table — the 16 standard terminal colours plus common names.
52
+ _ANSI_FG: dict[str, str] = {
53
+ "black": "30", "red": "31", "green": "32", "yellow": "33",
54
+ "blue": "34", "magenta": "35", "cyan": "36", "white": "37",
55
+ "brightred": "91", "brightgreen": "92", "brightyellow": "93",
56
+ "brightblue": "94", "brightmagenta": "95", "brightcyan": "96",
57
+ "grey": "90", "gray": "90", "brightwhite": "97",
58
+ }
59
+ _ANSI_BG: dict[str, str] = {
60
+ "black": "40", "red": "41", "green": "42", "yellow": "43",
61
+ "blue": "44", "magenta": "45", "cyan": "46", "white": "47",
62
+ "brightred": "101", "brightgreen": "102", "brightyellow": "103",
63
+ "brightblue": "104", "brightmagenta": "105", "brightcyan": "106",
64
+ "grey": "100", "gray": "100", "brightwhite": "107",
65
+ }
66
+
67
+
68
+ def _ansi_fg(name: str) -> str:
69
+ return _ANSI_FG.get(name.strip().lower(), "")
70
+
71
+
72
+ def _ansi_bg(name: str) -> str:
73
+ return _ANSI_BG.get(name.strip().lower(), "")
74
+
75
+
76
+ def _apply_color(canvas: list[list[str]], pos: dict, graph: Graph) -> None:
77
+ """Post-process: wrap each node's interior rows in ANSI colour codes."""
78
+ for name, (x0, y0, w, h) in pos.items():
79
+ node = graph.nodes[name]
80
+ fg = _ansi_fg(node.attrs.get("color", ""))
81
+ bg = _ansi_bg(node.attrs.get("fill", ""))
82
+ codes = [c for c in (bg, fg) if c]
83
+ if not codes:
84
+ continue
85
+ start = "\x1b[" + ";".join(codes) + "m"
86
+ end = "\x1b[0m"
87
+ for r in range(1, h - 1):
88
+ row = canvas[y0 + r]
89
+ row[x0] = start + row[x0]
90
+ row[x0 + w - 1] += end
91
+
92
+
93
+ def _box(node: Node, box: _BoxChars) -> list[str]:
94
+ """Render one node as a list of text rows (top border .. bottom border).
95
+
96
+ Shape/attribute aware: ``shape: diamond`` draws a rhombus, ``border:
97
+ double/dashed`` changes the frame characters.
98
+ """
99
+ tl, tr, bl, br, v, h = box
100
+ shape = node.attrs.get("shape", "normal")
101
+ border = node.attrs.get("border", "solid")
102
+ if shape == "diamond":
103
+ return _box_diamond(node, border, box)
104
+ pad_x = node.padding_x
105
+ pad_y = node.padding_y
106
+ inner_w = node.inner_width()
107
+ lines = node.label_lines()
108
+ w = node.width()
109
+ hgt = node.height()
110
+ if border == "double":
111
+ h2, v2 = "═", "║"
112
+ elif border == "dashed":
113
+ h2, v2 = "╌", "╎"
114
+ else:
115
+ h2, v2 = h, v
116
+ if shape in ("ellipse", "rounded"):
117
+ tl, tr, bl, br = "╭", "╮", "╰", "╯"
118
+ border_t = tl + h2 * (w - 2) + tr
119
+ rows: list[str] = [border_t]
120
+ for _ in range(pad_y):
121
+ rows.append(v2 + " " * (w - 2) + v2)
122
+ for line in lines:
123
+ right = max(inner_w - len(line), 0)
124
+ rows.append(v2 + " " * pad_x + line + " " * (pad_x + right) + v2)
125
+ for _ in range(pad_y):
126
+ rows.append(v2 + " " * (w - 2) + v2)
127
+ rows.append(bl + h2 * (w - 2) + br)
128
+ return rows
129
+
130
+
131
+ def _box_diamond(node: Node, border: str, box: _BoxChars) -> list[str]:
132
+ """Diamond (rhombus) node — label centered on the widest diagonal row."""
133
+ _, _, _, _, v, h = box
134
+ hch = "═" if border == "double" else h
135
+ vch = "║" if border == "double" else v
136
+ lines = node.label_lines()
137
+ inner_w = node.inner_width()
138
+ half = inner_w // 2
139
+ width = inner_w + 4
140
+ total_rows = len(lines) + 2
141
+ rows: list[str] = []
142
+ for r in range(total_rows):
143
+ if r == 0:
144
+ row = " " * (half + 1) + "/" + hch * max(inner_w - 2, 1) + "\\"
145
+ elif r == total_rows - 1:
146
+ row = " " * (half + 1) + "\\" + hch * max(inner_w - 2, 1) + "/"
147
+ else:
148
+ li = r - 1
149
+ pad = abs(half - li)
150
+ text = lines[li] if li < len(lines) else ""
151
+ left_pad = " " * (pad + 1)
152
+ right_pad = " " * (max(inner_w - len(text), 0) + pad + 1)
153
+ row = left_pad + vch + text + right_pad + vch
154
+ rows.append(row.ljust(width))
155
+ return rows
156
+
157
+
158
+ def _components(graph: Graph) -> list[list[str]]:
159
+ """Split nodes into connected components (preserving insertion order)."""
160
+ adj: dict[str, set[str]] = {n: set() for n in graph.nodes}
161
+ for e in graph.edges:
162
+ if e.source in adj and e.target in adj:
163
+ adj[e.source].add(e.target)
164
+ adj[e.target].add(e.source)
165
+ seen: set[str] = set()
166
+ comps: list[list[str]] = []
167
+ for start in graph.nodes:
168
+ if start in seen:
169
+ continue
170
+ q: deque[str] = deque([start])
171
+ cur: set[str] = set()
172
+ while q:
173
+ u = q.popleft()
174
+ if u in seen:
175
+ continue
176
+ seen.add(u)
177
+ cur.add(u)
178
+ for v in adj[u]:
179
+ if v not in seen:
180
+ q.append(v)
181
+ comps.append([n for n in graph.nodes if n in cur])
182
+ return comps
183
+
184
+
185
+ def _layers(comp: list[str], graph: Graph) -> list[list[str]]:
186
+ """Longest-path layering: rank[v] = 1 + max(rank[u]) over edges u->v."""
187
+ rank = {n: 0 for n in comp}
188
+ for _ in range(len(comp)): # longest path needs at most len-1 passes
189
+ changed = False
190
+ for e in graph.edges:
191
+ if e.source in rank and e.target in rank and rank[e.target] <= rank[e.source]:
192
+ rank[e.target] = rank[e.source] + 1
193
+ changed = True
194
+ if not changed:
195
+ break
196
+ by_rank: dict[int, list[str]] = {}
197
+ for n in comp:
198
+ by_rank.setdefault(rank[n], []).append(n)
199
+ return [by_rank[r] for r in sorted(by_rank)]
200
+
201
+
202
+ def _draw_edge(
203
+ canvas: list[list[str]],
204
+ pos: dict[str, tuple[int, int, int, int]],
205
+ edge: Edge,
206
+ styles: dict[str, tuple[str, str, str]],
207
+ *,
208
+ vertical_only: bool = False,
209
+ ) -> None:
210
+ sx0, sy0, sw, sh = pos[edge.source]
211
+ tx0, ty0, tw, th = pos[edge.target]
212
+ sx = sx0 + sw
213
+ tx = tx0
214
+ sy = sy0 + sh // 2
215
+ ty = ty0 + th // 2
216
+ cx = sx + _CHANNEL // 2
217
+
218
+ hch, vch, cch = styles.get(edge.style or _STYLE_DEFAULT)
219
+
220
+ arrowshape = edge.attrs.get("arrowshape", "")
221
+ if styles is _STYLE_ASCII:
222
+ ar, al = ">", "<"
223
+ elif arrowshape == "filled":
224
+ ar, al = "▶", "◀"
225
+ else:
226
+ ar, al = ">", "<"
227
+
228
+ def put(x: int, y: int, ch: str) -> None:
229
+ if 0 <= y < len(canvas) and 0 <= x < len(canvas[y]):
230
+ canvas[y][x] = ch
231
+
232
+ def put_cross(x: int, y: int, ch: str) -> None:
233
+ if 0 <= y < len(canvas) and 0 <= x < len(canvas[y]):
234
+ if canvas[y][x] == " ":
235
+ canvas[y][x] = ch
236
+ elif canvas[y][x] != ch:
237
+ canvas[y][x] = cch
238
+
239
+ if sy == ty:
240
+ if vertical_only:
241
+ return
242
+ if edge.label:
243
+ left = f"{hch}{hch}" if not edge.directed_from_source else f"{al}{hch}{hch}"
244
+ right = f"{hch}{hch}{ar}" if edge.directed_to_target else f"{hch}{hch}"
245
+ arrow = f"{left} {edge.label} {right}"
246
+ else:
247
+ arrow = f"{hch}{hch}{ar}" if edge.directed_to_target else f"{hch}{hch}"
248
+ if edge.directed_from_source:
249
+ arrow = al + arrow
250
+ start = sx + 1
251
+ end = tx - 1
252
+ width = end - start + 1
253
+ if width > len(arrow):
254
+ cells = [hch] * width
255
+ if arrow.startswith(al):
256
+ cells[0] = al
257
+ if arrow.endswith(ar):
258
+ cells[-1] = ar
259
+ for i, ch in enumerate(cells):
260
+ put(start + i, sy, ch)
261
+ else:
262
+ for i, ch in enumerate(arrow):
263
+ put(start + i, sy, ch)
264
+ return
265
+
266
+ # route the vertical arm from the source's bottom edge so it never
267
+ # collides with horizontal arrows leaving the source's mid row
268
+ sy = sy0 + sh - 1
269
+ lo, hi = (sy, ty) if sy < ty else (ty, sy)
270
+ if vertical_only:
271
+ for y in range(lo + 1, hi):
272
+ put_cross(cx, y, vch)
273
+ return
274
+
275
+ for x in range(sx + 1, cx):
276
+ put(x, sy, hch)
277
+ for x in range(cx, tx):
278
+ put(x, ty, hch)
279
+ if edge.directed_to_target:
280
+ put(tx - 1, ty, ar)
281
+ if edge.directed_from_source:
282
+ put(sx + 1, sy, al)
283
+ if edge.label:
284
+ mid_y = (lo + hi) // 2
285
+ for i, ch in enumerate(edge.label):
286
+ put(cx + i + 1, mid_y, ch)
287
+
288
+
289
+ def render(graph: Graph, *, ascii_style: bool = False, color: bool = False) -> str:
290
+ """Render the graph to multi-line ASCII/Unicode text (no trailing newline)."""
291
+ if not graph.nodes:
292
+ return ""
293
+ box_chars = _BOX_ASCII if ascii_style else _BOX_UNICODE
294
+ styles = _STYLE_ASCII if ascii_style else _STYLE_UNICODE
295
+ bands: list[str] = []
296
+ for comp in _components(graph):
297
+ layers = _layers(comp, graph)
298
+ layer_boxes = [[_box(graph.nodes[n], box_chars) for n in layer] for layer in layers]
299
+ col_w = [max(max(len(row) for row in b) for b in boxes) for boxes in layer_boxes]
300
+ col_h = [sum(len(b) for b in boxes) + (len(boxes) - 1) for boxes in layer_boxes]
301
+ y_offs: list[list[int]] = []
302
+ for boxes in layer_boxes:
303
+ offs: list[int] = []
304
+ y = 0
305
+ for b in boxes:
306
+ offs.append(y)
307
+ y += len(b) + 1
308
+ y_offs.append(offs)
309
+
310
+ has_groups = any(graph.nodes[n].attrs.get("group") for n in comp)
311
+ pad = 1 if has_groups else 0
312
+ height = (max(col_h) if col_h else 0) + 2 * pad
313
+ width = (sum(col_w) + _CHANNEL * (len(layers) - 1)) + 2 * pad
314
+ canvas = [[" "] * width for _ in range(height)]
315
+ pos: dict[str, tuple[int, int, int, int]] = {}
316
+ x = pad
317
+ for c, boxes in enumerate(layer_boxes):
318
+ for i, b in enumerate(boxes):
319
+ x0 = x
320
+ y0 = y_offs[c][i] + pad
321
+ for r, row in enumerate(b):
322
+ for cc, ch in enumerate(row):
323
+ canvas[y0 + r][x0 + cc] = ch
324
+ pos[layers[c][i]] = (x0, y0, len(b[0]), len(b))
325
+ x += col_w[c] + _CHANNEL
326
+
327
+ edges_in_comp = [e for e in graph.edges if e.source in pos and e.target in pos]
328
+ for e in edges_in_comp:
329
+ _draw_edge(canvas, pos, e, styles, vertical_only=True)
330
+ for e in edges_in_comp:
331
+ _draw_edge(canvas, pos, e, styles)
332
+ _draw_groups(canvas, pos, graph, box_chars)
333
+ if color:
334
+ _apply_color(canvas, pos, graph)
335
+ bands.append("\n".join("".join(row).rstrip() for row in canvas))
336
+ return "\n\n".join(bands)
337
+
338
+
339
+ def _draw_groups(
340
+ canvas: list[list[str]],
341
+ pos: dict[str, tuple[int, int, int, int]],
342
+ graph: Graph,
343
+ box: _BoxChars,
344
+ ) -> None:
345
+ """Draw a labelled dashed frame around each group's nodes."""
346
+ by_group: dict[str, list[str]] = {}
347
+ for n in graph.nodes:
348
+ grp = graph.nodes[n].attrs.get("group")
349
+ if grp and n in pos:
350
+ by_group.setdefault(grp, []).append(n)
351
+ for grp, members in by_group.items():
352
+ xs = [pos[m][0] for m in members]
353
+ ys = [pos[m][1] for m in members]
354
+ xe = [pos[m][0] + pos[m][2] for m in members]
355
+ ye = [pos[m][1] + pos[m][3] for m in members]
356
+ x0, x1 = min(xs) - 1, max(xe) + 1
357
+ y0, y1 = min(ys) - 1, max(ye) + 1
358
+ x0 = max(x0, 0)
359
+ y0 = max(y0, 0)
360
+ x1 = min(x1, len(canvas[0]) - 1)
361
+ y1 = min(y1, len(canvas) - 1)
362
+ for x in range(x0, x1 + 1):
363
+ if canvas[y0][x] == " ":
364
+ canvas[y0][x] = "─"
365
+ if canvas[y1][x] == " ":
366
+ canvas[y1][x] = "─"
367
+ for y in range(y0, y1 + 1):
368
+ if canvas[y][x0] == " ":
369
+ canvas[y][x0] = "│"
370
+ if canvas[y][x1] == " ":
371
+ canvas[y][x1] = "│"
372
+ canvas[y0][x0], canvas[y0][x1] = "┌", "┐"
373
+ canvas[y1][x0], canvas[y1][x1] = "└", "┘"
374
+ label = f" {grp} "
375
+ for i, ch in enumerate(label):
376
+ if x0 + 1 + i <= x1:
377
+ canvas[y0][x0 + 1 + i] = ch
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: graph-easy
3
+ Version: 0.0.1
4
+ Summary: A Python port of Graph::Easy - lay out and render graphs as ASCII art
5
+ Author: Tels (original Graph::Easy author)
6
+ License: GPL-2.0-or-later
7
+ Project-URL: Original, https://github.com/ironcamel/Graph-Easy
8
+ Keywords: graph,ascii,diagram,layout,graphviz
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
11
+ Classifier: Topic :: Multimedia :: Graphics
12
+ Classifier: Topic :: Utilities
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=7; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+ # graph-easy
21
+
22
+ A **Python port** of [Graph::Easy](https://github.com/ironcamel/Graph-Easy),
23
+ the Perl tool that lays out directed/undirected graphs and renders them as
24
+ **ASCII art** (box-and-wire diagrams rendered in the terminal).
25
+
26
+ This project faithfully translates the original Perl implementation to Python,
27
+ in order to provide the same functionality to Python users / as a native Python
28
+ library and command-line tool.
29
+
30
+ ## Provenance & License
31
+
32
+ - Original: **Graph::Easy**, Copyright (C) 2004 - 2008 by **Tels**
33
+ (<http://bloodgate.com/>).
34
+ - Upstream repository: <https://github.com/ironcamel/Graph-Easy>
35
+ - This port is licensed under the **GNU General Public License, version 2 or
36
+ (at your option) any later version** — the same license as the original
37
+ Graph::Easy, because a port is a derivative work.
38
+
39
+ See [`LICENSE`](./LICENSE) for the full LGPL/ GPL text.
40
+
41
+ ### Third-party color schemes
42
+
43
+ This product includes color specifications and designs developed by Cynthia
44
+ Brewer (<http://colorbrewer.org/>), used under the
45
+ Apache-Style Software License for ColorBrewer Color Schemes v1.1,
46
+ © 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
47
+ See the header of the original `Graph::Easy::Attributes` for the full notice.
48
+
49
+ ## Status
50
+
51
+ Actively-developed port. Currently implemented:
52
+
53
+ - **DSL parser**: `[ label ]`/bare nodes, `-->` `<--` `<-->` `--` arrows,
54
+ labelled edges (`-- label -->`), multiline labels (`\n`), comments
55
+ - **Layout engine**: longest-path layering with orthogonal edge routing —
56
+ chains, branches, merges and cycles all render correctly; independent
57
+ components stack as separate diagrams
58
+ - **Edge line styles** (faithful to upstream `Parser::_edge_style`):
59
+ `--` solid, `..` dotted, `==` double, `~~` wave, `##` bold, `.-`/`..-` dot-dash
60
+ - **Two output charsets**: Unicode box-drawing by default
61
+ (`┌──┐ ──> ══ ║ ·`), plain ASCII via `--ascii`
62
+
63
+ The heavier automatic layout engine (`Graph::Easy::Layout` grid solver) is a
64
+ follow-up milestone.
65
+
66
+ ## Usage
67
+
68
+ ```console
69
+ $ printf '[ Bonn ] --> [ Berlin ] --> [ Hamburg ]\n' | graph-easy
70
+ ┌──────┐ ┌────────┐ ┌─────────┐
71
+ │ Bonn │ ───────>│ Berlin │ ───────>│ Hamburg │
72
+ └──────┘ └────────┘ └─────────┘
73
+
74
+ # plain-ASCII output
75
+ $ printf '[ A ] ..> [ B ]\n' | graph-easy --ascii
76
+ +---+ +---+
77
+ | A | .......>| B |
78
+ +---+ +---+
79
+ ```
80
+
81
+ ## Development
82
+
83
+ ```console
84
+ $ python -m venv .venv && source .venv/bin/activate
85
+ $ pip install -e '.[dev]'
86
+ $ pytest
87
+ ```
88
+
89
+ ## Acknowledgments
90
+
91
+ Thanks to Tels and the Graph::Easy contributors whose careful layout and
92
+ rendering work this port builds upon.
@@ -0,0 +1,11 @@
1
+ graph_easy/__init__.py,sha256=_2HIh7t702j2VtarERwXRSwcPzMagOUIla7rk53OcT0,322
2
+ graph_easy/cli.py,sha256=16wDAKmti9l-JHYIWhUokHkwentfY2XGn_u9J6gzNdc,1513
3
+ graph_easy/node.py,sha256=nNJk61lnE7d78SrsHN6dV09knOa55PQ32vMN5BN788g,2036
4
+ graph_easy/parser.py,sha256=0_u3PAzyqlzPtBziGffVcKrk36DCjhMkVVbq5ALr52c,6635
5
+ graph_easy/render.py,sha256=Iy-GsBTJ4PtnqYT9WFhzAQd2UIV-_RJqQuAWAjggQCY,13389
6
+ graph_easy-0.0.1.dist-info/licenses/LICENSE,sha256=7a72Msu2Q-TnoiFxemxEGkwafJGObk1W3rw9hzmyM_Y,17984
7
+ graph_easy-0.0.1.dist-info/METADATA,sha256=KZonBLwebMeWHJxWJMIAv4_D_R0uoDDkj4koEimLlA4,3485
8
+ graph_easy-0.0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
9
+ graph_easy-0.0.1.dist-info/entry_points.txt,sha256=to15qxIiDoLms8qVBiEWYlFWUG0NJfqF4hM_tiqcMrw,51
10
+ graph_easy-0.0.1.dist-info/top_level.txt,sha256=PXdbO_ZlPTqVIP2paMrLxul2u1Zito6rRCDkAKKmRNY,11
11
+ graph_easy-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ graph-easy = graph_easy.cli:main
@@ -0,0 +1,338 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ <https://fsf.org/>
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, see <https://www.gnu.org/licenses/>.
308
+
309
+ Also add information on how to contact you by electronic and paper mail.
310
+
311
+ If the program is interactive, make it output a short notice like this
312
+ when it starts in an interactive mode:
313
+
314
+ Gnomovision version 69, Copyright (C) year name of author
315
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316
+ This is free software, and you are welcome to redistribute it
317
+ under certain conditions; type `show c' for details.
318
+
319
+ The hypothetical commands `show w' and `show c' should show the appropriate
320
+ parts of the General Public License. Of course, the commands you use may
321
+ be called something other than `show w' and `show c'; they could even be
322
+ mouse-clicks or menu items--whatever suits your program.
323
+
324
+ You should also get your employer (if you work as a programmer) or your
325
+ school, if any, to sign a "copyright disclaimer" for the program, if
326
+ necessary. Here is a sample; alter the names:
327
+
328
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
+
331
+ <signature of Moe Ghoul>, 1 April 1989
332
+ Moe Ghoul, President of Vice
333
+
334
+ This General Public License does not permit incorporating your program into
335
+ proprietary programs. If your program is a subroutine library, you may
336
+ consider it more useful to permit linking proprietary applications with the
337
+ library. If this is what you want to do, use the GNU Lesser General
338
+ Public License instead of this License.
@@ -0,0 +1 @@
1
+ graph_easy