Overview
Visual graphs extend regular graphs with required position and size properties on all nodes and edges. This makes them ready for rendering in canvas, SVG, or other visualization libraries.Visual Graph Type
TheVisualGraph type is similar to Graph, but nodes and edges have required position/size fields:
Visual Node Type
ExtendsGraphNode with required position and size:
Visual Edge Type
ExtendsGraphEdge with required position and size:
Creating Visual Graphs
UsecreateVisualGraph() to create graphs with required visual properties:
Default Values
If you don’t provide position/size,createVisualGraph() defaults them to 0:
Direction
Thedirection field provides a layout hint for rendering:
'down'— Top to bottom (default)'up'— Bottom to top'left'— Right to left'right'— Left to right
When exporting to formats like DOT, the
direction field is mapped to rankdir:'down'→TB(top to bottom)'up'→BT(bottom to top)'left'→RL(right to left)'right'→LR(left to right)
Visual Properties on Regular Graphs
You can add visual properties to regular graphs created withcreateGraph():
createGraph()— Visual properties are optional (x?: number)createVisualGraph()— Position/size are required (x: number)
Shape Property
Nodes can specify ashape for rendering:
'rectangle'/'box''ellipse'/'circle''diamond''hexagon'- Custom shapes (format-specific)
The exact shape names depend on the rendering format. For example, DOT uses
'box' instead of 'rectangle'. Check the format converter documentation for details.Color Property
Both nodes and edges can specify colors:- Node color — Fill color (mapped to
fillcolorin DOT) - Edge color — Stroke color
Style Property
For advanced styling, use thestyle object:
Visual Graphs with Algorithms
VisualGraph extends Graph, so all algorithms work with visual graphs:
Integration with Rendering Libraries
Visual graphs are designed to work with visualization libraries:XYFlow / React Flow
Cytoscape
D3
Layout Algorithms
While the library doesn’t include layout algorithms, you can use external tools:Example: Styled Workflow
Next Steps
Formats
Export visual graphs to DOT, GraphML, Cytoscape, etc.
Serialization
Learn about JSON serialization
Graphs
Back to basic graph concepts
Hierarchical Graphs
Combine visual properties with hierarchy