Registry / data / graph-lib

graph-lib

JSON →
library0.4.8pypypi✓ verified 84d ago

A set of diffusion related graph algorithms for Python, including community detection, node ranking, and graph sampling. Current version 0.4.8. Low release cadence.

pip install graph-lib
INSTALL
IMPORT
SIG · GRAPH-LIB
G
graph-lib
datapythonv0.4.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

graph_lib
import graph_lib
import graphlib
graphlib is a stdlib module (topological sort) completely different from graph-lib

Detect two communities in Zachary's karate club graph using spectral partitioning.

import graph_lib import networkx as nx G = nx.karate_club_graph() communities = graph_lib.spectral_partitioning(G, k=2) print(communities)
Debug
Known issues
deprecatedFunction 'graph_lib.diffusion_map' has been deprecated in v0.4.0. Use 'graph_lib.spectral_embedding' instead.
fix
Replace graph_lib.diffusion_map(G) with graph_lib.spectral_embedding(G, n_components=None)
affects: >=0.4.0
gotchaThe package imports as 'graph_lib' (underscore), not 'graphlib'. Importing 'graphlib' silently imports Python's stdlib module which does not raise an error but gives wrong results.
fix
Use 'import graph_lib' or 'from graph_lib import ...'
affects: all
gotchaGraph algorithms expect node labels to be integers. Non-integer labels may cause silent type errors in internal matrix construction.
fix
Ensure node labels are integers, e.g., G = nx.convert_node_labels_to_integers(G)
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'graphlib'
Trying to import as 'graphlib' which is a stdlib module. The correct import uses underscore: 'graph_lib'.
fix
pip install graph-lib and then import graph_lib (with underscore).
TypeError: unsupported operand type(s) for +: 'int' and 'list'
Passing non-integer node labels that cause internal conversion errors.
fix
Relabel nodes to integers: G = nx.convert_node_labels_to_integers(G)
AttributeError: module 'graph_lib' has no attribute 'diffusion_map'
diffusion_map was removed/deprecated in newer versions. Use spectral_embedding instead.
fix
Use graph_lib.spectral_embedding(G, n_components=None) instead.
Upgrade
Version history
0.4.8latest on PyPI · released Sep 8, 2017
Audit
Dependencies
numpyrequiredCore dependency for numerical operations
networkxrequiredGraph data structures and algorithms
scipyrequiredSparse matrix operations
Agent activity
4 hits · last 30 days
node
4
Resources
graph-lib — pip install graph-lib · libregistry