# hgr-format > Parses and validates HMETIS hypergraph (.hgr) files. Supports unweighted, edge-weighted, node-weighted, and dually-weighted formats. Use when working with hypergraph partitioning, HMETIS files, or graph partitioning tasks. - Author: Magi Chen - Repository: gradinnovate-labs/EDA-Skills - Version: 20260124164857 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-08 - Source: https://github.com/gradinnovate-labs/EDA-Skills - Web: https://mule.run/skillshub/@@gradinnovate-labs/EDA-Skills~hgr-format:20260124164857 --- --- name: hgr-format description: Parses and validates HMETIS hypergraph (.hgr) files. Supports unweighted, edge-weighted, node-weighted, and dually-weighted formats. Use when working with hypergraph partitioning, HMETIS files, or graph partitioning tasks. license: MIT compatibility: Requires Python 3.6+ metadata: version: "1.0" author: gradinnovate-labs --- # What I do - **Identify Format Type**: Detect the `fmt` code in the header to determine if the hypergraph uses weights for edges, nodes, or both. - **Validate Structure**: Verify that the number of lines in the file matches the expected count based on the number of hyperedges ($|E|$) and vertices ($|V|$). - **Analyze Hypergraph Metadata**: Extract the count of vertices and hyperedges and confirm if weights are present. ## Usage ### Quick Parse Use the provided script to parse any `.hgr` file: ```bash python scripts/parse_hgr.py ``` **Output:** - `number nodes`: Total number of vertices ($|V|$) - `number hyperedges`: Total number of hyperedges ($|E|$) - `is weighted hyperedges`: Whether hyperedges have weights (true/false) - `is weighted nodes`: Whether vertices have weights (true/false) - `is valid hgr`: Whether file structure is valid (true/false) ### Example ```bash $ python scripts/parse_hgr.py s13207P.hgr number nodes: 8772 number hyperedges: 8651 is weighted hyperedges: False is weighted nodes: False is valid hgr: True ``` ## When to use Use this skill when: - You need to process HMETIS hypergraph files - You need to validate hypergraph file structure - User mentions `.hgr` files, hypergraph partitioning, or HMETIS - You need to understand hypergraph metadata (nodes, hyperedges, weights) ## Format Overview HMETIS `.hgr` files support four formats: | Format Code | Description | |-------------|-------------| | (omitted) | Unweighted (edges and vertices = 1) | | 1 | Weighted hyperedges | | 10 | Weighted vertices | | 11 | Weighted hyperedges and vertices | See [references/REFERENCE.md](references/REFERENCE.md) for detailed format specifications. ## File Structure ``` hgr-format/ ├── SKILL.md # This file ├── scripts/ │ └── parse_hgr.py # Main parsing script ├── references/ │ └── REFERENCE.md # Detailed HMETIS format spec └── assets/ └── example.hgr # Example hypergraph file ```