# gdf
Python package to read and write network graphs in GDF (Graph Data Format).
### Requirements
* **Python 3**
* networkx>=2.3
* pandas>=0.25.3
### Usage
Just two functions are implemented, for reading from and writing data to file.
```
from gdf import read_gdf, write_gdf
# Builds NetworkX graph object from file.
G = read_gdf("input_file.gdf")
# Writes NetworkX graph object to file.
write_gdf(G, "output_file.gdf)
```
#### Detailed usage
A few additional arguments are available both for reading and writing files:
##### Building NetworkX graph object from file
```
G = read_gdf(
"input_file.gdf",
# Required; file path to read data from.
directed=None,
# Optional; consider graph edges as directed or undirected.
# True: returns a <nx.DiGraph> or <nx.MultiDiGraph> object.
# False: returns a <nx.Graph> or <nx.MultiGraph> object.
# None (default): decides based on "directed" field in file.
multigraph=None,
# Optional; consider multiple or single edges among nodes.
# True: always returns a <nx.MultiGraph> or <nx.MultiDiGraph> object.
# False: sums edge weights and returns a <nx.Graph> or <nx.DiGraph> object.
# None (default): only returns a multiplex graph if multiple edges are found.
node_attr=True,
# Optional; node attributes to import data from.
# Accepts either a [list] containing attribute names or a bool (True, False).
# Defaults to True, which considers all node attributes.
edge_attr=True,
# Optional; edge attributes to import data from.
# Accepts either a [list] containing attribute names or a bool (True, False).
# Defaults to True, which considers all edge attributes.
)
```
##### Writing NetworkX graph object to file
```
write_gdf(
G,
# Required; graph object from NetworkX.
"output_file.gdf",
# Required; file path to read data from.
node_attr=True,
# Optional; node attributes to export data from.
# Accepts either a [list] containing attribute names or a bool (True, False).
# Defaults to True, which considers all node attributes.
edge_attr=True,
# Optional; edge attributes to export data from.
# Accepts either a [list] containing attribute names or a bool (True, False).
# Defaults to True, which considers all edge attributes.
)
```
### Importing as a class
Alternatively, the module can also be imported as a class, e.g., for inheriting it:
```
from gdf import GDF
class MyClass(GDF):
...
```
___
### References
* [NetworkX](https://networkx.github.io)
* [Pandas](https://pandas.pydata.org/)
Raw data
{
"_id": null,
"home_page": "https://github.com/nelsonaloysio/gdf",
"name": "gdf",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": "",
"keywords": "GDF,Graph,Network,NetworkX",
"author": "Nelson Aloysio Reis de Almeida Passos",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/96/b8/efb90433a6e61e5776c9f1458ab6589bc269ef614edddb109c3ac57c5419/gdf-1.0.1.tar.gz",
"platform": null,
"description": "# gdf\n\nPython package to read and write network graphs in GDF (Graph Data Format).\n\n### Requirements\n\n* **Python 3**\n* networkx>=2.3\n* pandas>=0.25.3\n\n### Usage\n\nJust two functions are implemented, for reading from and writing data to file.\n\n```\nfrom gdf import read_gdf, write_gdf\n\n# Builds NetworkX graph object from file.\nG = read_gdf(\"input_file.gdf\")\n\n# Writes NetworkX graph object to file.\nwrite_gdf(G, \"output_file.gdf)\n```\n\n#### Detailed usage\n\nA few additional arguments are available both for reading and writing files:\n\n##### Building NetworkX graph object from file\n\n```\nG = read_gdf(\n \"input_file.gdf\",\n # Required; file path to read data from.\n\n directed=None,\n # Optional; consider graph edges as directed or undirected.\n # True: returns a <nx.DiGraph> or <nx.MultiDiGraph> object.\n # False: returns a <nx.Graph> or <nx.MultiGraph> object.\n # None (default): decides based on \"directed\" field in file.\n\n multigraph=None,\n # Optional; consider multiple or single edges among nodes.\n # True: always returns a <nx.MultiGraph> or <nx.MultiDiGraph> object.\n # False: sums edge weights and returns a <nx.Graph> or <nx.DiGraph> object.\n # None (default): only returns a multiplex graph if multiple edges are found.\n\n node_attr=True,\n # Optional; node attributes to import data from.\n # Accepts either a [list] containing attribute names or a bool (True, False).\n # Defaults to True, which considers all node attributes.\n\n edge_attr=True,\n # Optional; edge attributes to import data from.\n # Accepts either a [list] containing attribute names or a bool (True, False).\n # Defaults to True, which considers all edge attributes.\n)\n```\n\n##### Writing NetworkX graph object to file\n\n```\nwrite_gdf(\n G,\n # Required; graph object from NetworkX.\n\n \"output_file.gdf\",\n # Required; file path to read data from.\n\n node_attr=True,\n # Optional; node attributes to export data from.\n # Accepts either a [list] containing attribute names or a bool (True, False).\n # Defaults to True, which considers all node attributes.\n\n edge_attr=True,\n # Optional; edge attributes to export data from.\n # Accepts either a [list] containing attribute names or a bool (True, False).\n # Defaults to True, which considers all edge attributes.\n)\n```\n\n### Importing as a class\n\nAlternatively, the module can also be imported as a class, e.g., for inheriting it:\n\n```\nfrom gdf import GDF\n\nclass MyClass(GDF):\n ...\n```\n\n___\n\n### References\n\n* [NetworkX](https://networkx.github.io)\n* [Pandas](https://pandas.pydata.org/)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python package to read and write network graphs in GDF (Graph Data Format).",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/nelsonaloysio/gdf",
"Source": "https://github.com/nelsonaloysio/gdf",
"Tracker": "https://github.com/nelsonaloysio/gdf/issues"
},
"split_keywords": [
"gdf",
"graph",
"network",
"networkx"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d3c503e72cb81903c9ab8e2817b844863832934ad1319356662855ad805b96c",
"md5": "bae17d58925fee496885ff8a1c6a0c32",
"sha256": "07d937d6c2490ebb49516e4e89a8d4e81f1ad31028930b6ed8519933994e3a44"
},
"downloads": -1,
"filename": "gdf-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bae17d58925fee496885ff8a1c6a0c32",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 4708,
"upload_time": "2023-08-06T00:35:45",
"upload_time_iso_8601": "2023-08-06T00:35:45.359475Z",
"url": "https://files.pythonhosted.org/packages/8d/3c/503e72cb81903c9ab8e2817b844863832934ad1319356662855ad805b96c/gdf-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "96b8efb90433a6e61e5776c9f1458ab6589bc269ef614edddb109c3ac57c5419",
"md5": "f868b2c3accfe682a3d03bba57987d31",
"sha256": "f447af1c6e32fb7a465a9f123f7e91f24d1e7e4e81dafcf1292f71b4ade1c3ed"
},
"downloads": -1,
"filename": "gdf-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "f868b2c3accfe682a3d03bba57987d31",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 4624,
"upload_time": "2023-08-06T00:35:46",
"upload_time_iso_8601": "2023-08-06T00:35:46.755953Z",
"url": "https://files.pythonhosted.org/packages/96/b8/efb90433a6e61e5776c9f1458ab6589bc269ef614edddb109c3ac57c5419/gdf-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-06 00:35:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nelsonaloysio",
"github_project": "gdf",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "gdf"
}