Skip to content

Commit 8372707

Browse files
grokifyclaude
andcommitted
docs: add query and analyze packages to documentation
Update README, API reference, and changelog to document the new query and analyze packages added in v0.2.0: - Graph traversal: BFS, DFS, path finding - Graph analysis: hub detection, community detection, diff Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3661f45 commit 8372707

File tree

6 files changed

+284
-2
lines changed

6 files changed

+284
-2
lines changed

CHANGELOG.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55
"versioning": "semver",
66
"commitConvention": "conventional",
77
"releases": [
8+
{
9+
"version": "v0.2.0",
10+
"date": "2026-04-11",
11+
"highlights": [
12+
{ "description": "Graph traversal algorithms (BFS, DFS, path finding) in new `query` package" },
13+
{ "description": "Graph analysis: hub detection, community detection (Louvain), diff comparison" }
14+
],
15+
"added": [
16+
{ "description": "`query.Traverser` with BFS, DFS, and FindPath methods", "commit": "3661f45" },
17+
{ "description": "`query.Direction` enum: Outgoing, Incoming, Both", "commit": "3661f45" },
18+
{ "description": "`query.TraversalResult` with visited nodes, edges, depth tracking", "commit": "3661f45" },
19+
{ "description": "`analyze.FindHubs` to identify highly connected nodes", "commit": "3661f45" },
20+
{ "description": "`analyze.IsolatedNodes` to find weakly connected nodes", "commit": "3661f45" },
21+
{ "description": "`analyze.DetectCommunities` using Louvain algorithm", "commit": "3661f45" },
22+
{ "description": "`analyze.DiffGraphs` to compare graph snapshots", "commit": "3661f45" },
23+
{ "description": "`analyze.CohesionScore` for community density measurement", "commit": "3661f45" },
24+
{ "description": "`analyze.NodesByType` and `EdgesByType` grouping functions", "commit": "3661f45" },
25+
{ "description": "`analyze.EdgesByConfidence` for confidence-level grouping", "commit": "3661f45" }
26+
],
27+
"dependencies": [
28+
{ "description": "Added gonum.org/v1/gonum v0.17.0 for Louvain algorithm", "commit": "3661f45" }
29+
]
30+
},
831
{
932
"version": "v0.1.0",
1033
"date": "2026-04-11",

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ and this changelog is generated by [Structured Changelog](https://github.com/gro
99

1010
## [Unreleased]
1111

12+
## [v0.2.0] - 2026-04-11
13+
14+
### Highlights
15+
16+
- Graph traversal algorithms (BFS, DFS, path finding) in new `query` package
17+
- Graph analysis: hub detection, community detection (Louvain), diff comparison
18+
19+
### Added
20+
21+
- `query.Traverser` with BFS, DFS, and FindPath methods ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
22+
- `query.Direction` enum: Outgoing, Incoming, Both ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
23+
- `query.TraversalResult` with visited nodes, edges, depth tracking ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
24+
- `analyze.FindHubs` to identify highly connected nodes ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
25+
- `analyze.IsolatedNodes` to find weakly connected nodes ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
26+
- `analyze.DetectCommunities` using Louvain algorithm ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
27+
- `analyze.DiffGraphs` to compare graph snapshots ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
28+
- `analyze.CohesionScore` for community density measurement ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
29+
- `analyze.NodesByType` and `EdgesByType` grouping functions ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
30+
- `analyze.EdgesByConfidence` for confidence-level grouping ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
31+
32+
### Dependencies
33+
34+
- Added gonum.org/v1/gonum v0.17.0 for Louvain algorithm ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
35+
1236
## [v0.1.0] - 2026-04-11
1337

1438
### Highlights
@@ -48,5 +72,6 @@ and this changelog is generated by [Structured Changelog](https://github.com/gro
4872
- GitHub Actions CI workflows ([`4cd92d1`](https://github.com/plexusone/graphfs/commit/4cd92d1))
4973
- MIT License ([`88d89dd`](https://github.com/plexusone/graphfs/commit/88d89dd))
5074

51-
[unreleased]: https://github.com/plexusone/graphfs/compare/v0.1.0...HEAD
75+
[unreleased]: https://github.com/plexusone/graphfs/compare/v0.2.0...HEAD
76+
[v0.2.0]: https://github.com/plexusone/graphfs/compare/v0.1.0...v0.2.0
5277
[v0.1.0]: https://github.com/plexusone/graphfs/releases/tag/v0.1.0

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Git-friendly filesystem graph database with one-file-per-entity storage for mini
3434
- 🎯 **Confidence levels** - Support for EXTRACTED (AST), INFERRED (LLM), and AMBIGUOUS relationships
3535
- 🔌 **Pluggable storage** - `Store` interface for custom backends
3636
-**Schema validation** - Validate nodes, edges, and referential integrity
37+
- 🔍 **Graph traversal** - BFS, DFS, and path finding algorithms
38+
- 📊 **Graph analysis** - Hub detection, community detection (Louvain), graph diff
3739

3840
## Installation
3941

@@ -106,6 +108,47 @@ for _, err := range errs {
106108
}
107109
```
108110

111+
### Graph Traversal
112+
113+
```go
114+
import "github.com/plexusone/graphfs/pkg/query"
115+
116+
// Create a traverser from a graph
117+
traverser := query.NewTraverser(g)
118+
119+
// BFS traversal from a node
120+
result := traverser.BFS("func_main", query.Outgoing, 3, nil)
121+
fmt.Printf("Visited %d nodes\n", len(result.Visited))
122+
123+
// Find path between nodes
124+
path := traverser.FindPath("func_main", "func_helper", nil)
125+
fmt.Printf("Path: %v\n", path.Visited)
126+
127+
// DFS with edge type filter
128+
result = traverser.DFS("func_main", query.Both, 5, []string{"calls"})
129+
```
130+
131+
### Graph Analysis
132+
133+
```go
134+
import "github.com/plexusone/graphfs/pkg/analyze"
135+
136+
// Find hub nodes (most connected)
137+
hubs := analyze.FindHubs(nodes, edges, 10, []string{"package", "file"})
138+
for _, hub := range hubs {
139+
fmt.Printf("%s: %d connections\n", hub.Label, hub.Total)
140+
}
141+
142+
// Detect communities using Louvain algorithm
143+
result := analyze.DetectCommunities(nodes, edges)
144+
fmt.Printf("Found %d communities, modularity: %.3f\n",
145+
len(result.Communities), result.Modularity)
146+
147+
// Compare two graph snapshots
148+
diff := analyze.DiffGraphs(oldNodes, newNodes, oldEdges, newEdges)
149+
fmt.Printf("Changes: %s\n", diff.Summary)
150+
```
151+
109152
## Storage Format
110153

111154
### Nodes

docs/api-reference.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,167 @@ Structured validation error with field name and message.
250250

251251
- `from` node must exist in graph
252252
- `to` node must exist in graph
253+
254+
---
255+
256+
## Package `query`
257+
258+
Graph traversal algorithms.
259+
260+
### Traverser
261+
262+
```go
263+
type Traverser struct {
264+
// private fields
265+
}
266+
267+
func NewTraverser(g *graph.Graph) *Traverser
268+
func NewTraverserFromEdges(edges []*graph.Edge, nodes map[string]*graph.Node) *Traverser
269+
```
270+
271+
Creates a traverser for graph exploration.
272+
273+
### Direction
274+
275+
```go
276+
type Direction int
277+
278+
const (
279+
Outgoing Direction = iota // Follow edges from source to target
280+
Incoming // Follow edges from target to source
281+
Both // Follow edges in both directions
282+
)
283+
```
284+
285+
### TraversalResult
286+
287+
```go
288+
type TraversalResult struct {
289+
StartNode string // Node where traversal began
290+
Visited []string // Visited node IDs in order
291+
Edges []*graph.Edge // Traversed edges
292+
Depth map[string]int // Node ID to depth from start
293+
Parents map[string]*graph.Edge // Node ID to edge that led to it
294+
}
295+
```
296+
297+
### Traversal Methods
298+
299+
| Method | Signature | Description |
300+
|--------|-----------|-------------|
301+
| `BFS` | `func (t *Traverser) BFS(start string, dir Direction, maxDepth int, edgeTypes []string) *TraversalResult` | Breadth-first search |
302+
| `DFS` | `func (t *Traverser) DFS(start string, dir Direction, maxDepth int, edgeTypes []string) *TraversalResult` | Depth-first search |
303+
| `FindPath` | `func (t *Traverser) FindPath(from, to string, edgeTypes []string) *TraversalResult` | Find shortest path |
304+
305+
**Parameters:**
306+
307+
| Parameter | Description |
308+
|-----------|-------------|
309+
| `start` | Starting node ID |
310+
| `dir` | Traversal direction (Outgoing, Incoming, Both) |
311+
| `maxDepth` | Maximum traversal depth (0 = default 100) |
312+
| `edgeTypes` | Filter by edge types (nil = all types) |
313+
314+
---
315+
316+
## Package `analyze`
317+
318+
Graph analysis algorithms.
319+
320+
### Hub Detection
321+
322+
```go
323+
type HubNode struct {
324+
ID string
325+
Label string
326+
Type string
327+
InDegree int
328+
OutDegree int
329+
Total int
330+
}
331+
332+
func FindHubs(nodes []*graph.Node, edges []*graph.Edge, topN int, excludeTypes []string) []HubNode
333+
func IsolatedNodes(nodes []*graph.Node, edges []*graph.Edge, threshold int, excludeTypes []string) []*graph.Node
334+
```
335+
336+
| Function | Description |
337+
|----------|-------------|
338+
| `FindHubs` | Returns top N most connected nodes |
339+
| `IsolatedNodes` | Returns nodes with degree <= threshold |
340+
341+
### Community Detection
342+
343+
```go
344+
type Community struct {
345+
ID int
346+
Size int
347+
Cohesion float64
348+
Members []string
349+
Label string
350+
}
351+
352+
type ClusterResult struct {
353+
Communities []Community
354+
NodeCommunity map[string]int
355+
Modularity float64
356+
}
357+
358+
func DetectCommunities(nodes []*graph.Node, edges []*graph.Edge) *ClusterResult
359+
func DetectCommunitiesWithOptions(nodes []*graph.Node, edges []*graph.Edge, opts ClusterOptions) *ClusterResult
360+
```
361+
362+
Uses the Louvain algorithm for modularity optimization.
363+
364+
### ClusterOptions
365+
366+
```go
367+
type ClusterOptions struct {
368+
Algorithm ClusterAlgorithm // "louvain" or "components"
369+
Resolution float64 // Higher = smaller communities (default 1.0)
370+
ExcludeEdgeTypes []string // Edge types to ignore
371+
ExcludeNodeTypes []string // Node types to ignore
372+
}
373+
374+
func DefaultClusterOptions() ClusterOptions
375+
```
376+
377+
### Graph Diff
378+
379+
```go
380+
type GraphDiff struct {
381+
NewNodes []NodeChange
382+
RemovedNodes []NodeChange
383+
NewEdges []EdgeChange
384+
RemovedEdges []EdgeChange
385+
Summary string
386+
}
387+
388+
type NodeChange struct {
389+
ID string
390+
Label string
391+
Type string
392+
}
393+
394+
type EdgeChange struct {
395+
From string
396+
To string
397+
Type string
398+
Confidence string
399+
}
400+
401+
func DiffGraphs(oldNodes, newNodes []*graph.Node, oldEdges, newEdges []*graph.Edge) *GraphDiff
402+
```
403+
404+
Compares two graph snapshots and returns changes.
405+
406+
### Utility Functions
407+
408+
| Function | Signature | Description |
409+
|----------|-----------|-------------|
410+
| `NodesByType` | `func NodesByType(nodes []*graph.Node) map[string][]*graph.Node` | Group nodes by type |
411+
| `EdgesByType` | `func EdgesByType(edges []*graph.Edge) map[string][]*graph.Edge` | Group edges by type |
412+
| `EdgesByConfidence` | `func EdgesByConfidence(edges []*graph.Edge) map[graph.Confidence][]*graph.Edge` | Group edges by confidence |
413+
| `CohesionScore` | `func CohesionScore(members []string, adj map[string]map[string]bool) float64` | Calculate community density |
414+
| `HubScore` | `func HubScore(nodeID string, edges []*graph.Edge) int` | Calculate out-degree |
415+
| `AuthorityScore` | `func AuthorityScore(nodeID string, edges []*graph.Edge) int` | Calculate in-degree |
416+
| `InferredEdges` | `func InferredEdges(edges []*graph.Edge) []*graph.Edge` | Get INFERRED/AMBIGUOUS edges |

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ GraphFS is a Go library for storing and querying graph data using the filesystem
1818
- **Confidence levels** - Support for EXTRACTED (AST), INFERRED (LLM), and AMBIGUOUS relationships
1919
- **Pluggable storage** - `Store` interface for custom backends
2020
- **Schema validation** - Validate nodes, edges, and referential integrity
21+
- **Graph traversal** - BFS, DFS, and path finding algorithms
22+
- **Graph analysis** - Hub detection, community detection (Louvain), graph diff
2123

2224
## Quick Example
2325

docs/releases/changelog.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ and this changelog is generated by [Structured Changelog](https://github.com/gro
99

1010
## [Unreleased]
1111

12+
## [v0.2.0] - 2026-04-11
13+
14+
### Highlights
15+
16+
- Graph traversal algorithms (BFS, DFS, path finding) in new `query` package
17+
- Graph analysis: hub detection, community detection (Louvain), diff comparison
18+
19+
### Added
20+
21+
- `query.Traverser` with BFS, DFS, and FindPath methods ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
22+
- `query.Direction` enum: Outgoing, Incoming, Both ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
23+
- `query.TraversalResult` with visited nodes, edges, depth tracking ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
24+
- `analyze.FindHubs` to identify highly connected nodes ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
25+
- `analyze.IsolatedNodes` to find weakly connected nodes ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
26+
- `analyze.DetectCommunities` using Louvain algorithm ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
27+
- `analyze.DiffGraphs` to compare graph snapshots ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
28+
- `analyze.CohesionScore` for community density measurement ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
29+
- `analyze.NodesByType` and `EdgesByType` grouping functions ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
30+
- `analyze.EdgesByConfidence` for confidence-level grouping ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
31+
32+
### Dependencies
33+
34+
- Added gonum.org/v1/gonum v0.17.0 for Louvain algorithm ([`3661f45`](https://github.com/plexusone/graphfs/commit/3661f45))
35+
1236
## [v0.1.0] - 2026-04-11
1337

1438
### Highlights
@@ -48,5 +72,6 @@ and this changelog is generated by [Structured Changelog](https://github.com/gro
4872
- GitHub Actions CI workflows ([`4cd92d1`](https://github.com/plexusone/graphfs/commit/4cd92d1))
4973
- MIT License ([`88d89dd`](https://github.com/plexusone/graphfs/commit/88d89dd))
5074

51-
[unreleased]: https://github.com/plexusone/graphfs/compare/v0.1.0...HEAD
75+
[unreleased]: https://github.com/plexusone/graphfs/compare/v0.2.0...HEAD
76+
[v0.2.0]: https://github.com/plexusone/graphfs/compare/v0.1.0...v0.2.0
5277
[v0.1.0]: https://github.com/plexusone/graphfs/releases/tag/v0.1.0

0 commit comments

Comments
 (0)