Fast Graph Algorithms Library implemented in C++
Project description
fastgraphFPMS
fastgraphFPMS is a Python library for graph theory and algorithms, built with a high-performance C++ core.
It provides a flexible way to load graphs from files (multiple formats supported) and run many classical graph algorithms efficiently from Python.
Installation
Install directly from PyPI:
pip install fastgraphFPMS
Requirements:
- Python 3.8+
- (Automatically handled) precompiled C++ extension for your platform
Features
-
Multiple input formats (auto-detected):
- Adjacency matrix
- CSR 3-list format (
HeadSucc,Succ,WeightsSucc) - Explicit edge triples (
u v w) - Per-line adjacency list (
u v w v w …)
-
Efficient CSR backend in C++ (
HeadSucc,Succ,WeightsSucc) with automatic predecessors construction -
Algorithms included:
- Connected components (CC), strongly connected components (SCC)
- Bipartiteness checks
- Minimum spanning tree: Prim, Kruskal
- Shortest paths: Dijkstra (variants), Bellman–Ford, Sedgewick–Vitter
- All pairs shortest paths: Floyd–Warshall
- Eulerian path / circuit
- Hamiltonian path / circuit
- Graph coloring heuristics (Greedy, Welsh–Powell, DSATUR, chromatic helpers)
- Max flow: Ford–Fulkerson, Edmonds–Karp
- Traversals: BFS, DFS
Usage example (Python)
from fastgraphFPMS import Graph
# Load a graph from file (auto-detected format)
g = Graph("examples/csr_three_line.txt")
print("Number of nodes:", g.num_nodes)
# Connected components
cc_count, cc_nodes = g.find_cc()
print("Connected components:", cc_count)
# Dijkstra from node 0
distances, predecessors = g.dijkstra(0)
print("Shortest path to node 3:", distances[3])
Supported file formats
1) CSR three-line format
0 2 5 6 8 9 9
1 3 2 3 4 5 2 4 5
2 4 1 2 2 2 2 1 2
2) Adjacency matrix
6
0 2 0 4 0 0
0 0 1 2 2 0
0 0 0 0 0 2
0 0 2 0 1 0
0 0 0 0 0 2
0 0 0 0 0 0
3) Explicit triples
6
0 1 2
0 3 4
1 2 1
4) Per-line adjacency lists
0 1 2 3 4
1 2 1 3 2
Build from source
If you want to build locally (instead of installing via pip):
git clone <repo-url>
cd fastgraphFPMS
pip install .
This will build the C++ core with pybind11 and install the Python package.
Contributing
Contributions are welcome! Ideas:
- Extend algorithm coverage
- Improve Pythonic API
- Add more graph input/output formats
- Documentation and tutorials
Please open an issue or PR in the repository.
License
Copyright (c) 2025 Drogo Flavio
Permission est hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastgraphfpms-1.0.5.tar.gz.
File metadata
- Download URL: fastgraphfpms-1.0.5.tar.gz
- Upload date:
- Size: 90.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
460eff47eaaa93e0961a5e02ecd7be991c7ee221aae6f65290cb1e27b3c4dc04
|
|
| MD5 |
c49c9ba3cf285f3799f6bf2962a33e62
|
|
| BLAKE2b-256 |
63747903239891fa79e225f2be450f22dc97b420a996b17fb675dc092ff75fcd
|
File details
Details for the file fastgraphfpms-1.0.5-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fastgraphfpms-1.0.5-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 228.1 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7662856b88b4a077c98259c34f838eb07d7c9c915e9b8a9165bfab70aa2020fd
|
|
| MD5 |
3946993ec4353b2de6745dfbdfbd5a31
|
|
| BLAKE2b-256 |
8b30f4c9d05f212453bd5bae2adda20606fb5a6e267cebc67a40f39efc4b8cd1
|