Skip to content

Commit

Permalink
complete file format list and replace links
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Maas committed Nov 22, 2024
1 parent 4a1c7f4 commit dcbc7ea
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 16 deletions.
70 changes: 63 additions & 7 deletions FileFormats.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,87 @@ The following is an overview of the input and output file formats which are used

**Important note:** For historical reasons, the hMetis and Metis input formats use 1-based indexing.
However, Mt-KaHyPar converts the indices to 0-based indexing when reading the files.
Any results obtained from the binary or one of the library interfaces will also use 0-based indices (i.e., shifted by -1 in comparison to the input file).
Any results obtained from the binary or one of the library interfaces will also use 0-based indexing (i.e., shifted by -1 in comparison to the input file).

### hMetis Format for Input Hypergraphs
## hMetis Format for Input Hypergraphs

Per default, Mt-KaHyPar assumes that the input hypergraph is provided in the hMetis format: [Example](tests/instances/unweighted_hypergraph.hgr)
Per default, Mt-KaHyPar assumes that the input hypergraph is provided in the hMetis format:
[Unweighted Example](tests/instances/unweighted_hypergraph.hgr), [Weighted Example](tests/instances/hypergraph_with_node_and_edge_weights.hgr), [hMetis manual](https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf)

The general format looks as follows:

```
% comment
num_hypergedges num_hypernodes [weight_type]
[hyperedge_weight] pin_1 pin_2 ... pin_i
[hyperedge_weight_1] pin_1 pin_2 ... pin_i
...
[hyperedge_weight] pin_1 pin_2 ... pin_j
[hyperedge_weight_m] pin_1 pin_2 ... pin_j
[hypernode_weight_1]
...
[hypernode_weight_n]
```

Any line that starts with ‘%’ is a comment line and is skipped.
The first line is a header containing two or three numbers describing the total number of hyperedges, the total number of hypernodes and the types weights used by the hypergraph
(00/omitted = unweighted, 10 = node weight, 01 = edge weight, 11 = node and edge weights).
The first line is a header containing two or three numbers describing the total number of hyperedges, the total number of hypernodes and the types weights used by the graph
(00/omitted = unweighted, 10 = node weights, 01 = edge weights, 11 = node and edge weights).

Afterwards, there is one line for each hyperedge which contains a list of the pins (hypernode IDs) of the hyperedge.
If hyperedge weights are used, there is an additional entry at the start of the line which is the weight of the hyperedge.

If no hypernode weights are used, this is the end of the file.
Otherwise, there is one line for each hypernode containing a single entry, which is the weight of the hypernode.

## Metis Format for Input Graphs

Mt-KaHyPar can also read input *graphs* in Metis format via `--input-file-format=metis`.
Furthermore, target graphs for the Steiner tree metric need to be provided in the Metis format:
[Unweighted Example](tests/instances/unweighted_graph.graph), [Weighted Example](tests/instances/graph_with_node_and_edge_weights.graph), [Metis manual](https://karypis.github.io/glaros/files/sw/metis/manual.pdf)

**Important note:** Mt-KaHyPar only works on undirected graphs. Therefore, for each edge `u -> v` in the input file there *must be* a corresponding entry for `v -> u` with the same edge weight.

The general format looks as follows:

```
% comment
num_nodes num_edges [weight_type]
[node_weight_1] neigbor_1 [edge_weight_1] neighbor_2 [edge_weight_2] ... neighbor_i [edge_weight_i]
...
[node_weight_n] neigbor_1 [edge_weight_1] neighbor_2 [edge_weight_2] ... neighbor_j [edge_weight_j]
```

Any line that starts with ‘%’ is a comment line and is skipped.
The first line is a header containing two or three numbers describing the total number of nodes, the total number of edges and the types weights used by the hypergraph
(00/omitted = unweighted, 10 = node weights, 01 = edge weights, 11 = node and edge weights).

Afterwards, there is one line for each node which contains the edges as an adjacency list, i.e., a list of the neighbor nodes (node IDs).
If node weights are used, there is an additional entry at the start of the line which is the weight of the node.
If edge weights are used, the adjacency list contains pairs as entries, with the first number being the node ID and the second number being the edge weight.

## Partition Output Format

When outputting the partitioning result via `--write-partition-file=true --partition-output-folder=<path/to/folder>`, Mt-KaHyPar uses the following format:

```
block_ID_1
...
-block_ID_n
```

The file contains one line for each (hyper)node.
Each line contains a single number which is the ID of the block that the node is assigned to.

## hMetis Fix File Format

When partitioning with fixed vertices via `-f <path-to-fixed-vertex-file>`, Mt-KaHyPar assumes that the fixed vertices are provided in hMetis fix file format:
[hMetis manual](https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf)

The format looks as follows:

```
-1|block_ID_1
...
-1|block_ID_n
```

The file contains one line for each (hyper)node.
Each line contains a single number which is the block ID if the node should be fixed, or -1 if the node can be assigned to any block.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,25 @@ Mt-KaHyPar can optimize the cut-net, connectivity, and sum-of-external-degrees m

-o <cut/km1/soed>

### Mapping (Hyper)Graphs onto Graphs
### Graph Partitioning

To map a **(hyper)graph** onto a **target graph** with Mt-KaHyPar, you can add the following command line parameters to the partitioning call:
To partition a **graph** with Mt-KaHyPar, you can add the following command line parameters to the partitioning call:

-g <path-to-target-graph> -o steiner_tree
-h <path-to-graph> --instance-type=graph --input-file-format=<metis/hmetis> -o cut

The target graph is expected to be in [Metis format](http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/manual.pdf). The nodes of the (hyper)graph are then mapped onto the nodes of the target graph, while optimizing the Steiner tree metric (see [Supported Objective Functions](#supported-objective-functions)).
Mt-KaHyPar then uses optimized data structures for graph partitioning, which speedups the partitioning time by a factor of two compared to our hypergraph partitioning code. Per default, we expect the input in [hMetis format](FileFormats.md#hmetis-format-for-input-hypergraphs), but you can read graph files in [Metis format](FileFormats.md#metis-format-for-input-graphs) via `--input-file-format=metis`.

### Graph Partitioning
### Mapping (Hyper)Graphs onto Graphs

To partition a **graph** with Mt-KaHyPar, you can add the following command line parameters to the partitioning call:
To map a **(hyper)graph** onto a **target graph** with Mt-KaHyPar, you can add the following command line parameters to the partitioning call:

-h <path-to-graph> --instance-type=graph --input-file-format=<metis/hmetis> -o cut
-g <path-to-target-graph> -o steiner_tree

Mt-KaHyPar then uses optimized data structures for graph partitioning, which speedups the partitioning time by a factor of two compared to our hypergraph partitioning code. Per default, we expect the input in [hMetis format](http://glaros.dtc.umn.edu/gkhome/fetch/sw/hmetis/manual.pdf), but you can read graph files in [Metis format](http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/manual.pdf) via `--input-file-format=metis`.
The target graph is expected to be in [Metis format](FileFormats.md#metis-format-for-input-graphs). The nodes of the (hyper)graph are then mapped onto the nodes of the target graph, while optimizing the Steiner tree metric (see [Supported Objective Functions](#supported-objective-functions)).

### Fixed Vertices

Fixed vertices are nodes that are preassigned to particular block and are not allowed to change their block during partitioning. Mt-KaHyPar reads fixed vertices from a file in the [hMetis fix file format](http://glaros.dtc.umn.edu/gkhome/fetch/sw/hmetis/manual.pdf), which can be provided via the following command line parameter:
Fixed vertices are nodes that are preassigned to particular block and are not allowed to change their block during partitioning. Mt-KaHyPar reads fixed vertices from a file in the [hMetis fix file format](FileFormats.md#hmetis-fix-file-format), which can be provided via the following command line parameter:

-f <path-to-fixed-vertex-file>

Expand Down

0 comments on commit dcbc7ea

Please sign in to comment.