Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ATTRIBUTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ Vendored WordPerfect-family test files. Per-file provenance (upstream path, revi
- **License:** CDLA-Permissive-1.0
- **Used here:** 2 financial-report pages (`images/doclaynet_page_01..02.jpg`) from the `test` split (`NASDAQ_ATRI_2003.pdf` p24, `NYSE_MGM_2004.pdf` p49).
- **Modifications:** authoritative PDF text cells linearized in reading order (top-to-bottom, then left-to-right). No OCR and no model used; text is DocLayNet's verbatim PDF-layer cell text.

## Diagram fixtures (this repository)

- **Source:** authored here, not derived from any third-party dataset.
- **License:** same as this repository.
- **Used here:** `diagrams/*.svg` plus their `diagrams/src/*.dot` sources and `ground_truth/dot/*.dot`.
- **Modifications:** four SVGs are rendered from the committed `.dot` sources with Graphviz 15.1.1 (`dot`/`neato`), which is EPL-1.0 licensed; its output is not a derivative of the tool. `nested_transforms.svg` is hand-written. Ground truth is the source graph restated by node label, so it is independent of any recogniser's numbering.
61 changes: 61 additions & 0 deletions diagrams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Diagram fixtures

Vector diagrams for node/edge recovery (xberg-io/xberg#579). A vector diagram
carries its own graph, so recovery from one is exact rather than probabilistic,
and these fixtures are what say whether it actually is.

## Why generated, not hand-drawn

Hand-written SVG exercises almost none of what a real diagram tool emits. The
four SVGs already in `xml/` have no transform chain, no arrowheads, no double
borders and no curved connectors, and a recogniser can pass all four while being
wrong about every file a user would actually bring.

Rendering a known graph through Graphviz fixes that, and it also gives ground
truth for free: the source `.dot` **is** the correct answer, so the corpus
measures recovery rather than freezing whatever it currently produces.

## Layout

| file | exercises |
|---|---|
| `graphviz_flow.svg` | box, diamond and ellipse nodes; arrowheads; edge labels; a dashed edge; root `translate` with negative coordinates |
| `graphviz_states.svg` | `doublecircle` (one node drawn as two concentric outlines); a pair of antiparallel edges between adjacent nodes |
| `graphviz_network.svg` | undirected `--` edges, so no arrowhead anywhere; `neato` layout |
| `graphviz_bidirectional.svg` | `dir=both` and `dir=back` |
| `nested_transforms.svg` | hand-authored: nested `translate`/`scale` groups plus a viewBox that differs from the viewport, so nothing sits at the coordinate it is written at |
| `src/*.dot` | the Graphviz sources, so every SVG above is regenerable |

`ground_truth/dot/<stem>.dot` holds the graph each fixture draws, keyed by node
label rather than by generated id so it does not depend on any one recogniser's
numbering. Two entries are deliberately empty, `data_dashboard` and
`simple_svg`: those files are a bar chart and a two-shape drawing, they are not
diagrams, and recovering a graph from either would be a false positive.

Ground truth also covers `xml/org_chart.svg` and `xml/flowchart.svg`, which stay
where they are.

## Regenerate

```
brew install graphviz # or apt-get install graphviz
cd diagrams/src
for f in graphviz_flow graphviz_states graphviz_bidirectional; do
dot -Tsvg "$f.dot" -o "../$f.svg"
done
neato -Tsvg graphviz_network.dot -o ../graphviz_network.svg
```

Output is stable for a given Graphviz version. This was built with 15.1.1;
a different version may lay the graphs out differently, which changes
coordinates but not the graph, and the ground truth is written in terms of the
graph.

`nested_transforms.svg` is hand-authored and is not regenerated.

## Not included

A vector PDF of the same graph (`dot -Tpdf`) would exercise the PDF path, but
`*.pdf` is excluded from git here and lives in the corpus bucket, so it has to
go through `scripts/publish_corpus.py`. Happy to supply the file for a
maintainer to publish.
50 changes: 50 additions & 0 deletions diagrams/graphviz_bidirectional.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions diagrams/graphviz_flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions diagrams/graphviz_network.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions diagrams/graphviz_states.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions diagrams/nested_transforms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions diagrams/src/graphviz_bidirectional.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
digraph graphviz_bidirectional {
rankdir=LR;
node [shape=box style=filled fillcolor="#fdb462"];
api [label="API"];
db [label="Database"];
cache [label="Cache"];
api -> db [dir=both];
api -> cache;
cache -> db [dir=back];
}
11 changes: 11 additions & 0 deletions diagrams/src/graphviz_flow.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
digraph graphviz_flow {
rankdir=TB;
a [label="Start" shape=box style=filled fillcolor="#a6cee3"];
b [label="Validate" shape=diamond style=filled fillcolor="#b2df8a"];
c [label="Process" shape=box style=filled fillcolor="#fb9a99"];
d [label="Done" shape=ellipse style=filled fillcolor="#fdbf6f"];
a -> b;
b -> c [label="ok"];
b -> d [label="skip" style=dashed];
c -> d;
}
13 changes: 13 additions & 0 deletions diagrams/src/graphviz_network.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
graph graphviz_network {
layout=neato;
node [shape=ellipse style=filled fillcolor="#cccccc"];
gw [label="Gateway" fillcolor="#8dd3c7"];
s1 [label="Switch A" fillcolor="#ffffb3"];
s2 [label="Switch B" fillcolor="#ffffb3"];
h1 [label="Host 1"];
h2 [label="Host 2"];
gw -- s1;
gw -- s2;
s1 -- h1;
s2 -- h2;
}
Loading