leptos_helios/graph_features/
mod.rs1pub mod algorithms;
7pub mod analysis;
8pub mod clustering;
9pub mod layouts;
10pub mod visualization;
11
12pub use algorithms::*;
14pub use analysis::*;
15pub use clustering::*;
16pub use layouts::*;
17pub use visualization::*;
18
19#[derive(Debug, Clone, PartialEq)]
24pub struct GraphNode {
25 pub id: String,
26 pub x: f64,
27 pub y: f64,
28 pub weight: f64,
29 pub color: String,
30 pub size: f64,
31 pub label: String,
32}
33
34impl GraphNode {
35 pub fn new(id: &str, x: f64, y: f64) -> Self {
37 Self {
38 id: id.to_string(),
39 x,
40 y,
41 weight: 1.0,
42 color: "#000000".to_string(),
43 size: 10.0,
44 label: id.to_string(),
45 }
46 }
47
48 pub fn set_color(&mut self, color: &str) {
50 self.color = color.to_string();
51 }
52
53 pub fn set_size(&mut self, size: f64) {
55 self.size = size;
56 }
57
58 pub fn set_label(&mut self, label: &str) {
60 self.label = label.to_string();
61 }
62}
63
64#[derive(Debug, Clone)]
66pub struct GraphEdge {
67 pub source: String,
68 pub target: String,
69 pub weight: f64,
70 pub color: String,
71 pub width: f64,
72 pub label: String,
73}
74
75impl GraphEdge {
76 pub fn new(source: &str, target: &str, weight: f64) -> Self {
78 Self {
79 source: source.to_string(),
80 target: target.to_string(),
81 weight,
82 color: "#000000".to_string(),
83 width: 1.0,
84 label: String::new(),
85 }
86 }
87
88 pub fn set_color(&mut self, color: &str) {
90 self.color = color.to_string();
91 }
92
93 pub fn set_width(&mut self, width: f64) {
95 self.width = width;
96 }
97
98 pub fn set_label(&mut self, label: &str) {
100 self.label = label.to_string();
101 }
102}
103
104#[derive(Debug, Clone)]
106pub struct CentralityMeasures {
107 pub degree_centrality: f64,
108 pub betweenness_centrality: f64,
109 pub closeness_centrality: f64,
110}
111
112#[derive(Debug, Clone)]
114pub struct NetworkMetrics {
115 pub node_count: usize,
116 pub edge_count: usize,
117 pub density: f64,
118 pub clustering_coefficient: f64,
119 pub average_path_length: f64,
120}
121
122#[derive(Debug, Clone)]
124pub struct VisualizationMetrics {
125 pub edge_crossings: usize,
126 pub node_overlaps: usize,
127 pub layout_quality: f64,
128}