@@ -14,75 +14,30 @@ A modern, header-only C++11 library for graph construction and pathfinding algor
1414- ** Robust** : Comprehensive exception handling, structure validation, memory safety via RAII
1515- ** Well-Documented** : Extensive API reference, tutorials, and working examples
1616
17- ---
18-
19- ## Quick Start (5 minutes)
20-
21- ### Installation
22- ``` bash
23- # Header-only - just copy and include
24- git clone https://github.com/rxdu/libgraph.git
25- cp -r libgraph/include/graph /your/project/
26-
27- # OR: System install with CMake
28- mkdir build && cd build && cmake .. && sudo make install
17+ ### Generic State Types
18+ ``` cpp
19+ struct GameState {
20+ int x, y, health, ammo;
21+ int64_t GetId() const { return y* 1000 + x; } // Auto-detected by DefaultIndexer
22+ };
23+ Graph<GameState > game_world;
2924```
3025
31- ### Your First Graph
26+ ### Custom Cost Types
3227```cpp
33- #include " graph/graph.hpp"
34- #include " graph/search/dijkstra.hpp"
35-
36- struct Location { int id; std::string name; };
37-
38- // Create graph and add vertices
39- Graph<Location > map;
40- map.AddVertex({0, "Home"});
41- map.AddVertex({1, "Work"});
42- map.AddVertex({2, "Store"});
43-
44- // Add weighted edges (distances)
45- map.AddEdge({0, "Home"}, {1, "Work"}, 5.0);
46- map.AddEdge({0, "Home"}, {2, "Store"}, 3.0);
47- map.AddEdge({2, "Store"}, {1, "Work"}, 4.0);
48-
49- // Find optimal path
50- auto path = Dijkstra::Search(map, {0, "Home"}, {1, "Work"});
51- // Result: Home -> Store -> Work (7km total, shorter than direct 5km route)
28+ struct TravelCost {
29+ double time, distance, comfort;
30+ bool operator<(const TravelCost& other) const { /* lexicographic comparison */ }
31+ };
32+ Graph<Location, TravelCost> multi_criteria_graph;
5233```
5334
54- **[Complete Getting Started Guide →](docs/getting_started.md)**
55-
56- ---
57-
58- ## Documentation
59-
60- ### **For New Users**
61- - **[Getting Started Guide](docs/getting_started.md)** - From zero to working graph in 20 minutes
62- - **[Complete API Reference](docs/api.md)** - All classes, methods, and examples
63- - **[Tutorial Series](docs/tutorials/)** - Progressive learning path
64-
65- ### **For Advanced Users**
66- - **[Architecture Overview](docs/architecture.md)** - System design and template patterns
67- - **[Advanced Features](docs/advanced_features.md)** - Custom costs, validation, thread safety
68- - **[Search Algorithms Guide](docs/search_algorithms.md)** - Deep dive into A*, Dijkstra, BFS, DFS
69-
70- ### **For Contributors**
71- - **[Performance Testing](docs/performance_testing.md)** - Benchmarking and optimization
72- - **[Thread Safety Design](docs/thread_safety_design.md)** - Concurrent search architecture
73- - **[Search Framework](docs/search_framework.md)** - Modern strategy pattern implementation
74-
75- ---
76-
77- ## Use Cases & Applications
78-
79- | **Domain** | **Use Case** | **Algorithm** | **Key Feature** |
80- |------------|--------------|---------------|-----------------|
81- | **Game Development** | NPC pathfinding, map navigation | A* with heuristics | Grid-based movement, obstacle avoidance |
82- | **Robotics** | Motion planning, SLAM | Dijkstra, A* | Real-time path updates, dynamic costs |
83- | **GPS Navigation** | Route planning, traffic optimization | Dijkstra with custom costs | Multi-criteria optimization (time, distance, cost) |
84- | **Network Analysis** | Social graphs, web crawling | BFS, DFS | Large-scale graph traversal |
85- | **Data Science** | Dependency analysis, workflow management | Topological sort, DFS | DAG processing, cycle detection |
35+ ### Performance Optimization
36+ ``` cpp
37+ graph.reserve(10000 ); // Pre-allocate vertices
38+ context.PreAllocate(10000 ); // Pre-allocate search state
39+ graph.AddVertices(state_list); // Batch operations
40+ ```
8641
8742---
8843
@@ -100,7 +55,7 @@ template<typename State, typename Transition = double, typename StateIndexer = D
10055class Graph ;
10156```
10257- ** State** : Your vertex data (locations, game states, etc.)
103- - ** Transition** : Edge weights (distance, time, cost, custom types)
58+ - ** Transition** : Edge weights (distance, time, cost, custom types)
10459- ** StateIndexer** : Automatic ID generation from states
10560
10661### Performance Characteristics
@@ -113,9 +68,7 @@ Optimal space complexity O(m+n) using adjacency lists:
11368| Search Algorithms | O((m+n) log n) | O(n) |
11469| Thread-Safe Search | O((m+n) log n) | O(n) per context |
11570
116- ---
117-
118- ## Thread Safety
71+ ### Thread Safety
11972
12073** Concurrent read-only searches** are fully supported:
12174``` cpp
@@ -130,35 +83,6 @@ void worker_thread(const Graph<Location>& map) {
13083
13184---
13285
133- ## Advanced Features
134-
135- ### Custom Cost Types
136- ```cpp
137- struct TravelCost {
138- double time, distance, comfort;
139- bool operator<(const TravelCost& other) const { /* lexicographic comparison */ }
140- };
141- Graph<Location, TravelCost> multi_criteria_graph;
142- ```
143-
144- ### Generic State Types
145- ``` cpp
146- struct GameState {
147- int x, y, health, ammo;
148- int64_t GetId() const { return y* 1000 + x; } // Auto-detected by DefaultIndexer
149- };
150- Graph<GameState > game_world;
151- ```
152-
153- ### Performance Optimization
154- ```cpp
155- graph.reserve(10000); // Pre-allocate vertices
156- context.PreAllocate(10000); // Pre-allocate search state
157- graph.AddVertices(state_list); // Batch operations
158- ```
159-
160- ---
161-
16286## Build & Integration
16387
16488### Requirements
@@ -168,7 +92,7 @@ graph.AddVertices(state_list); // Batch operations
16892
16993### Integration Options
17094
171- #### 1. Header-Only (Recommended)
95+ #### 1. Header-Only
17296```bash
17397git clone https://github.com/rxdu/libgraph.git
17498cp -r libgraph/include/graph /your/project/include/
@@ -196,6 +120,13 @@ find_package(graph REQUIRED)
196120target_link_libraries(your_app PRIVATE xmotion::graph)
197121```
198122
123+ #### 4. Debian Package Installation
124+ ``` bash
125+ mkdir build && cd build
126+ cmake -DCMAKE_BUILD_TYPE=Release .. && make -j4 && cpack
127+ sudo dpkg -i graph_3.0.0_amd64.deb # Adjust version as needed
128+ ```
129+
199130### Build Examples and Tests
200131``` bash
201132git clone --recursive https://github.com/rxdu/libgraph.git
@@ -211,90 +142,49 @@ cmake --build .
211142./bin/utests
212143```
213144
214- ---
215-
216- ## Performance Testing
217-
218- This library includes comprehensive performance benchmarks to evaluate graph operations and search algorithms across different scales.
145+ ### Your First Graph
146+ ``` cpp
147+ #include " graph/graph.hpp"
148+ #include " graph/search/dijkstra.hpp"
219149
220- ### Quick Performance Test
150+ struct Location { int id; std::string name; };
221151
222- Run the unified benchmark suite to get a complete performance analysis:
152+ // Create graph and add vertices
153+ Graph<Location > map;
154+ map.AddVertex({0, "Home"});
155+ map.AddVertex({1, "Work"});
156+ map.AddVertex({2, "Store"});
223157
224- ``` bash
225- # Build the library with benchmarks
226- mkdir build && cd build
227- cmake -DBUILD_TESTING=ON ..
228- cmake --build .
158+ // Add weighted edges (distances)
159+ map.AddEdge({0, "Home"}, {1, "Work"}, 5.0);
160+ map.AddEdge({0, "Home"}, {2, "Store"}, 3.0);
161+ map.AddEdge({2, "Store"}, {1, "Work"}, 4.0);
229162
230- # Run comprehensive performance tests
231- ../scripts/run_unified_benchmarks.sh
163+ // Find optimal path
164+ auto path = Dijkstra::Search(map, {0, "Home"}, {1, "Work"});
165+ // Result: Home -> Store -> Work (7km total, shorter than direct 5km route)
232166```
233167
234- The benchmark generates a single comprehensive report file that includes:
235-
236- - ** Micro-benchmarks** : Operation-level performance analysis (edge lookup, vertex removal, search context)
237- - ** Large-scale benchmarks** : Realistic workload testing (10K-1M+ vertices)
238- - ** Memory scaling** : Memory usage patterns by graph size
239- - ** Concurrent performance** : Multi-threaded search throughput
240- - ** Optimization targets** : Specific recommendations with expected improvements
241-
242- ### Performance Results
243-
244- The test outputs results to ` performance_results/unified_benchmark_results_<timestamp>.txt ` with sections:
245-
246- 1 . ** Edge Lookup Performance** : Current O(n) linear search analysis
247- 2 . ** Vertex Removal Performance** : Current O(m²) removal operation analysis
248- 3 . ** Search Context Performance** : Memory allocation vs. reuse patterns
249- 4 . ** Concurrent Search Performance** : Threading scalability analysis
250- 5 . ** Graph Construction Performance** : Large-scale graph creation benchmarks
251- 6 . ** Search Algorithm Scaling** : Dijkstra/BFS/DFS performance comparison
252- 7 . ** Memory Scaling Analysis** : Memory efficiency by graph size
253- 8 . ** Optimization Recommendations** : Specific targets for performance improvements
254-
255- ### System Requirements
256-
257- - ** Memory** : 2GB+ recommended for large-scale tests
258- - ** CPU** : Multi-core recommended for concurrent benchmarks
259- - ** Time** : 2-5 minutes depending on system performance
260-
261- ### Using Results for Optimization
262-
263- The benchmark results serve as baseline measurements for quantitative evaluation of performance optimizations:
264-
265- 1 . ** Save baseline** : Keep initial benchmark results for comparison
266- 2 . ** Implement optimization** : Make targeted improvements (e.g., hash-based edge lookup)
267- 3 . ** Re-run benchmarks** : Execute the same test suite
268- 4 . ** Compare results** : Analyze performance improvements quantitatively
269-
270- Example optimization targets identified:
271- - ** Edge Lookup** : O(n) → O(1) hash-based lookup (10-100x improvement expected)
272- - ** Vertex Removal** : O(m²) → O(m) bidirectional references (2-10x improvement expected)
273- - ** Memory Pooling** : Reduce context allocation overhead (20-50% improvement expected)
274- - ** Context Reuse** : Systematic reuse patterns (30-70% improvement expected)
168+ **[Complete Getting Started Guide →](docs/getting_started.md)**
275169
276170---
277171
278- ## Project Status & Quality
279-
280- ### ** Mature & Production-Ready**
281- - ** 199 comprehensive tests** (100% pass rate, 1 disabled)
282- - ** Complete algorithm suite** : A* , Dijkstra, BFS, DFS with unified framework
283- - ** Thread-safe concurrent searches** with external SearchContext
284- - ** Generic cost framework** with custom comparators and lexicographic costs
285- - ** Enterprise-grade error handling** with 7-tier exception hierarchy
172+ ## Documentation
286173
287- ### ** Recent Milestones ** (2025)
288- - ** Phase 3 Complete ** : Generic cost types, enhanced testing, sample modernization
289- - ** Phase 2 Complete ** : Performance optimization (35% improvement), STL compatibility
290- - ** Phase 1 Complete ** : Unified search framework eliminating 70% code duplication
174+ ### **For New Users**
175+ - **[Getting Started Guide](docs/getting_started.md)** - From zero to working graph in 20 minutes
176+ - **[Complete API Reference](docs/api.md)** - All classes, methods, and examples
177+ - **[Tutorial Series](docs/tutorials/)** - Progressive learning path
291178
292- ### ** Current Focus ** (Phase 4)
293- - Graph analysis algorithms (connected components, cycle detection)
294- - Enhanced search variants (early termination, hop limits)
295- - Extended graph operations (statistics, subgraph extraction)
179+ ### **For Advanced Users**
180+ - **[Architecture Overview](docs/architecture.md)** - System design and template patterns
181+ - **[Advanced Features](docs/advanced_features.md)** - Custom costs, validation, thread safety
182+ - **[Search Algorithms Guide](docs/search_algorithms.md)** - Deep dive into A*, Dijkstra, BFS, DFS
296183
297- ** [ Complete Roadmap & TODO List →] ( TODO.md ) **
184+ ### **For Contributors**
185+ - **[Performance Testing](docs/performance_testing.md)** - Benchmarking and optimization
186+ - **[Thread Safety Design](docs/thread_safety_design.md)** - Concurrent search architecture
187+ - **[Search Framework](docs/search_framework.md)** - Modern strategy pattern implementation
298188
299189---
300190
@@ -324,6 +214,8 @@ This library is distributed under **MIT License**.
324214}
325215```
326216
217+ ** [ → Complete Roadmap & TODO List] ( TODO.md ) **
218+
327219---
328220
329221** Built for the C++ community**
0 commit comments