# kojix2/ruby-igraph architecture

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

- Interactive diagram: https://gitdiagram.com/kojix2/ruby-igraph
- Repository: https://github.com/kojix2/ruby-igraph

## Overview

ruby-igraph provides a Ruby interface to the native igraph network-analysis library. The documented workflow is to create or populate a graph, invoke graph operations through FFI, and read results such as vertex and edge counts. Its binding modules expose graph construction, analysis, layouts, and data structures. The README’s example uses the low-level binding directly; the supplied excerpts do not show how the high-level Graph wrapper delegates to it, so that relationship is not asserted.

Main entry points: [`lib/igraph/libigraph.rb`](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph.rb) (FFI loader), [`lib/igraph/libigraph/vector.rb`](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/vector.rb) (Native vectors), [`lib/igraph/libigraph/paths.rb`](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/paths.rb) (Paths and structure), [`lib/igraph/libigraph/community.rb`](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/community.rb) (Community analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Ruby API"]
  node_ruby_api["Ruby entry point<br/>[igraph.rb]"]
  node_graph_api["Graph wrapper<br/>[graph.rb]"]
  node_selectors["Graph selectors<br/>[vertex_selector.rb]"]
  node_edge_selectors["Edge selectors<br/>[edge_selector.rb]"]
  node_io["Graph I/O<br/>[io.rb]"]
end

subgraph group_ffi["FFI bindings"]
  node_ffi_loader["FFI loader<br/>[libigraph.rb]"]
  node_constructors["Graph construction<br/>[constructors.rb]"]
  node_interface["Graph operations<br/>[interface.rb]"]
end

subgraph group_analysis["Network analysis"]
  node_algorithms["Paths and structure<br/>[paths.rb]"]
  node_centrality["Centrality measures<br/>[centrality.rb]"]
  node_communities["Community analysis<br/>[community.rb]"]
  node_generation["Graph generators<br/>[games.rb]"]
  node_layout["Graph layouts<br/>[layout.rb]"]
  node_structural["Structural analysis<br/>[structural.rb]"]
  node_adjacency["Adjacency lists<br/>[adjlist.rb]"]
end

subgraph group_data["Graph data"]
  node_graph_type["Native graph type<br/>[datatype.rb]"]
  node_vectors["Native vectors<br/>[vector.rb]"]
  node_matrices["Native matrices<br/>[matrix.rb]"]
end

subgraph group_native["Native dependency"]
  node_libigraph["igraph C library"]
end

node_user(("Ruby caller"))

node_user -->|"requires"| node_ruby_api
node_user -->|"calls bindings"| node_ffi_loader
node_ffi_loader -->|"loads library"| node_libigraph
node_ffi_loader -->|"loads"| node_constructors
node_ffi_loader -->|"loads"| node_interface
node_ffi_loader -->|"loads"| node_algorithms
node_ffi_loader -->|"loads"| node_centrality
node_ffi_loader -->|"loads"| node_communities
node_ffi_loader -->|"loads"| node_generation
node_ffi_loader -->|"loads"| node_layout
node_ffi_loader -->|"loads"| node_structural
node_ffi_loader -->|"loads"| node_adjacency
node_constructors -->|"uses type"| node_graph_type
node_algorithms -->|"uses type"| node_vectors
node_algorithms -->|"uses type"| node_matrices
node_centrality -->|"uses type"| node_vectors
node_communities -->|"uses type"| node_vectors
node_communities -->|"uses type"| node_matrices
node_generation -->|"uses type"| node_vectors
node_structural -->|"uses type"| node_vectors
node_adjacency -->|"uses type"| node_vectors
node_graph_type -->|"embeds"| node_vectors
node_matrices -->|"embeds"| node_vectors

click node_ruby_api "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph.rb"
click node_graph_api "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/graph.rb"
click node_selectors "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/vertex_selector.rb"
click node_edge_selectors "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/edge_selector.rb"
click node_io "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/io.rb"
click node_ffi_loader "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph.rb"
click node_constructors "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/constructors.rb"
click node_interface "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/interface.rb"
click node_algorithms "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/paths.rb"
click node_centrality "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/centrality.rb"
click node_communities "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/community.rb"
click node_generation "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/games.rb"
click node_layout "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/layout.rb"
click node_structural "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/structural.rb"
click node_adjacency "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/adjlist.rb"
click node_graph_type "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/datatype.rb"
click node_vectors "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/vector.rb"
click node_matrices "https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/matrix.rb"

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_ruby_api,node_graph_api,node_selectors,node_edge_selectors,node_io toneBlue
class node_ffi_loader,node_constructors,node_interface toneAmber
class node_algorithms,node_centrality,node_communities,node_generation,node_layout,node_structural,node_adjacency toneMint
class node_graph_type,node_vectors,node_matrices toneRose
class node_libigraph,node_user toneIndigo
```

## Components

### Ruby API

- [Ruby entry point](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph.rb): `lib/igraph.rb`
- [Graph wrapper](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/graph.rb): `lib/igraph/graph.rb`
- [Graph selectors](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/vertex_selector.rb): `lib/igraph/vertex_selector.rb`
- [Edge selectors](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/edge_selector.rb): `lib/igraph/edge_selector.rb`
- [Graph I/O](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/io.rb): `lib/igraph/io.rb`

### FFI bindings

- [FFI loader](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph.rb): `lib/igraph/libigraph.rb`
- [Graph construction](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/constructors.rb): `lib/igraph/libigraph/constructors.rb`
- [Graph operations](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/interface.rb): `lib/igraph/libigraph/interface.rb`

### Network analysis

- [Paths and structure](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/paths.rb): `lib/igraph/libigraph/paths.rb`
- [Centrality measures](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/centrality.rb): `lib/igraph/libigraph/centrality.rb`
- [Community analysis](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/community.rb): `lib/igraph/libigraph/community.rb`
- [Graph generators](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/games.rb): `lib/igraph/libigraph/games.rb`
- [Graph layouts](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/layout.rb): `lib/igraph/libigraph/layout.rb`
- [Structural analysis](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/structural.rb): `lib/igraph/libigraph/structural.rb`
- [Adjacency lists](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/adjlist.rb): `lib/igraph/libigraph/adjlist.rb`

### Graph data

- [Native graph type](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/datatype.rb): `lib/igraph/libigraph/datatype.rb`
- [Native vectors](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/vector.rb): `lib/igraph/libigraph/vector.rb`
- [Native matrices](https://github.com/kojix2/ruby-igraph/blob/main/lib/igraph/libigraph/matrix.rb): `lib/igraph/libigraph/matrix.rb`

### Native dependency

- **igraph C library**

### Other components

- **Ruby caller**

## Connections

- Ruby caller → Ruby entry point: requires (evidence: `lib/igraph.rb`)
- Ruby caller → FFI loader: calls bindings
- FFI loader → igraph C library: loads library (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Graph construction: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Graph operations: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Paths and structure: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Centrality measures: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Community analysis: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Graph generators: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Graph layouts: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Structural analysis: loads (evidence: `lib/igraph/libigraph.rb`)
- FFI loader → Adjacency lists: loads (evidence: `lib/igraph/libigraph.rb`)
- Graph construction → Native graph type: uses type (evidence: `lib/igraph/libigraph/constructors.rb`)
- Paths and structure → Native vectors: uses type (evidence: `lib/igraph/libigraph/paths.rb`)
- Paths and structure → Native matrices: uses type (evidence: `lib/igraph/libigraph/paths.rb`)
- Centrality measures → Native vectors: uses type (evidence: `lib/igraph/libigraph/centrality.rb`)
- Community analysis → Native vectors: uses type (evidence: `lib/igraph/libigraph/community.rb`)
- Community analysis → Native matrices: uses type (evidence: `lib/igraph/libigraph/community.rb`)
- Graph generators → Native vectors: uses type (evidence: `lib/igraph/libigraph/games.rb`)
- Structural analysis → Native vectors: uses type (evidence: `lib/igraph/libigraph/structural.rb`)
- Adjacency lists → Native vectors: uses type (evidence: `lib/igraph/libigraph/adjlist.rb`)
- Native graph type → Native vectors: embeds (evidence: `lib/igraph/libigraph/datatype.rb`)
- Native matrices → Native vectors: embeds (evidence: `lib/igraph/libigraph/matrix.rb`)
