# p4zaa/graphprepkit architecture

> Architecture diagram of the GitHub repository p4zaa/graphprepkit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p4zaa/graphprepkit
- Repository: https://github.com/p4zaa/graphprepkit

## Overview

##### Project type and purpose
- Project type: a Python library (open-source toolkit) for graph data preprocessing.
- Purpose: provide utilities to transform raw tabular graph data into edge lists, index mappings, and visualizations for homogeneous and heterogeneous graphs.

##### File structure
- Top-level package “GraphPrepKit”
- construct.py        – functions to build connection tables (edge lists)
- homo.py             – functions for homogeneous graph mapping
- hetero.py           – functions for heterogeneous graph mapping
- dataset/            – example data (CSV files) for demonstration or tests
- setup.py              – packaging and dependency declarations
- README.md             – usage instructions and high-level overview

##### README for additional insights
- Key operations:
- build connection dataframes from raw source→target lists
- Unique IDs to integer indices for model ingestion
- support for both “homo” and “hetero” graph types
- reliance on pandas for data manipulation and networkx for plotting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client (user scripts/notebooks)"]:::external

    %% Dataset artifacts
    subgraph "Raw Data Artifacts" 
        direction TB
        DatasetInit["dataset/__init__.py"]:::data
        TweetCSV["#พรรคก้าวไกล_tweet.csv"]:::data
        UserCSV["#พรรคก้าวไกล_user.csv"]:::data
    end

    %% Core Package
    subgraph "GraphPrepKit Package"
        direction TB
        Init["__init__.py"]:::core
        Construct["construct.py"]:::core
        Homo["homo.py"]:::core
        Hetero["hetero.py"]:::core
        PlotNX["plotnx.py"]:::core
    end

    %% External dependencies and docs
    Pandas["pandas"]:::external
    NetworkX["networkx"]:::external
    Setup["setup.py"]:::external
    Readme["README.md"]:::external

    %% Data flow
    Client -->|"import GraphPrepKit.construct"| Construct
    Construct -->|"DataFrame of source/target pairs"| Client
    Construct -->|"raw edge list"| Homo
    Construct -->|"raw edge list"| Hetero
    Homo -->|"Mapped index pairs"| Client
    Hetero -->|"Mapped index pairs"| Client
    Client -->|"import GraphPrepKit.plotnx"| PlotNX
    PlotNX -->|"NetworkX Graph object"| Client

    %% Raw data usage
    Client -->|"reads CSV"| TweetCSV
    Client -->|"reads CSV"| UserCSV

    %% External libs usage
    Construct -->|"uses pandas"| Pandas
    Homo -->|"uses pandas"| Pandas
    Hetero -->|"uses pandas"| Pandas
    PlotNX -->|"uses networkx"| NetworkX

    %% Packaging and docs
    Setup -.->|"packaging config"| Init
    Readme -.->|"usage instructions"| Client

    %% Click events
    click Init "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/__init__.py"
    click Construct "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/construct.py"
    click Homo "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/homo.py"
    click Hetero "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/hetero.py"
    click PlotNX "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/plotnx.py"
    click DatasetInit "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/dataset/__init__.py"
    click TweetCSV "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/dataset/#พรรคก้าวไกล_twitter_data/#พรรคก้าวไกล_tweet.csv"
    click UserCSV "https://github.com/p4zaa/graphprepkit/blob/main/GraphPrepKit/dataset/#พรรคก้าวไกล_twitter_data/#พรรคก้าวไกล_user.csv"
    click Setup "https://github.com/p4zaa/graphprepkit/blob/main/setup.py"
    click Readme "https://github.com/p4zaa/graphprepkit/blob/main/README.md"

    %% Styles
    classDef core fill:#8dd3c7,stroke:#333,stroke-width:1px
    classDef external fill:#bebada,stroke:#333,stroke-width:1px
    classDef data fill:#fb8072,stroke:#333,stroke-width:1px
```
