CLI Reference¶
ForceAtlas2 provides a command-line interface via python -m fa2.
Commands¶
layout — Compute positions¶
python -m fa2 layout edges.json -o layout.json
python -m fa2 layout edges.csv --mode community --iterations 200 --seed 42
cat edges.json | python -m fa2 layout - > positions.json
render — Layout and render to image¶
python -m fa2 render edges.json -o graph.png
python -m fa2 render edges.csv -o graph.svg --title "My Network" --mode community
metrics — Compute layout quality¶
Options¶
| Flag | Short | Default | Description |
|---|---|---|---|
--iterations |
-i |
100 | Number of layout iterations |
--dim |
-d |
2 | Layout dimensions |
--mode |
-m |
default | Layout preset: default, community, hub-dissuade, compact |
--seed |
-s |
None | Random seed |
--output |
-o |
stdout | Output file path |
--title |
-t |
None | Chart title (render only) |
--positions |
-p |
None | Pre-computed positions file (metrics only) |
Input Formats¶
JSON¶
Or with explicit structure:
Or adjacency dict:
CSV¶
Piping¶
# Stdin → layout
echo '[["A","B"],["B","C"],["A","C"]]' | python -m fa2 layout - > layout.json
# Stdin → render
echo '[["A","B"],["B","C"],["A","C"]]' | python -m fa2 render - -o graph.png
# Stdin → metrics (computes layout internally)
echo '[["A","B"],["B","C"],["A","C"]]' | python -m fa2 metrics -