{"id":27641,"library":"cfgraph","title":"CFGraph","description":"CFGraph is a Python library that provides a flattening graph for RDFlib collections, converting RDF collection structures into a simplified graph representation. Version 0.2.1 is the latest release, with an irregular release cadence.","status":"active","version":"0.2.1","language":"python","source_language":"en","source_url":"https://github.com/hsolbrig/CFGraph","tags":["rdf","rdflib","collections","graph-flattening"],"install":[{"cmd":"pip install cfgraph","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"CFGraph requires rdflib to work with RDF graphs.","package":"rdflib","optional":false}],"imports":[{"note":"Flattener is directly exposed from the top-level cfgraph module, not a submodule.","wrong":"from cfgraph.flattener import Flattener","symbol":"Flattener","correct":"from cfgraph import Flattener"},{"note":"The library itself is the module; do not import a nested cfgraph.","wrong":"from cfgraph import cfgraph","symbol":"cfgraph","correct":"import cfgraph"}],"quickstart":{"code":"import rdflib\nfrom cfgraph import Flattener\n\n# Load an RDF graph\ng = rdflib.Graph()\ng.parse('example.ttl', format='turtle')\n\n# Flatten collections\nflattener = Flattener(g)\nflattener.flatten()\n\n# The graph now has flattened collections\nprint(f\"Number of triples after flattening: {len(g)}\")","lang":"python","description":"Basic usage: parse an RDF graph and flatten all collections using the Flattener class."},"warnings":[{"fix":"Use `g2 = rdflib.Graph()` and parse again, or use `g2 = g + g` (but careful with blank nodes).","message":"The Flattener modifies the graph in-place. Make a copy if you need to preserve the original graph.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your data uses the standard RDF collection pattern.","message":"CFGraph only works with RDF collections that follow the standard rdf:first/rdf:rest pattern. Other collection representations are not supported.","severity":"gotcha","affected_versions":"all"},{"fix":"Use with rdflib < 6.0 or test compatibility.","message":"The library has not been updated in several years and may have compatibility issues with newer versions of rdflib (e.g., rdflib >= 6.0).","severity":"deprecated","affected_versions":"0.2.1"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from cfgraph import Flattener`.","cause":"Incorrect import path; Flattener is at cfgraph.Flattener, not cfgraph.flattener.","error":"ImportError: cannot import name 'Flattener' from 'cfgraph'"},{"fix":"Preprocess data to standard RDF collections, or check if your data uses a different collection pattern.","cause":"CFGraph expects standard RDF collection patterns; if your graph does not use rdf:first/rdf:rest, the Flattener may raise this error.","error":"AttributeError: 'Graph' object has no attribute 'first'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}