Skip to content

A parser for constructing petgraph graphs from the dimacs format

Notifications You must be signed in to change notification settings

RaoulLuque/dimacs-petgraph-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dimacs Petgraph Parser

Basic parser to convert graphs in dimacs .col format to petgraphs 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)

Usage / Example

Include this lib in your dependencies in your Cargo.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:

  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<i32, i32, petgraph::prelude::Undirected>,
        Option<usize>,
        Option<usize>,
        Option<usize>
        ) =
      read_graph(test_graph_one_file)
          .expect("Test Graph One should be readable/in correct format");

About

A parser for constructing petgraph graphs from the dimacs format

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages