# stephanyrajeh/tgf architecture

> Architecture diagram of the GitHub repository stephanyrajeh/tgf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stephanyrajeh/tgf
- Repository: https://github.com/stephanyrajeh/tgf

## Overview

TGF is a research workflow for detecting random link anomalies: preprocess link-stream datasets, inject labeled anomalies when ground truth is unavailable, generate history-graph features, and train/test classifiers. The README documents H- and G-type histories, combined feature sets, bipartite and unipartite handling, and large-network/sliding-window variants. The tree and sampled feature-generation source support the feature stage; learning and preprocessing internals are represented at their documented subsystem level because their implementations were not sampled.

Main entry points: [`3-FeatureGeneration/main.py`](https://github.com/stephanyrajeh/tgf/blob/main/3-FeatureGeneration/main.py) (Feature CLI), [`1-PreprocessingOfDatasets`](https://github.com/stephanyrajeh/tgf/tree/main/1-PreprocessingOfDatasets) (Raw Datasets), [`2-Injection`](https://github.com/stephanyrajeh/tgf/tree/main/2-Injection) (Anomaly Injection), [`4-LearningAndTesting-LargeNetworks/ClassicalLearning`](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting-LargeNetworks/ClassicalLearning) (Classical Learning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Preprocessing"]
  node_raw_streams["Raw Datasets"]
  node_cleaning["Stream Cleaning"]
end

subgraph group_inject["Anomaly Injection"]
  node_injection["Anomaly Injection"]
  node_labeled_streams["Injected Streams"]
end

subgraph group_features["Feature Generation"]
  node_feature_cli["Feature CLI<br/>[main.py]"]
  node_dsc["Dynamic Counters<br/>[DSC_lib.py]"]
  node_feature_records["Feature Records"]
end

subgraph group_learn["Learning and Testing"]
  node_history_h["H Histories"]
  node_history_g["G Histories"]
  node_combine_histories["Combined Histories"]
  node_combine_h["Combined H Histories"]
  node_combine_g["Combined G Histories"]
  node_classical["Classical Learning"]
  node_sliding["Sliding Windows"]
end

subgraph group_large["Large Networks"]
end

node_researcher(("Researcher"))
node_predictions["Detection Results"]

node_researcher -->|"supplies datasets"| node_raw_streams
node_raw_streams -->|"preprocesses as"| node_cleaning
node_cleaning -->|"provides stream"| node_injection
node_injection -->|"writes labeled stream"| node_labeled_streams
node_labeled_streams -->|"streams input"| node_feature_cli
node_feature_cli -->|"uses counters"| node_dsc
node_feature_cli -->|"emits features"| node_feature_records
node_feature_records -->|"trains and tests"| node_history_h
node_feature_records -->|"trains and tests"| node_history_g
node_feature_records -->|"trains and tests"| node_combine_histories
node_feature_records -->|"trains and tests"| node_combine_h
node_feature_records -->|"trains and tests"| node_combine_g
node_feature_records -->|"supports learning"| node_classical
node_feature_records -->|"supports windowed learning"| node_sliding
node_classical -->|"detects anomalies"| node_predictions
node_sliding -->|"tests in chunks"| node_predictions

click node_raw_streams "https://github.com/stephanyrajeh/tgf/tree/main/1-PreprocessingOfDatasets"
click node_cleaning "https://github.com/stephanyrajeh/tgf/tree/main/1-PreprocessingOfDatasets"
click node_injection "https://github.com/stephanyrajeh/tgf/tree/main/2-Injection"
click node_labeled_streams "https://github.com/stephanyrajeh/tgf/tree/main/2-Injection"
click node_feature_cli "https://github.com/stephanyrajeh/tgf/blob/main/3-FeatureGeneration/main.py"
click node_dsc "https://github.com/stephanyrajeh/tgf/blob/main/3-FeatureGeneration/DSC_lib.py"
click node_history_h "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/HTypeHistoryGraphs"
click node_history_g "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/GTypeHistoryGraphs"
click node_combine_histories "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningHandGTypeHistoryGraphs"
click node_combine_h "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningHTypeHistoryGraphs"
click node_combine_g "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningGTypeHistoryGraphs"
click node_classical "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting-LargeNetworks/ClassicalLearning"
click node_sliding "https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting-LargeNetworks/SlidingWindowsLearning"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_streams,node_cleaning toneBlue
class node_injection,node_labeled_streams toneAmber
class node_feature_cli,node_dsc,node_feature_records toneMint
class node_history_h,node_history_g,node_combine_histories,node_combine_h,node_combine_g,node_classical,node_sliding toneRose
class node_researcher,node_predictions toneIndigo
```

## Components

### Preprocessing

- [Raw Datasets](https://github.com/stephanyrajeh/tgf/tree/main/1-PreprocessingOfDatasets): `1-PreprocessingOfDatasets`
- [Stream Cleaning](https://github.com/stephanyrajeh/tgf/tree/main/1-PreprocessingOfDatasets): `1-PreprocessingOfDatasets`

### Anomaly Injection

- [Anomaly Injection](https://github.com/stephanyrajeh/tgf/tree/main/2-Injection): `2-Injection`
- [Injected Streams](https://github.com/stephanyrajeh/tgf/tree/main/2-Injection): `2-Injection`

### Feature Generation

- [Feature CLI](https://github.com/stephanyrajeh/tgf/blob/main/3-FeatureGeneration/main.py): `3-FeatureGeneration/main.py`
- [Dynamic Counters](https://github.com/stephanyrajeh/tgf/blob/main/3-FeatureGeneration/DSC_lib.py): `3-FeatureGeneration/DSC_lib.py`
- **Feature Records**

### Learning and Testing

- [H Histories](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/HTypeHistoryGraphs): `4-LearningAndTesting/HTypeHistoryGraphs`
- [G Histories](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/GTypeHistoryGraphs): `4-LearningAndTesting/GTypeHistoryGraphs`
- [Combined Histories](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningHandGTypeHistoryGraphs): `4-LearningAndTesting/CombiningHandGTypeHistoryGraphs`
- [Combined H Histories](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningHTypeHistoryGraphs): `4-LearningAndTesting/CombiningHTypeHistoryGraphs`
- [Combined G Histories](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting/CombiningGTypeHistoryGraphs): `4-LearningAndTesting/CombiningGTypeHistoryGraphs`
- [Classical Learning](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting-LargeNetworks/ClassicalLearning): `4-LearningAndTesting-LargeNetworks/ClassicalLearning`
- [Sliding Windows](https://github.com/stephanyrajeh/tgf/tree/main/4-LearningAndTesting-LargeNetworks/SlidingWindowsLearning): `4-LearningAndTesting-LargeNetworks/SlidingWindowsLearning`

### Other components

- **Researcher**
- **Detection Results**

## Connections

- Researcher → Raw Datasets: supplies datasets
- Raw Datasets → Stream Cleaning: preprocesses as
- Stream Cleaning → Anomaly Injection: provides stream
- Anomaly Injection → Injected Streams: writes labeled stream
- Injected Streams → Feature CLI: streams input
- Feature CLI → Dynamic Counters: uses counters
- Feature CLI → Feature Records: emits features
- Feature Records → H Histories: trains and tests
- Feature Records → G Histories: trains and tests
- Feature Records → Combined Histories: trains and tests
- Feature Records → Combined H Histories: trains and tests
- Feature Records → Combined G Histories: trains and tests
- Feature Records → Classical Learning: supports learning
- Feature Records → Sliding Windows: supports windowed learning
- Classical Learning → Detection Results: detects anomalies
- Sliding Windows → Detection Results: tests in chunks
