Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2024"
# The generated code depends on lalrpop-util.
[dependencies]
lalrpop-util = { version = "0.22", features = ["lexer"] }
clap = { version = "4.4", features = ["derive"] }

# Add a build-time dependency on the lalrpop library:
[build-dependencies]
Expand Down
31 changes: 19 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@ use std::fs::File;
use std::io::{self, Read};
use std::path::Path;

use clap::Parser;
use ontime::parser::tg_parser::{NIDListParser, TemporalGraphParser};

/// A solver for punctual reachability games on temporal graphs
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Path to the temporal graph input file
input_file: String,

/// Target set of nodes (comma-separated node IDs)
target_set: String,

/// Time to reach the target set
time_to_reach: usize,
}

fn main() -> io::Result<()> {
// Path to the example file
let args: Vec<String> = std::env::args().collect();
if args.len() != 4 {
eprintln!(
"Usage: {} <input_file> <target_set> <time_to_reach>",
args[0]
);
std::process::exit(1);
}
let args = Args::parse();

let path = Path::new(&args[1]);
let path = Path::new(&args.input_file);
let mut file = File::open(path)?;
let mut input = String::new();
file.read_to_string(&mut input)?;
Expand All @@ -27,12 +34,12 @@ fn main() -> io::Result<()> {

// parse target
let parser = NIDListParser::new();
let v = parser.parse(&args[2]).expect("Failed to read target");
let v = parser.parse(&args.target_set).expect("Failed to read target");
let target_ids: std::collections::HashSet<_> = v.iter().cloned().collect();
//println!("{:#?}", target_ids);

// time to reach
let k: usize = args[3].parse::<usize>().expect("Failed to parse usize");
let k: usize = args.time_to_reach;

// node ownershopt. true --> pLayer one, false --> player two node.
let nodes_owned_by_reacher: Vec<bool> = graph.node_ownership();
Expand Down