Skip to content

Interface: Graph

Defined in: model/graph.ts:43

Represents an Agraph_t — a graph or subgraph.

In the C implementation Agraph_t holds n_seq/n_id (node dicts), e_seq/e_id (edge dicts), g_seq/g_id (subgraph dicts), parent, root, and a shared Agclos_t. Here we use native TypeScript collections in place of libcdt Dict_t, and the info field replaces the agbindrec / GD_* mechanism (AD-1).

Nodes are owned by the root graph. Subgraphs hold references to the same Node instances (Subgraph Ownership Semantics, cgraph.md).

See

lib/cgraph/cgraph.h:Agraph_s

Properties

anonymous

ts
readonly anonymous: boolean;

Defined in: model/graph.ts:56

True when the graph was declared with NO name (digraph {), as opposed to an explicit empty name (digraph "" {). Both store name === '', but cgraph gives the truly-anonymous root the internal id %1 (agnameof) while the empty-named one keeps "". Only the imagemap <map id/name> reads this (map.ts:mapGraphName); dot/xdot re-serialization keeps name so an anonymous root round-trips as digraph {, not digraph %1 {.

See

lib/cgraph/id.c:idmap (anon → %1) ; lib/cgraph/agraph.c:agnameof


attrs

ts
attrs: Map<string, string>;

Defined in: model/graph.ts:89

String attributes (agget/agset equivalents). Replaces the Agattr_t / Agsym_t machinery for simple key-value access.

See

lib/cgraph/cgraph.h:Agattr_s


declaredGraphAttrs

ts
declaredGraphAttrs: Set<string>;

Defined in: model/graph.ts:155

Names of graph attributes (AGRAPH) declared anywhere in this hierarchy — the port's stand-in for cgraph's Agsym_t symbol table. Populated on the ROOT only, at parse time, whenever a graph attribute is assigned on any (sub)graph: setting ordering=out on a subgraph declares "ordering" graph-wide with an empty default, so agGraphAttr(root, "ordering") returns "" (not undefined) — mirroring agfindgraphattr/late_string. Read via agGraphAttr (model/cgraph-ops.ts); empty on non-root graphs.

See

lib/cgraph/attr.c:agattr (graph-wide declaration, "" default)


edgeDefaults

ts
edgeDefaults: Map<string, string>;

Defined in: model/graph.ts:95

Default attributes applied to all edges in this graph scope.


edges

ts
edges: Edge[];

Defined in: model/graph.ts:76

All edges owned by this graph (root graph only for ownership; subgraphs reference a subset). Mirrors Agraph_t.e_seq.

See

lib/cgraph/cgraph.h:Agraph_s


graphDefaultsSnapshot?

ts
optional graphDefaultsSnapshot?: Map<string, string>;

Defined in: model/graph.ts:106

Snapshot of the enclosing graphs' graph-attribute defaults (this graph -> root, inner wins) captured when this subgraph was OPENED during parsing. Graph attributes set on an ancestor AFTER this subgraph was created are not included — mirroring cgraph's parse-time agsubg defval copy. Used for order-correct label/font inheritance (e.g. a root label= declared after a cluster must NOT apply to that cluster). Undefined on the root graph.

See

lib/cgraph/graph.c:agsubg (attr defval copy)


info

ts
info: GraphInfo;

Defined in: model/graph.ts:112

Layout-engine info; replaces GD_* macros via agbindrec (AD-1).

See

lib/cgraph/cgraph.h:agbindrec


kind

ts
readonly kind: GraphKind;

Defined in: model/graph.ts:62

Directed/strict classification; mirrors Agdesc_t.directed and Agdesc_t.strict.

See

lib/cgraph/cgraph.h:Agdesc_s


name

ts
readonly name: string;

Defined in: model/graph.ts:45

Graph name; agnameof equivalent.

See

lib/cgraph/cgraph.h:agnameof


nodeDefaults

ts
nodeDefaults: Map<string, string>;

Defined in: model/graph.ts:92

Default attributes applied to all nodes in this graph scope.


nodes

ts
nodes: Map<string, Node>;

Defined in: model/graph.ts:69

Node set in insertion order, keyed by name. Mirrors Agraph_t.n_seq (sequence dict) merged with n_id access.

See

lib/cgraph/cgraph.h:Agraph_s


parent

ts
parent: Graph | null;

Defined in: model/graph.ts:118

Immediate parent graph. null for root graphs.

See

lib/cgraph/cgraph.h:Agraph_s


root

ts
root: Graph;

Defined in: model/graph.ts:125

Root (main) graph. Self-referential for root graphs; points up for subgraphs.

See

lib/cgraph/cgraph.h:Agraph_s


seq

ts
seq: number = 0;

Defined in: model/graph.ts:135

Subgraph sequence number (AGSEQ). A global counter on the root, assigned at creation in source order, counting anonymous subgraphs. The root keeps the default 0 (par == NULL never calls agnextseq). Consumed by getObjId to emit cluster ids clust<seq>.

See

  • lib/cgraph/cgraph.h:AGSEQ
  • lib/cgraph/graph.c:agopen (AGSEQ(g) = agnextseq(par, AGRAPH))

subgraphs

ts
subgraphs: Map<string, Graph>;

Defined in: model/graph.ts:82

Named subgraphs, keyed by name. Mirrors Agraph_t.g_seq/g_id.

See

lib/cgraph/cgraph.h:Agraph_s


subgSeqCounter

ts
subgSeqCounter: number = 0;

Defined in: model/graph.ts:143

Root-only counter mirroring clos->seq[AGRAPH]: the running maximum AGSEQ handed out to subgraphs. Meaningful only on the root graph; assignSubgSeq pre-increments it. Other graphs leave it at 0.

See

lib/cgraph/graph.c:agnextseq (++clos->seq[AGRAPH])