Library to save graph GDF files
Project description
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.
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
File details
Details for the file gdflib-0.0.1.tar.gz
.
File metadata
- Download URL: gdflib-0.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 231e297bd17ce2a162a9d31ce30883f8fa6dea1aafe55e57531cc1856c3158e7 |
|
MD5 | 32b1b74e208e2a828b9e1df2fea0b97c |
|
BLAKE2b-256 | ffafb69145b7a26ef7da69af79d4f1fb0e4c48016970209be7b6272af62e29b8 |