Skip to content

Commit

Permalink
default labels change
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzarx1 committed Jul 18, 2024
1 parent 703adc2 commit bc15f6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Instant;

use crossbeam::channel::{unbounded, Receiver, Sender};
use eframe::{run_native, App, CreationContext};
use egui::{CollapsingHeader, Context, Pos2, ScrollArea, Slider, Ui, Vec2};
use egui::{CollapsingHeader, Context, Pos2, ScrollArea, Ui, Vec2};
use egui_graphs::events::Event;
use egui_graphs::{to_graph, DefaultEdgeShape, DefaultNodeShape, Edge, Graph, GraphView, Node};
use fdg::fruchterman_reingold::{FruchtermanReingold, FruchtermanReingoldConfiguration};
Expand Down
6 changes: 3 additions & 3 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<
let graph_node = self.g.node_weight_mut(idx).unwrap();

graph_node.bind(idx, location);
graph_node.set_label(idx.index().to_string());
graph_node.set_label(format!("node {}", idx.index()));

idx
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl<
removed
}

/// Adds edge between start and end node with default label setting correct order.
/// Adds edge between start and end node with default label.
pub fn add_edge(
&mut self,
start: NodeIndex<Ix>,
Expand All @@ -191,7 +191,7 @@ impl<
let e = self.g.edge_weight_mut(idx).unwrap();

e.bind(idx, order);
e.set_label(e.id().index().to_string());
e.set_label(format!("edge {}", e.id().index()));

idx
}
Expand Down
12 changes: 6 additions & 6 deletions src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ pub fn add_edge_custom<
///
/// assert_eq!(*input_graph.g.edge_weight(input_graph.g.edge_indices().next().unwrap()).unwrap().payload(), "edge1");
///
/// assert_eq!(*input_graph.g.node_weight(input_node_1).unwrap().label().clone(), input_node_1.index().to_string());
/// assert_eq!(*input_graph.g.node_weight(input_node_2).unwrap().label().clone(), input_node_2.index().to_string());
/// assert_eq!(*input_graph.g.node_weight(input_node_1).unwrap().label().clone(), format!("node {}", input_node_1.index()));
/// assert_eq!(*input_graph.g.node_weight(input_node_2).unwrap().label().clone(), format!("node {}", input_node_2.index()));
///
/// let loc_1 = input_graph.g.node_weight(input_node_1).unwrap().location();
/// let loc_2 = input_graph.g.node_weight(input_node_2).unwrap().location();
Expand Down Expand Up @@ -175,7 +175,7 @@ pub fn default_node_transform<
payload: &N,
) -> Node<N, E, Ty, Ix, D> {
let mut n = Node::new(payload.clone());
n.set_label(idx.index().to_string());
n.set_label(format!("node {}", idx.index()));

let loc = random_location(DEFAULT_SPAWN_SIZE);
n.bind(idx, loc);
Expand All @@ -197,7 +197,7 @@ pub fn default_edge_transform<
) -> Edge<N, E, Ty, Ix, Dn, D> {
let mut e = Edge::new(payload.clone());
e.bind(idx, order);
e.set_label(e.id().index().to_string());
e.set_label(format!("edge {}", e.id().index()));
e
}

Expand Down Expand Up @@ -280,7 +280,7 @@ mod tests {
assert!(input_n.location().x >= 0.0 && input_n.location().x <= DEFAULT_SPAWN_SIZE);
assert!(input_n.location().y >= 0.0 && input_n.location().y <= DEFAULT_SPAWN_SIZE);

assert_eq!(*input_n.label(), user_idx.index().to_string());
assert_eq!(*input_n.label(), format!("node {}", user_idx.index()));

assert!(!input_n.selected());
assert!(!input_n.dragged());
Expand Down Expand Up @@ -309,7 +309,7 @@ mod tests {
assert!(input_n.location().x >= 0.0 && input_n.location().x <= DEFAULT_SPAWN_SIZE);
assert!(input_n.location().y >= 0.0 && input_n.location().y <= DEFAULT_SPAWN_SIZE);

assert_eq!(*input_n.label(), user_idx.index().to_string());
assert_eq!(*input_n.label(), format!("node {}", user_idx.index()));

assert!(!input_n.selected());
assert!(!input_n.dragged());
Expand Down

0 comments on commit bc15f6e

Please sign in to comment.