Skip to content

Commit

Permalink
Merge branch 'main' into more-edge-coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish authored Oct 9, 2023
2 parents e5431cc + 632aa9a commit ee68b3a
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
if: runner.os == 'Linux'
- name: 'Build rustworkx and test dependencies'
run: |
pip install -c constraints.txt -U '.[mpl,graphviz]' fixtures testtools>=2.5.0 networkx>=2.5 stestr
pip install -c constraints.txt -U '.[mpl,graphviz]' fixtures testtools>=2.5.0 networkx>=2.5 stestr>=4.1
- name: 'Build retworkx'
env:
RUSTWORKX_PKG_NAME: "retworkx"
Expand Down
118 changes: 53 additions & 65 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ numpy = "0.19.0"
petgraph = "0.6.4"
rand = "0.8"
rand_pcg = "0.3"
rayon = "1.7"
rayon = "1.8"
rayon-cond = "1.7"

[lib]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
features:
- |
Added a new function, :func:`clear` that clears all nodes and edges
from a :class:`rustworkx.PyGraph` or :class:`rustworkx.PyDiGraph`
- |
Added a new function, :func:`clear_edges` that clears all edges for
:class:`rustworkx.PyGraph` or :class:`rustworkx.PyDiGraph` without
modifying nodes
2 changes: 1 addition & 1 deletion rustworkx-core/src/centrality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ where
{
let alpha: f64 = alpha.unwrap_or(0.1);

let mut beta: HashMap<usize, f64> = beta_map.unwrap_or_else(HashMap::new);
let mut beta: HashMap<usize, f64> = beta_map.unwrap_or_default();

if beta.is_empty() {
// beta_map was none
Expand Down
20 changes: 20 additions & 0 deletions rustworkx-core/src/token_swapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ where
}
let id_node = self.rev_node_map[&node];
let id_token = self.rev_node_map[&tokens[&node]];

if self.graph.neighbors(id_node).next().is_none() {
return Err(MapNotPossible {});
}

for id_neighbor in self.graph.neighbors(id_node) {
let neighbor = self.node_map[&id_neighbor];
let dist_neighbor: DictMap<G::NodeId, usize> = dijkstra(
Expand Down Expand Up @@ -705,4 +710,19 @@ mod test_token_swapper {
Err(_) => (),
};
}

#[test]
fn test_edgeless_graph_fails() {
let mut g = petgraph::graph::UnGraph::<(), ()>::new_undirected();
let a = g.add_node(());
let b = g.add_node(());
let c = g.add_node(());
let d = g.add_node(());
g.add_edge(c, d, ());
let mapping = HashMap::from([(a, b), (b, a)]);
match token_swapper(&g, mapping, Some(10), Some(4), Some(50)) {
Ok(_) => panic!("This should error"),
Err(_) => (),
};
}
}
1 change: 0 additions & 1 deletion src/dag_algo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ pub fn collect_bicolor_runs(
}
} else {
for color in colors {
let color = color;
ensure_vector_has_index!(pending_list, block_id, color);
if let Some(color_block_id) = block_id[color] {
block_list[color_block_id].append(&mut pending_list[color]);
Expand Down
Loading

0 comments on commit ee68b3a

Please sign in to comment.