Skip to main content

datasynth_graph/exporters/
common.rs

1//! Common types shared across ML graph exporters (PyG, DGL).
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7/// Common export configuration shared by PyG and DGL exporters.
8#[derive(Debug, Clone)]
9pub struct CommonExportConfig {
10    /// Export node features.
11    pub export_node_features: bool,
12    /// Export edge features.
13    pub export_edge_features: bool,
14    /// Export node labels (anomaly flags).
15    pub export_node_labels: bool,
16    /// Export edge labels (anomaly flags).
17    pub export_edge_labels: bool,
18    /// Export train/val/test masks.
19    pub export_masks: bool,
20    /// Train split ratio.
21    pub train_ratio: f64,
22    /// Validation split ratio.
23    pub val_ratio: f64,
24    /// Random seed for splits.
25    pub seed: u64,
26}
27
28impl Default for CommonExportConfig {
29    fn default() -> Self {
30        Self {
31            export_node_features: true,
32            export_edge_features: true,
33            export_node_labels: true,
34            export_edge_labels: true,
35            export_masks: true,
36            train_ratio: 0.7,
37            val_ratio: 0.15,
38            seed: 42,
39        }
40    }
41}
42
43/// Common metadata shared by PyG and DGL exporters.
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct CommonGraphMetadata {
46    /// Graph name.
47    pub name: String,
48    /// Number of nodes.
49    pub num_nodes: usize,
50    /// Number of edges.
51    pub num_edges: usize,
52    /// Node feature dimension.
53    pub node_feature_dim: usize,
54    /// Edge feature dimension.
55    pub edge_feature_dim: usize,
56    /// Number of node classes (for classification).
57    pub num_node_classes: usize,
58    /// Number of edge classes (for classification).
59    pub num_edge_classes: usize,
60    /// Node type mapping.
61    pub node_types: HashMap<String, usize>,
62    /// Edge type mapping.
63    pub edge_types: HashMap<String, usize>,
64    /// Whether graph is directed.
65    pub is_directed: bool,
66    /// Files included in export.
67    pub files: Vec<String>,
68    /// Additional statistics.
69    pub statistics: HashMap<String, f64>,
70}