8.5 Graph Functions

► |  | Mr Lib: Extra GUI Libraries

1 | Aligned Pasteboard
2 | Arrow Toggle Snip
3 | Bitmap Label
4 | Cache-image Snip
5 | Close Icon
6 | Expandable Snip
7 | GIF and Animated GIF Writing
8 | Graphs
9 | Hierarchical List Control
10 | Include Bitmap
11 | Interactive Value Port
12 | Name Message
13 | Path Dialog
14 | Plot
15 | Switchable Button
16 | Image Core
17 | Matrix Snip
18 | Snip Canvases
19 | Syntax Browser
20 | Te X Table
21 | Terminal Window
22 | White on Black Panel Predicate
23 | Acknowledgments
| Index

▼ | 8 | Graphs

8.1 | graph-pasteboard<%>
8.2 | graph-pasteboard-mixin
8.3 | graph-snip<%>
8.4 | graph-snip-mixin
8.5 | Graph Functions

On this page:

add-links
add-links/ text-colors
remove-links
set-link-label
dot-positioning
find-dot
dot-label
neato-label
neato-hier-label
neato-ipsep-label

Racket
top contents ← prev up next →

### 8.5 Graph Functions🔗ℹ

> procedure (add-links parent child) → void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> (add-links parent child) → void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> (add-links |  | parent |  |  |  |
> |  | child |  |  |  |
> |  | dark-pen |  |  |  |
> |  | light-pen |  |  |  |
> |  | dark-brush |  |  |  |
> |  | light-brush |  |  |  |
> | [ | label]) |  | → |  | void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> dark-pen : (or/c (is-a?/c pen%) false/c)
> light-pen : (or/c (is-a?/c pen%) false/c)
> dark-brush : (or/c (is-a?/c brush%) false/c)
> light-brush : (or/c (is-a?/c brush%) false/c)
> label : (or/c string? false/c) = #f
> (add-links |  | parent |  |  |  |
> |  | child |  |  |  |
> |  | dark-pen |  |  |  |
> |  | light-pen |  |  |  |
> |  | dark-brush |  |  |  |
> |  | light-brush |  |  |  |
> |  | dx |  |  |  |
> |  | dy |  |  |  |
> | [ | label]) |  | → |  | void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> dark-pen : (or/c (is-a?/c pen%) false/c)
> light-pen : (or/c (is-a?/c pen%) false/c)
> dark-brush : (or/c (is-a?/c brush%) false/c)
> light-brush : (or/c (is-a?/c brush%) false/c)
> dx : real?
> dy : real?
> label : (or/c string? false/c) = #f

Connects a parent snip to a child snip within a pasteboard.

The default dark-pen/dark-brush and light-pen/light-brush are blue and purple, respectively. The dark-pen and dark-brush are used when the mouse cursor is over the snip (or a child or parent), and the light-pen and light-brush are used when the mouse cursor is not over the snip. The brush is used to draw inside the arrow head and the pen is used to draw the border of the arrowhead and the line connecting the two snips.

if label is provided and not #f, it is used as a label on the edge.

When dx and dy are provided, the are offsets for the head and the tail of the arrow. Otherwise, 0 offsets are used.

> > procedure
> > (add-links/text-colors |  | parent |  |  |  |
> > |  | child |  |  |  |
> > |  | dark-pen |  |  |  |
> > |  | light-pen |  |  |  |
> > |  | dark-brush |  |  |  |
> > |  | light-brush |  |  |  |
> > |  | dark-text |  |  |  |
> > |  | light-text |  |  |  |
> > |  | dx |  |  |  |
> > |  | dy |  |  |  |
> > |  | label) |  | → |  | void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> dark-pen : (or/c (is-a?/c pen%) false/c)
> light-pen : (or/c (is-a?/c pen%) false/c)
> dark-brush : (or/c (is-a?/c brush%) false/c)
> light-brush : (or/c (is-a?/c brush%) false/c)
> dark-text : (or/c (is-a?/c color%) false/c)
> light-text : (or/c (is-a?/c color%) false/c)
> dx : real?
> dy : real?
> label : (or/c string? false/c)

Like add-links, but with extra dark-text and light-text arguments to set the colors of the label.

> procedure (remove-links parent child) → void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)

Disconnects a parent snip from a child snip within a pasteboard.

> procedure (set-link-label parent child label) → void?
> parent : (is-a?/c graph-snip<%>)
> child : (is-a?/c graph-snip<%>)
> label : (or/c string? false/c)

Changes the label on the edge going from child to parent to be label. If there is no existing edge between the two nodes, then nothing happens.

> > procedure
> > (dot-positioning |  | pb |  |  |  |
> > | [ | option |  |  |  |
> > |  | overlap-or-horizontal?]) |  | → |  | void?
> pb : (is-a?/c pasteboard%)
> | option |  | : |  | (or/c dot-label neato-label neato-hier-label neato-ipsep-label)
> |  |  | = |  | dot-label
> overlap-or-horizontal? : boolean? = #f

This finds the sizes of the graph-snip<%>s in pb and their children and then passes that information to dot or neato (depending on option), extracting a layout and then applying it to the snips in pb.

If option is dot-label, then overlap-or-horizontal? controls whether dot uses a horizontal or vertical alignment. If option is any of the other options, it controls whether or not neato is allowed to overlap nodes.

If find-dot returns #f, this function does nothing.

> procedure (find-dot [neato?]) → (or/c path? #f)
> neato? : boolean? = #f

Tries to find the dot or neato binary and, if it succeeds, returns the path to it. If it cannot find it, returns #f.

> value dot-label : string?

A string describing the regular dot option for graph layout that dot-positioning uses.

> value neato-label : string?

A string describing the neato option for graph layout that dot-positioning uses.

> value neato-hier-label : string?

A string describing the neato hierarchical option for graph layout that dot-positioning uses.

> value neato-ipsep-label : string?

A string describing the neato ipsep option for graph layout that dot-positioning uses.
top contents ← prev up next →