Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raoulluque/dimacs-petgraph-parser
A parser for constructing petgraph graphs from the dimacs format
https://github.com/raoulluque/dimacs-petgraph-parser
dimacs-format graph graphs petgraph rust
Last synced: 5 days ago
JSON representation
A parser for constructing petgraph graphs from the dimacs format
- Host: GitHub
- URL: https://github.com/raoulluque/dimacs-petgraph-parser
- Owner: RaoulLuque
- Created: 2024-04-17T12:47:59.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-10T15:48:57.000Z (8 months ago)
- Last Synced: 2024-05-11T16:01:38.278Z (8 months ago)
- Topics: dimacs-format, graph, graphs, petgraph, rust
- Language: Rust
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dimacs Petgraph Parser
Basic parser to convert graphs in [dimacs .col](http://lcs.ios.ac.cn/~caisw/Resource/about_DIMACS_graph_format.txt) format to [petgraphs](https://github.com/petgraph/petgraph) with optional treewidth information. The treewidth information is in optional lines in arbirtary order in between the c and p lines in the dimacs.col file:
```
c ...
t TREEWIDTH_NUMBER
l TREEWIDTH_LOWER_BOUND_NUMBER
u TREEWIDTH_UPPER_BOUND_NUMBER
p ...
```
(see examples in [test_graphs](test_graphs))# Usage / Example
Include this lib in your dependencies in your Cargo.toml:
```toml
dimacs_petgraph_parser = { git = "https://github.com/RaoulLuque/dimacs-petgraph-parser" }
```
Use the read_graph() function. This will return a result with an error if any IO errors occur or the graph is in the wrong format:```rust
let test_graph_one_file =
File::open("test_graphs/test_graph_one.col").expect("Should be able to read file");
let (test_graph_one, treewidth, lower_bound, upper_bound):
(Graph,
Option,
Option,
Option
) =
read_graph(test_graph_one_file)
.expect("Test Graph One should be readable/in correct format");
```