CP Graph Editor
Smart Parser • Zero Formatting Hassle

Codeforces, CSES, AtCoder & LeetCode Graph Input Formats

Never spend contest minutes rewriting testcases by hand. Paste sample inputs directly into the left Edges List editor or the smart Import modal — all node counts, isolated vertices, weights, and multi-testcases sync live.

1. Headerless & Standard N M Edge Lists

Works for Codeforces, CSES, and USACO inputs — both with or without the leading N M counts line. Isolated nodes declared inside N remain preserved on the canvas.

# Standard N M format (preserves isolated vertex 5)
5 4
1 2
2 3 10
3 4 -5
1 4

2. String Node IDs, Primed Vertices & String Edge Weights

Supports primes (1', 2' for flow/residual split nodes), named tokens, booleans, and quoted string weights.

SRC 1 0
1 2' "fast lane"
2' DEST 6
1 [10]
Goal: "end"
IsolatedNode

3. LeetCode 2D Arrays & Parent Arrays

Click Import in the Editor tab to auto-convert LeetCode edge arrays or tree parent lists into synchronized tabs:

# LeetCode 2D unweighted / weighted array
edges = [[0,1],[1,2],[2,0],[1,3]]
[[0,1,10],[1,2,5],[2,0,8]]

# LeetCode Tree Parent Array
parent = [-1, 0, 0, 1, 1, 2]

4. Multi-Testcase Contests (T Testcases)

Paste T followed by T graphs — CP Graph detects multiple testcases and offers a 1-click Split into Tabs action so every testcase draws cleanly in its own tab.

2
3 2
1 2
2 3
4 3
1 2
2 3
3 4

Frequently Asked Questions

Can I paste LeetCode 2D arrays like edges = [[0,1],[1,2]] directly?

Yes. Open the Import modal or convert bracketed JSON/Python arrays directly; toggling 0-based matches LeetCode indexing cleanly.

Does the editor preserve isolated vertices when N exceeds edges?

Yes. Standard N M contest headers create all vertices from 1..N (or 0..N-1), keeping disconnected components intact.

How are multi-testcase (T) contest inputs handled?

The parser detects multiple testcases and surfaces a 1-click Split into Tabs action to inspect each testcase side-by-side.