Skip to main content

About gdflib

gdflib is a Python package made to dump GDF graph files.

Installing

gdflib can be installed from pypi:

easy_install gdflib

or:

pip install gdflib

should just work for most of the users

Usage

Most simple example:

>>> from gdflib import GdfEntries, Node
>>>
>>> entities = GdfEntries()
>>> entities.add_node(Node(name='node1', label='This is the first node'))
>>> entities.add_node(Node(name='node2', label='This is the second node'))
>>> entities.link('node1', 'node2')
>>> print entities.dumps()
nodedef>name , style INT, width DOUBLE, color VARCHAR, image VARCHAR, label VARCHAR, height DOUBLE, visible BOOLEAN, labelcolor VARCHAR, y DOUBLE, x DOUBLE, strokecolor VARCHAR, fixed BOOLEAN, labelvisible BOOLEAN
node1,1,4.000000,cornflowerblue,,'This is the first node',4.000000,true,cornflowerblue,,,cadetblue,false,false
node2,1,4.000000,cornflowerblue,,'This is the second node',4.000000,true,cornflowerblue,,,cadetblue,false,false
edgedef>node1 , node2 , directed BOOLEAN, color VARCHAR, weight DOUBLE, width DOUBLE, label VARCHAR, visible BOOLEAN, labelcolor VARCHAR, labelvisible BOOLEAN
node1,node2,true,dandelion,1.000000,3.000000,'1',true,dandelion,false

By default all nodes implement the standard properties defined for GDF, unspecified properties will get the default value. Custom nodes can be defined through the Declarative interface:

>>> from gdflib import String, Double
>>> from gdflib import GdfEntries, Node
>>>
>>> class Product(Node):
...     company = String(default='Unknown Company')
...     price = Double(required=True)
...
>>> entities = GdfEntries(Product)
>>> entities.add_node(Product(name='node1', company='Custom Company', price=33.10))
>>> entities.add_node(Product(name='node2', label='Low Cost Product', price=18.21))
>>> entities.link('node1', 'node2')
>>> entities.dumps()
nodedef>name , style INT, width DOUBLE, color VARCHAR, image VARCHAR, label VARCHAR, height DOUBLE, visible BOOLEAN, labelcolor VARCHAR, y DOUBLE, x DOUBLE, strokecolor VARCHAR, fixed BOOLEAN, labelvisible BOOLEAN, company VARCHAR, price DOUBLE
node1,1,4.000000,cornflowerblue,,'node1',4.000000,true,cornflowerblue,,,cadetblue,false,false,'Custom Company',33.100000
node2,1,4.000000,cornflowerblue,,'Low Cost Product',4.000000,true,cornflowerblue,,,cadetblue,false,false,'Unknown Company',18.210000
edgedef>node1 , node2 , directed BOOLEAN, color VARCHAR, weight DOUBLE, width DOUBLE, label VARCHAR, visible BOOLEAN, labelcolor VARCHAR, labelvisible BOOLEAN
node1,node2,true,dandelion,1.000000,3.000000,'1',true,dandelion,false

gdflib provides also support for custom edges, those can be defined like custom nodes by subclassing Edge and providing additional attributes. In such case instead of using link function to link two nodes, add_edge call should be uses.

Release files for gdflib 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gdflib 0.0.1
File Size Uploaded
gdflib-0.0.1.tar.gz 4.3 kB Details

Release files / gdflib-0.0.1.tar.gz

Download URL gdflib-0.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
231e297bd17ce2a162a9d31ce30883f8fa6dea1aafe55e57531cc1856c3158e7
BLAKE2b-256 checksum
How to use checksums
ffafb69145b7a26ef7da69af79d4f1fb0e4c48016970209be7b6272af62e29b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page