mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 03:50:39 +00:00
⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# `obigraph` Package: Semantic Overview
|
||||
|
||||
The `obigraph` package provides a generic, type-safe undirected/directed graph implementation in Go. Its core features include:
|
||||
|
||||
- **Generic Graph Structure**: Parametrized over vertex type `V` and edge data type `T`, enabling flexible use with arbitrary user-defined types.
|
||||
- **Bidirectional Edge Tracking**: Maintains both forward (`Edges`) and reverse (`ReverseEdges`) adjacency maps for efficient neighbor/parent queries.
|
||||
- **Edge Management**:
|
||||
- `AddEdge`: Adds an *undirected* edge (inserted in both directions).
|
||||
- `AddDirectedEdge`: Adds a *directed* edge (only one direction).
|
||||
- `SetAsDirectedEdge`: Converts an existing undirected edge into a directed one by removing the reverse link.
|
||||
- **Graph Queries**:
|
||||
- `Neighbors(v)`: Returns all adjacent vertices (outgoing in directed case).
|
||||
- `Parents(v)`: Returns incoming neighbors via reverse adjacency.
|
||||
- `Degree(v)` / `ParentDegree(v)`: Compute vertex degrees (total or incoming).
|
||||
- **Customizable Vertex/Edge Properties**:
|
||||
- `VertexWeight`, `EdgeWeight`: Funcs to assign weights (default: constant weight = 1.0).
|
||||
- `VertexId`: Custom vertex label generator (default: `"V%d"`).
|
||||
|
||||
- **GML Export**:
|
||||
- `Gml(...)` / `WriteGml(...)`: Generates or writes a Graph Modelling Language (GML) representation.
|
||||
- Supports directed/undirected modes, degree-based filtering (`min_degree`), and visual styling:
|
||||
- Vertex shape: `circle` if weight ≥ threshold, else `rectangle`.
|
||||
- Size scaled by square root of vertex weight.
|
||||
- Uses Go’s `text/template` for rendering.
|
||||
|
||||
- **File I/O**: Directly writes GML to file via `WriteGmlFile(...)`.
|
||||
|
||||
- **Logging & Safety**: Uses Logrus for bounds-checking errors; panics on template parsing/writing failures.
|
||||
|
||||
The package is designed for lightweight, high-performance graph modeling and visualization-ready export.
|
||||
@@ -0,0 +1,14 @@
|
||||
# `obigraph.GraphBuffer` Feature Overview
|
||||
|
||||
The `GraphBuffer[V, T]` type provides a **thread-safe graph construction interface** using buffered edge insertion via Go channels.
|
||||
|
||||
- **Asynchronous Edge Addition**: Edges are enqueued through a `chan Edge[T]`, processed in the background by a goroutine that updates an underlying static graph (`Graph[V, T]`).
|
||||
- **Non-blocking API**: `AddEdge` and `AddDirectedEdge` are non-synchronous — they send to the channel without waiting for graph mutation, enabling high-throughput edge ingestion.
|
||||
- **Graph Initialization**: `NewGraphBuffer` initializes both the graph and a dedicated worker goroutine to consume edges.
|
||||
- **GML Export Support**: Full support for exporting the final graph in [Graph Modelling Language (GML)](https://en.wikipedia.org/wiki/Graph_Modelling_Language), with optional filtering (`min_degree`) and layout parameters (`threshold`, `scale`).
|
||||
- **File & Stream Output**: Methods `WriteGml` and `WriteGmlFile` allow writing GML to any `io.Writer`, including files.
|
||||
- **Resource Cleanup**: The explicit `Close()` method terminates the worker goroutine by closing the channel, ensuring clean shutdown.
|
||||
- **Generic Design**: Fully generic over vertex (`V`) and edge data types (`T`), supporting arbitrary value semantics.
|
||||
|
||||
> ⚠️ **Note**: The buffer is *not* safe for concurrent `AddEdge` calls without external synchronization beyond channel semantics.
|
||||
> ✅ Ideal for producer-consumer patterns where edges are streamed from multiple goroutines into a single graph.
|
||||
Reference in New Issue
Block a user