Compare commits
No commits in common. "4d67a5480f6009c8d951a7277875f7f7eb0b2f25" and "ec0592cb054330fc07f39d523d3d2ab82bea04c9" have entirely different histories.
4d67a5480f
...
ec0592cb05
3 changed files with 1 additions and 55 deletions
|
|
@ -155,11 +155,8 @@ enum Method {
|
|||
#[derive(Debug, Parser)]
|
||||
struct Args {
|
||||
filename: PathBuf,
|
||||
#[clap(default_value = "reduction2")]
|
||||
method: Method,
|
||||
k: Option<u16>,
|
||||
#[clap(short, long)]
|
||||
reverse: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -172,20 +169,6 @@ fn main() {
|
|||
let r = vertex_cover(&graph, k, args.method);
|
||||
eprintln!("{}: {:?}", k, start.elapsed());
|
||||
r
|
||||
} else if args.reverse {
|
||||
let mut k = graph.num_vertices();
|
||||
let mut last_solution = None;
|
||||
loop {
|
||||
let start = std::time::Instant::now();
|
||||
let r = vertex_cover(&graph, k, args.method);
|
||||
eprintln!("{}: {:?}", k, start.elapsed());
|
||||
if let Some(r) = r {
|
||||
k = r.len() as u16 - 1;
|
||||
last_solution = Some(r);
|
||||
} else {
|
||||
break last_solution;
|
||||
};
|
||||
}
|
||||
} else {
|
||||
let mut k = 0;
|
||||
loop {
|
||||
|
|
|
|||
|
|
@ -237,8 +237,6 @@ pub fn reduction2(graph: &mut Graph, k: u16) -> Option<Vec<u16>> {
|
|||
let _ = graph.reinsert_vertices(1);
|
||||
|
||||
r
|
||||
} else if graph.is_empty() {
|
||||
Some(Vec::new())
|
||||
} else if k == 0 {
|
||||
if graph.is_empty() {
|
||||
Some(Vec::new())
|
||||
|
|
@ -345,10 +343,6 @@ pub fn reduction2(graph: &mut Graph, k: u16) -> Option<Vec<u16>> {
|
|||
}
|
||||
}
|
||||
} else if let Some(vertex) = graph.get_vertex_with_degree_greater(3) {
|
||||
if k < 1 {
|
||||
return None;
|
||||
}
|
||||
|
||||
graph.remove_vertex(vertex);
|
||||
|
||||
match reduction2(graph, k - 1) {
|
||||
|
|
@ -380,6 +374,6 @@ pub fn reduction2(graph: &mut Graph, k: u16) -> Option<Vec<u16>> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
unreachable!("{k}")
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from numpy import roots,isreal
|
||||
from itertools import combinations_with_replacement
|
||||
|
||||
|
||||
solutions = []
|
||||
|
||||
s = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
for i in range(2, 7):
|
||||
|
||||
for j in combinations_with_replacement(s, i):
|
||||
|
||||
p = [-j.count(k) for k in range(max(j) + 1)]
|
||||
p[0] = 1
|
||||
|
||||
|
||||
r = [float(k) for k in roots(p) if isreal(k) and k > 0.0]
|
||||
# print(j, max(j), p, r)
|
||||
|
||||
solutions.append((j, r[0]))
|
||||
|
||||
|
||||
|
||||
solutions.sort(key=lambda e: e[1])
|
||||
|
||||
for s in solutions:
|
||||
|
||||
print(f"{s[1]}\t{s[0]}")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue